Capsules and Configurations Design
Overview
Capsules and Configurations are core components of the Roboticks deployment pipeline: Compositions (Docker) → Capsules (Apps) → Configurations (Settings)- Capsules: Versioned application packages (.tar.gz, .zip) that run inside Docker compositions
- Configurations: Site/device-specific settings tied to capsules
- Deployment Packages: Complete deployments linking composition + capsule + configuration
Use Cases
- Development Workflow: Developers upload new capsule versions with different features/fixes
- Multi-Environment: Same capsule with different configurations (dev/staging/prod)
- Fleet Management: Deploy specific capsule+config combinations to device fleets
- Simulation: Run capsules in compositions for testing before device deployment
Architecture
Database Schema
Capsules Table
- (project_id, name, version) - No duplicate versions
- (project_id, s3_path) - Unique storage paths
- (project_id, name, is_latest) - Fast lookup of latest version
- (project_id, capsule_type) - Filter by type
- (validation_status) - Find unvalidated capsules
Configurations Table
- (project_id, name) - Unique config names per project
- (project_id, s3_path) - Unique storage paths
- (project_id, capsule_id) - Find configs for a capsule
- (project_id, environment) - Filter by environment
- (parent_config_id) - Find child configs
DeploymentPackages Table
- (project_id, deployment_status) - Find active deployments
- (capsule_id) - Find deployments using a capsule
- (configuration_id) - Find deployments using a config
S3 Storage Structure
API Authentication
Project Secret Authentication:- Each project has a
project_secret(generated on creation) - Capsule/config uploads use
X-Project-Secretheader - Download/list operations use standard JWT tokens
Semantic Versioning
Version Format:MAJOR.MINOR.PATCH
Wildcard Support:
1.2.3- Exact version1.2.*- Any patch version in 1.21.*- Any minor/patch in major 1^1.2.0- Compatible versions (>= 1.2.0, < 2.0.0)~1.2.0- Approximately equivalent (>= 1.2.0, < 1.3.0)
Enhanced Features
1. Capsule Dependencies
2. Configuration Inheritance
3. Validation Tracking
- Upload triggers validation
- Store validation status (pending/passed/failed)
- Block deployments of failed capsules/configs
4. Deployment History
- Track which capsule+config was deployed when
- Support rollback to previous deployment
- Audit trail of all deployments
API Endpoints
Capsules
Upload Capsule (with presigned URL):Configurations
Upload Configuration:Deployment Packages
Create Deployment Package:Implementation Phases
Phase 1: Backend - Database Models & Migration ✅ COMPLETED
- ✅ Created CapsuleArchive model (versioned app binaries with dependencies, validation)
- ✅ Created Configuration model (settings with inheritance, capsule linking)
- ✅ Renamed Capsule → Deployment (deployment tracking and state management)
- ✅ Updated all relationships (Project, FleetDevice, Session)
- ✅ Created comprehensive Alembic migration (
20251113_refactor_deployment_pipeline.py)
Phase 2: Backend - API Implementation (Current Priority)
- ⏳ S3 service for presigned URLs and storage management
- ⏳ Project secret generation and authentication middleware
- ⏳ Pydantic schemas (CapsuleArchiveCreate, ConfigurationCreate, etc.)
- ⏳ CapsuleArchive API endpoints (upload-url, confirm, list, get, delete)
- ⏳ Configuration API endpoints with inheritance resolution
- ⏳ Dependency resolution logic for capsule archives
Phase 2: Backend - Configurations
- Configuration database model
- Configuration API endpoints
- Inheritance resolution logic
- Validation schema support
Phase 3: Frontend - Capsules & Configurations
- Capsules page (list, upload, delete)
- Capsule details modal (all versions, metadata)
- Configurations page
- Upload wizards with drag-and-drop
Phase 4: Deployment Packages
- DeploymentPackage model
- Deployment API endpoints
- Frontend Deployments page
- Device fleet integration
Phase 5: Stats & Limits Integration
- Add capsule_storage_bytes to ProjectStats
- Add configuration_storage_bytes to ProjectStats
- Update hourly-stats-updater Lambda
- Update frontend UsageLimitsWidget
- Enforce storage limits on upload
Storage Limits
Per Organization Tier:- Free: 1 GB total storage (Docker + Capsules + Configs)
- Professional: 50 GB
- Enterprise: 500 GB
- Check total storage before accepting uploads
- Return 413 Payload Too Large if exceeds limit
- Show storage breakdown in dashboard
Security Considerations
- Project Secret: Generated on project creation, stored hashed in database
- Presigned URLs: Short expiration (1 hour for uploads, 15 min for downloads)
- Checksums: Verify SHA256 after upload to detect tampering/corruption
- Access Control: Only project members can list/download capsules/configs
- Rate Limiting: Limit upload frequency to prevent abuse
Future Enhancements
- Capsule Scanning: Security vulnerability scanning for uploaded binaries
- Configuration Encryption: Encrypt sensitive configs at rest
- Rollback Automation: Automatic rollback on deployment failure
- Version Comparison: Diff tool to compare capsule/config versions
- Dependency Resolution: Auto-download required dependency capsules
- Build Integration: CI/CD webhooks to auto-upload capsules on successful builds