Overview
Open Wearables uses Docker Compose to orchestrate multiple services including the FastAPI backend, PostgreSQL database, Redis cache, Celery workers, and React frontend. This guide covers both development and production deployments.Architecture
The platform consists of seven containerized services:| Service | Container | Port | Description |
|---|---|---|---|
| PostgreSQL | postgres__open-wearables | 5432 | Primary database |
| Redis | redis__open-wearables | 6379 | Cache and message broker |
| Backend API | backend__open-wearables | 8000 | FastAPI application |
| Celery Worker | celery-worker__open-wearables | - | Background task processor |
| Celery Beat | celery-beat__open-wearables | - | Scheduled task scheduler |
| Flower | flower__open-wearables | 5555 | Celery monitoring UI |
| Frontend | frontend__open-wearables | 3000 | React application |
Quick Start
Configure environment variables
Copy the example environment file and customize it:See Environment Variables for configuration details.
Start all services
- Build the backend and frontend images
- Start all seven services
- Apply database migrations automatically
- Create the default admin account ([email protected] / your-secure-password)
Verify deployment
Access the services:
- Frontend: http://localhost:3000
- API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Celery Flower: http://localhost:5555
Service Configuration
Database (PostgreSQL)
The PostgreSQL service includes health checks to ensure availability before dependent services start:docker-compose.yml
Backend API
The main FastAPI application depends on both database and Redis services:docker-compose.yml
- Waits for database health check before starting
- Loads environment variables from
.envfile - Auto-restarts on failure
- Hot-reload support in development mode
Celery Worker
Processes background tasks for data syncing, webhooks, and scheduled jobs:docker-compose.yml
The Celery worker uses the same Docker image as the backend API to ensure consistency.
Celery Beat
Schedules periodic tasks like automatic data synchronization:docker-compose.yml
- Automatic user data sync every hour (configurable via
SYNC_INTERVAL_SECONDS) - Sleep data processing every hour (configurable via
SLEEP_SYNC_INTERVAL_SECONDS)
Redis
Serves as both cache and message broker for Celery:docker-compose.yml
Flower (Celery Monitoring)
Provides a web UI for monitoring Celery tasks:docker-compose.yml
- Active tasks and workers
- Task history and statistics
- Worker performance metrics
Frontend
React application served with Vite in development mode:docker-compose.yml
Development Workflow
Hot Reload
The Docker Compose configuration includes watch mode for automatic reloading:- Backend code changes (
backend/app/) trigger sync without restart - Migration changes (
backend/migrations/) trigger sync and restart - Environment file changes (
.env) trigger sync and restart - Dependency changes (
uv.lock) trigger full rebuild - Frontend code changes (
frontend/src/) trigger sync without restart
Useful Commands
View logs
View logs
Execute commands in containers
Execute commands in containers
Rebuild services
Rebuild services
Reset database
Reset database
Production Deployment
Prerequisites
Production environment file
Create a production Update critical settings:
.env file with secure credentials:ENVIRONMENT=production- Generate secure
SECRET_KEY(see Environment Variables) - Set strong database password
- Enable Redis authentication
- Configure CORS origins
- Set up email service (Resend API key)
- Configure Sentry for error tracking
Production Best Practices
Recommended production setup:- Use managed services for PostgreSQL and Redis (AWS RDS, Azure Database, etc.)
- Reverse proxy with SSL/TLS termination (nginx, Caddy, Traefik)
- Container orchestration (Kubernetes, ECS, or Docker Swarm) for scaling
- Monitoring with Prometheus + Grafana or cloud-native solutions
- Log aggregation with ELK stack or cloud logging services
- Backup strategy for database and persistent volumes
- CI/CD pipeline for automated testing and deployment
Scaling
Scale Celery workers
Scale Celery workers
Scale backend API
Scale backend API
When scaling the API behind a load balancer:Configure your load balancer (nginx, Traefik, etc.) to distribute traffic.
docker-compose.prod.yml
Health Checks and Monitoring
The API provides health check endpoints:Troubleshooting
Service won't start
Service won't start
Check logs:Common issues:
- Database not ready: Wait for health check to pass
- Port already in use: Change port mapping in docker-compose.yml
- Environment variables missing: Check
.envfile exists and has required values
Database connection errors
Database connection errors
Verify database is running:Check database logs:Test connection manually:
Celery tasks not processing
Celery tasks not processing
Check worker status:Verify Redis connection:Check Flower for task queue:
Open http://localhost:5555 and verify workers are active
Out of disk space
Out of disk space
Clean up Docker resources:
Next Steps
Environment Variables
Configure your deployment with environment variables
Database Setup
Advanced database configuration and migrations
