Component-specific development documentation for contributing to Axionyx.
This section provides comprehensive development guides for all Axionyx components, covering setup, architecture, best practices, testing, and debugging.
- Firmware Overview - Getting started with firmware
- Adding New Devices - Create new device types
- Common Components - Using shared libraries
- Testing - Firmware testing strategies
- Debugging - Debug tools and techniques
- Backend Overview - Python/FastAPI development
- API Development - Adding new endpoints
- Database Migrations - Schema management
- Testing - Backend testing
- Frontend Overview - Next.js development
- Components - Creating UI components
- Routing - Navigation and routing
- Testing - Frontend testing
- Mobile Overview - Flutter development
- Screens - Creating app screens
- Device Integration - Connect to devices
- Testing - Mobile testing
- GitHub Actions - CI/CD workflows
- Pre-commit Hooks - Code quality gates
- Deployment - Deployment strategies
General:
- Git 2.30+
- Code editor (VS Code recommended)
- Terminal/shell access
Component-Specific:
- Firmware: PlatformIO or Arduino IDE
- Backend: Python 3.12+, uv package manager
- Frontend: Node.js 18+, npm/yarn
- Mobile: Flutter SDK 3.2.6+
See Getting Started for detailed setup.
-
Clone Repository
git clone https://github.com/axionyx/axionyx.git cd axionyx -
Create Feature Branch
git checkout -b feature/your-feature-name
-
Make Changes
- Write code
- Write tests
- Update documentation
-
Run Tests
# Component-specific test commands -
Commit Changes
git add . git commit -m "feat: add new feature"
-
Push and Create PR
git push origin feature/your-feature-name
Follow Conventional Commits:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Types:
feat:New featurefix:Bug fixdocs:Documentation changesstyle:Code style changes (formatting)refactor:Code refactoringtest:Adding or updating testschore:Maintenance tasks
Examples:
feat(firmware): add support for new sensor type
fix(api): correct temperature calculation in PCR
docs(readme): update installation instructions
Style:
- Google C++ Style Guide
- 4-space indentation
- CamelCase for classes
- camelCase for methods
- UPPER_CASE for constants
Example:
class TemperatureController {
public:
void setSetpoint(float temperature);
float getCurrentTemperature() const;
private:
static const int MAX_TEMPERATURE = 120;
float currentTemp;
};Style:
- PEP 8
- Black formatter
- Ruff linter
- 4-space indentation
- snake_case for functions/variables
- PascalCase for classes
Example:
class DeviceService:
def get_device_status(self, device_id: str) -> DeviceStatus:
"""Get current device status."""
device = self.repository.find_by_id(device_id)
return device.get_status()Style:
- ESLint + Prettier
- 2-space indentation
- camelCase for variables/functions
- PascalCase for components/types
- Functional components with hooks
Example:
interface DeviceProps {
deviceId: string;
onUpdate: (data: DeviceData) => void;
}
export function DeviceMonitor({ deviceId, onUpdate }: DeviceProps) {
const [status, setStatus] = useState<DeviceStatus | null>(null);
// ...
}Style:
- Effective Dart
- 2-space indentation
- camelCase for variables/methods
- PascalCase for classes
- Trailing commas for better formatting
Example:
class DeviceController extends ChangeNotifier {
DeviceStatus? _status;
Future<void> updateStatus(String deviceId) async {
final status = await deviceRepository.getStatus(deviceId);
_status = status;
notifyListeners();
}
}Test individual functions and classes in isolation.
Coverage Goal: 80%+
Tools:
- Firmware: Unity test framework
- Backend: pytest
- Frontend: Jest + React Testing Library
- Mobile: Flutter test framework
Test component interactions.
Coverage:
- API endpoint testing
- Database operations
- WebSocket communication
Test complete user workflows.
Tools:
- Frontend: Playwright
- Mobile: Flutter integration tests
- API: Postman collections
Serial Monitor:
pio device monitorLogging Levels:
Logger::debug("Debug message");
Logger::info("Info message");
Logger::warning("Warning message");
Logger::error("Error message");Hardware Debugger:
- JTAG debugging with ESP-PROG
- GDB integration
Debugger:
python -m debugpy --listen 5678 main.pyLogging:
import logging
logging.debug("Debug message")Database Inspection:
psql -d axionyxBrowser DevTools:
- React DevTools extension
- Network tab for API calls
- Console for errors
Next.js Debugging:
NODE_OPTIONS='--inspect' npm run devFlutter DevTools:
flutter pub global activate devtools
flutter pub global run devtoolsDebug Mode:
flutter run --debug- Create device class extending
DeviceBase - Implement required methods
- Create device-specific logic (e.g., control algorithms)
- Add API endpoint handlers
- Update documentation
- Write tests
See Adding New Devices for details.
- Define route in
HTTPServer.cpp - Implement handler function
- Add request/response validation
- Update API documentation
- Write integration tests
See API Development for details.
- Create component file
- Define props interface
- Implement component logic
- Add styling (Tailwind CSS)
- Export component
- Write tests
See Components for details.
- Create screen widget
- Define navigation route
- Implement screen logic
- Add state management
- Connect to API
- Write tests
See Screens for details.
- Minimize memory allocations
- Use const references
- Optimize loop iterations
- Disable debug logging in production
- Use async/await for I/O operations
- Implement connection pooling
- Cache frequently accessed data
- Profile with cProfile
- Code splitting for route-based loading
- Lazy load components
- Optimize images (WebP, responsive)
- Memoize expensive calculations
- Use const constructors
- Implement ListView.builder for long lists
- Optimize build methods
- Profile with DevTools
- Never commit secrets to git
- Use environment variables for config
- Validate all user inputs
- Follow principle of least privilege
- Encrypt WiFi credentials in SPIFFS
- Implement secure pairing
- Validate API requests
- Use HTTPS for OTA updates (production)
- Use parameterized queries (prevent SQL injection)
- Implement rate limiting
- Validate JWT tokens
- Hash passwords with bcrypt
- Sanitize user inputs
- Use HTTPS for API calls
- Store tokens securely (Keychain/Keystore)
- Implement CSRF protection
- Public APIs and interfaces
- Complex algorithms
- Configuration options
- Breaking changes
- Migration guides
Code Comments:
/**
* Sets the temperature setpoint for a specific zone.
*
* @param zone Zone number (0-2)
* @param temperature Target temperature in Celsius (0-120)
* @return true if successful, false if out of range
*/
bool setSetpoint(uint8_t zone, float temperature);Markdown Docs:
- Clear titles and structure
- Code examples
- Links to related docs
- Updated with code changes
See Documentation Guide.
- GitHub Discussions
- Issue tracker
- Pull request reviews
Comprehensive guide to ESP32 firmware development, including:
- Device abstraction patterns
- Using common components (WiFi, Config, HTTP, WebSocket)
- Sensor simulation
- PID control implementation
- Testing and debugging
Python/FastAPI backend development guide:
- Project structure
- Database models and migrations
- Service layer patterns
- API endpoint implementation
- Testing and CI/CD
Next.js web dashboard development:
- App router patterns
- Server vs client components
- State management
- API integration
- Testing strategies
Flutter mobile app development:
- Project architecture
- State management (Provider/BLoC)
- WebSocket integration
- Device discovery and pairing
- Platform-specific features