SYMS OS Logo

Developer Guide

โ† Back to Home

๐Ÿ‘จโ€๐Ÿ’ป 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)

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:

๐Ÿ“ 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

  1. Create feature branch
    git checkout -b feature/my-new-feature
  2. Make changes - Edit code, add features, fix bugs
  3. Test locally
    npm test
    docker compose up -d
    # Manual testing in browser
  4. Commit changes
    git add .
    git commit -m "feat: add user authentication"
  5. Push to GitHub
    git push origin feature/my-new-feature
  6. Create Pull Request - Via GitHub web interface
  7. Code Review - Address feedback, make updates
  8. Merge to main - After approval
  9. Deploy to test environment - Automated or manual

Commit Message Convention

Follow Conventional Commits specification:

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:

  1. Navigate to Fleet Management
  2. Select device group
  3. Click Deploy Update
  4. Choose update type (full / incremental)
  5. 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:

๐Ÿค Contributing

Code Style

Pull Request Guidelines

  1. One feature per PR - Keep changes focused
  2. Add tests - New features must include tests
  3. Update documentation - If API changes
  4. Follow commit conventions - Use Conventional Commits
  5. Request review - From at least one maintainer

Code Review Checklist

Getting Help

๐ŸŽ“ Next Steps: