|
| 1 | +# Docker Architecture Diagram |
| 2 | + |
| 3 | +``` |
| 4 | +┌─────────────────────────────────────────────────────────────────────┐ |
| 5 | +│ Docker Host Machine │ |
| 6 | +│ │ |
| 7 | +│ ┌─────────────────────────────────────────────────────────────┐ │ |
| 8 | +│ │ Docker Network: inpactai-network │ │ |
| 9 | +│ │ │ │ |
| 10 | +│ │ ┌──────────────────┐ ┌──────────────────┐ ┌────────┐│ │ |
| 11 | +│ │ │ Frontend │ │ Backend │ │ Redis ││ │ |
| 12 | +│ │ │ Container │ │ Container │ │ Container │ |
| 13 | +│ │ │ │ │ │ │ ││ │ |
| 14 | +│ │ │ Node 18-alpine │ │ Python 3.10-slim │ │ Redis 7││ │ |
| 15 | +│ │ │ Vite Dev Server │◄───┤ FastAPI + uvicorn │ Alpine ││ │ |
| 16 | +│ │ │ Port: 5173 │ │ Port: 8000 │◄───┤ Port: ││ │ |
| 17 | +│ │ │ │ │ │ │ 6379 ││ │ |
| 18 | +│ │ └──────────────────┘ └──────────────────┘ └────────┘│ │ |
| 19 | +│ │ │ │ │ │ │ |
| 20 | +│ │ │ Volume Mount │ Volume Mount │ │ │ |
| 21 | +│ │ │ (Hot Reload) │ (Hot Reload) │ │ │ |
| 22 | +│ │ ▼ ▼ ▼ │ │ |
| 23 | +│ │ ┌──────────────┐ ┌─────────────┐ ┌──────────┐│ │ |
| 24 | +│ │ │ ./Frontend │ │ ./Backend │ │redis_data││ │ |
| 25 | +│ │ │ /app │ │ /app │ │ Volume ││ │ |
| 26 | +│ │ └──────────────┘ └─────────────┘ └──────────┘│ │ |
| 27 | +│ └─────────────────────────────────────────────────────────────┘ │ |
| 28 | +│ │ |
| 29 | +│ Port Mappings: │ |
| 30 | +│ ┌─────────────┬──────────────┬────────────────────────────────┐ │ |
| 31 | +│ │ Host:5173 │ ──────────► │ frontend:5173 (React + Vite) │ │ |
| 32 | +│ │ Host:8000 │ ──────────► │ backend:8000 (FastAPI) │ │ |
| 33 | +│ │ Host:6379 │ ──────────► │ redis:6379 (Cache) │ │ |
| 34 | +│ └─────────────┴──────────────┴────────────────────────────────┘ │ |
| 35 | +│ │ |
| 36 | +│ Environment Files: │ |
| 37 | +│ ┌────────────────────────────────────────────────────────────┐ │ |
| 38 | +│ │ Backend/.env → Backend Container │ │ |
| 39 | +│ │ Frontend/.env → Frontend Container │ │ |
| 40 | +│ └────────────────────────────────────────────────────────────┘ │ |
| 41 | +│ │ |
| 42 | +└───────────────────────────────────────────────────────────────────────┘ |
| 43 | +
|
| 44 | +User Browser |
| 45 | + │ |
| 46 | + ▼ |
| 47 | +http://localhost:5173 ──► Frontend Container ──► React UI |
| 48 | + │ |
| 49 | + │ API Calls |
| 50 | + ▼ |
| 51 | + http://backend:8000 ──► Backend Container ──► FastAPI |
| 52 | + │ |
| 53 | + │ Cache/PubSub |
| 54 | + ▼ |
| 55 | + redis:6379 ──► Redis Container |
| 56 | +
|
| 57 | +
|
| 58 | +Communication Flow: |
| 59 | +────────────────────── |
| 60 | +
|
| 61 | +1. User accesses http://localhost:5173 |
| 62 | + └─► Docker routes to Frontend Container |
| 63 | +
|
| 64 | +2. Frontend makes API call to /api/* |
| 65 | + └─► Vite proxy forwards to http://backend:8000 |
| 66 | + └─► Docker network resolves 'backend' to Backend Container |
| 67 | +
|
| 68 | +3. Backend connects to Redis |
| 69 | + └─► Uses REDIS_HOST=redis environment variable |
| 70 | + └─► Docker network resolves 'redis' to Redis Container |
| 71 | +
|
| 72 | +4. Backend connects to Supabase |
| 73 | + └─► Uses credentials from Backend/.env |
| 74 | + └─► External connection via internet |
| 75 | +
|
| 76 | +
|
| 77 | +Service Dependencies: |
| 78 | +───────────────────── |
| 79 | +
|
| 80 | +redis (no dependencies) |
| 81 | + │ |
| 82 | + └─► backend (depends on redis) |
| 83 | + │ |
| 84 | + └─► frontend (depends on backend) |
| 85 | +
|
| 86 | +
|
| 87 | +Health Checks: |
| 88 | +────────────── |
| 89 | +
|
| 90 | +Redis: redis-cli ping |
| 91 | +Backend: curl http://localhost:8000/ |
| 92 | +Frontend: No health check (depends on backend health) |
| 93 | +
|
| 94 | +
|
| 95 | +Volume Mounts: |
| 96 | +────────────── |
| 97 | +
|
| 98 | +Development: |
| 99 | + ./Backend:/app (Hot reload for Python) |
| 100 | + ./Frontend:/app (Hot reload for Vite) |
| 101 | + /app/__pycache__ (Excluded) |
| 102 | + /app/node_modules (Excluded) |
| 103 | +
|
| 104 | +Production: |
| 105 | + redis_data:/data (Persistent Redis storage only) |
| 106 | +
|
| 107 | +
|
| 108 | +Build Process: |
| 109 | +────────────── |
| 110 | +
|
| 111 | +Development: |
| 112 | + 1. Copy package files |
| 113 | + 2. Install dependencies |
| 114 | + 3. Copy source code |
| 115 | + 4. Start dev server with hot reload |
| 116 | +
|
| 117 | +Production: |
| 118 | + Stage 1: Build |
| 119 | + 1. Copy package files |
| 120 | + 2. Install dependencies |
| 121 | + 3. Copy source code |
| 122 | + 4. Build optimized bundle |
| 123 | + |
| 124 | + Stage 2: Serve |
| 125 | + 1. Copy built artifacts |
| 126 | + 2. Use minimal runtime (nginx for frontend) |
| 127 | + 3. Serve optimized files |
| 128 | +
|
| 129 | +
|
| 130 | +Network Isolation: |
| 131 | +────────────────── |
| 132 | +
|
| 133 | +Internal Network (inpactai-network): |
| 134 | + - frontend ←→ backend (HTTP) |
| 135 | + - backend ←→ redis (TCP) |
| 136 | + |
| 137 | +External Access: |
| 138 | + - Host machine → All containers (via port mapping) |
| 139 | + - Backend → Supabase (via internet) |
| 140 | + - Backend → External APIs (via internet) |
| 141 | +
|
| 142 | +
|
| 143 | +Security Model: |
| 144 | +─────────────── |
| 145 | +
|
| 146 | +Development: |
| 147 | + - Root user in containers (for hot reload) |
| 148 | + - Source code mounted as volumes |
| 149 | + - Debug logging enabled |
| 150 | +
|
| 151 | +Production: |
| 152 | + - Non-root user in containers |
| 153 | + - No volume mounts (except data) |
| 154 | + - Production logging |
| 155 | + - Resource limits enforced |
| 156 | + - Optimized images |
| 157 | +``` |
| 158 | + |
| 159 | +## Quick Command Reference |
| 160 | + |
| 161 | +```bash |
| 162 | +Start: docker compose up --build |
| 163 | +Stop: docker compose down |
| 164 | +Logs: docker compose logs -f |
| 165 | +Rebuild: docker compose up --build |
| 166 | +Clean: docker compose down -v |
| 167 | +``` |
| 168 | + |
| 169 | +## Service URLs |
| 170 | + |
| 171 | +| Service | Internal | External | |
| 172 | +|---------|----------|----------| |
| 173 | +| Frontend | frontend:5173 | http://localhost:5173 | |
| 174 | +| Backend | backend:8000 | http://localhost:8000 | |
| 175 | +| Redis | redis:6379 | localhost:6379 | |
0 commit comments