๐จโ๐ป Development Guide
Complete guide for developers working on SYMS OS Edge. Learn how to set up your development environment, understand the codebase, and contribute effectively.
๐ง Development Environment Setup
Prerequisites
| Tool | Version | Purpose |
|---|---|---|
| Docker Desktop | Latest | Container orchestration |
| Node.js | 20+ | JavaScript runtime |
| Git | 2.40+ | Version control |
| VS Code | Latest | Code editor (recommended) |
| PostgreSQL Client | 14+ | Database management (optional) |
Clone and Setup
# Clone the repository
git clone https://github.com/lvmre/syms-os-edge.git
cd syms-os-edge
# Copy environment template
cp .env.example docker/.env
# Install dependencies
npm install
# Start development environment
cd docker
docker compose up -d
๐ก Tip: Edit
docker/.env with your local settings before starting services. Use strong passwords and unique secrets for security.
VS Code Extensions (Recommended)
- ESLint - Code linting for JavaScript
- Prettier - Code formatting
- Docker - Container management
- GitLens - Enhanced Git integration
- Thunder Client - API testing
Local Testing
Start all services locally for development:
# Start all services
cd docker
docker compose up -d
# View logs
docker compose logs -f
# Check service status
docker compose ps
# Stop all services
docker compose down
Access Points:
- Portal:
http://localhost:80 - Admin Dashboard:
http://localhost:3000 - API Gateway:
http://localhost:8080 - Grafana:
http://localhost:3001
๐ Project Structure
syms-os-edge/
โโโ os/ # OS layer & bootstrap scripts
โ โโโ scripts/
โ โ โโโ bootstrap.sh # Initial system setup
โ โ โโโ wifi-hotspot.sh # Wi-Fi AP configuration
โ โ โโโ system-tweaks.sh # Performance optimization
โ โโโ config/
โ โโโ rc.local # Boot configuration
โ
โโโ docker/ # Docker orchestration
โ โโโ docker-compose.yml # Main compose file
โ โโโ .env # Environment variables
โ โโโ nginx/ # Reverse proxy config
โ โโโ postgres/ # Database initialization
โ โโโ prometheus/ # Monitoring config
โ
โโโ api-gateway/ # Express.js API server
โ โโโ src/
โ โ โโโ routes/ # API endpoints
โ โ โโโ middleware/ # Auth, logging, etc.
โ โ โโโ services/ # Business logic
โ โ โโโ models/ # Database models
โ โโโ package.json
โ
โโโ admin-dashboard/ # React admin interface
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โโโ pages/ # Page components
โ โ โโโ hooks/ # Custom hooks
โ โ โโโ utils/ # Helper functions
โ โโโ package.json
โ
โโโ portal/ # Student/teacher portal
โ โโโ public/ # Static assets
โ โโโ src/
โ โ โโโ components/
โ โ โโโ views/
โ โ โโโ api/
โ โโโ package.json
โ
โโโ device-agent/ # Pi device management
โ โโโ src/
โ โ โโโ enrollment.js # Device registration
โ โ โโโ heartbeat.js # Health monitoring
โ โ โโโ ota-update.js # OTA update handler
โ โโโ package.json
โ
โโโ sync-agent/ # Content synchronization
โ โโโ src/
โ โ โโโ download.js # Content fetcher
โ โ โโโ storage.js # Local storage manager
โ โ โโโ priority-queue.js # Sync prioritization
โ โโโ package.json
โ
โโโ ui-shell/ # Qt Quick kiosk UI
โ โโโ main.qml # Main UI layout
โ โโโ components/ # Reusable QML components
โ โโโ resources/ # Images, fonts, etc.
โ
โโโ shared/ # Shared utilities
โ โโโ logger.js # Winston logger
โ โโโ db.js # Database connection
โ โโโ validators.js # Input validation
โ
โโโ tests/ # Test suites
โโโ unit/ # Unit tests
โโโ integration/ # Integration tests
โโโ e2e/ # End-to-end tests
๐ Development Workflow
Standard Git Workflow
- Create feature branch
git checkout -b feature/my-new-feature - Make changes - Edit code, add features, fix bugs
- Test locally
npm test docker compose up -d # Manual testing in browser - Commit changes
git add . git commit -m "feat: add user authentication" - Push to GitHub
git push origin feature/my-new-feature - Create Pull Request - Via GitHub web interface
- Code Review - Address feedback, make updates
- Merge to main - After approval
- Deploy to test environment - Automated or manual
Commit Message Convention
Follow Conventional Commits specification:
feat:New featurefix:Bug fixdocs:Documentation changesstyle:Code style changes (formatting)refactor:Code refactoringtest:Adding or updating testschore:Maintenance tasks
Examples:
feat: add offline content search
fix: resolve database connection timeout
docs: update API endpoint documentation
refactor: extract auth logic into middleware
๐งช Testing
Running Tests
# Run all tests
npm test
# Run specific test suite
npm test -- api-gateway
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch
Test Types
| Type | Framework | Command |
|---|---|---|
| Unit Tests | Jest | npm run test:unit |
| Integration Tests | Jest + Supertest | npm run test:integration |
| E2E Tests | Playwright | npm run test:e2e |
Writing Tests
Example unit test:
// tests/unit/auth.test.js
const { validatePassword } = require('../../shared/validators');
describe('Password Validation', () => {
test('should accept strong password', () => {
const result = validatePassword('SecurePass123!');
expect(result.valid).toBe(true);
});
test('should reject weak password', () => {
const result = validatePassword('weak');
expect(result.valid).toBe(false);
expect(result.error).toBe('Password too short');
});
});
๐ Deployment
Production Deployment
# 1. Build production images
docker compose -f docker-compose.prod.yml build
# 2. Push to registry (if using)
docker compose -f docker-compose.prod.yml push
# 3. Deploy to Pi
ssh pi@syms-edge-01
cd syms-os-edge
git pull origin main
docker compose -f docker-compose.prod.yml up -d
OTA Updates
Push updates to deployed devices via admin dashboard:
- Navigate to Fleet Management
- Select device group
- Click Deploy Update
- Choose update type (full / incremental)
- Monitor progress in real-time
โ ๏ธ Important: Always test OTA updates on a test device before deploying to production fleet. Enable automatic rollback for safety.
Monitoring Deployment
Track deployment health:
- Grafana Dashboards: Real-time metrics
- Prometheus Alerts: Automated notifications
- Device Logs: Centralized logging via Loki
- Health Checks: API endpoint monitoring
๐ค Contributing
Code Style
- Use ESLint for JavaScript linting
- Use Prettier for code formatting
- Follow Airbnb JavaScript Style Guide
- Write descriptive variable and function names
- Add JSDoc comments for public APIs
Pull Request Guidelines
- One feature per PR - Keep changes focused
- Add tests - New features must include tests
- Update documentation - If API changes
- Follow commit conventions - Use Conventional Commits
- Request review - From at least one maintainer
Code Review Checklist
- โ Code follows style guidelines
- โ Tests pass and cover new code
- โ Documentation is updated
- โ No security vulnerabilities introduced
- โ Performance impact is acceptable
- โ Changes are backwards compatible (if possible)
Getting Help
- GitHub Discussions: Ask questions, share ideas
- GitHub Issues: Report bugs, request features
- Email: [email protected]
- Slack: Join our developer community (link in repo)
๐ Next Steps:
- Read the Setup Guide for deployment instructions
- Check Changelog for recent updates
- Review Release Notes for version info