Architecture
System Overview
Section titled “System Overview”┌─────────────┐ ┌──────────────┐ ┌─────────────┐│ Amplify │────▶│ Traefik │────▶│ FastAPI ││ (Frontend) │ │ (Reverse Proxy)│ │ (Backend) │└─────────────┘ └──────────────┘ └──────┬──────┘ │ ┌───────────────────────────┤ ▼ ▼ ▼ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ RDS │ │ Valkey │ │ S3 │ │(PostgreSQL)│ │ (Cache) │ │ (Images) │ └──────────┘ └──────────┘ └──────────┘Request Flow
Section titled “Request Flow”- Frontend (React on Amplify) makes API calls to
api.tiny-agents.kovacova.ca - Traefik terminates TLS and routes to the correct backend service
- FastAPI handles the request, authenticating via Better-Auth JWTs
- PostgreSQL (RDS) stores all data; pgvector handles embedding similarity search
- Valkey caches frequently accessed data (knowledge base, sessions)
- S3 stores meal images
Database Design
Section titled “Database Design”Two databases on the same RDS instance:
mealpal— main application data (meals, chat, embeddings)auth— Better-Auth tables (users, sessions, accounts)
The mealpal database uses pgvector for RAG embeddings (1536-dimensional OpenAI vectors).
Deployment
Section titled “Deployment”Blue-green zero-downtime deploys via ./deploy.sh:
- Build new container image
- Start new container alongside the old one
- Health check the new container
- Update Traefik routing to the new container
- Drain and stop the old container
All infrastructure runs in ca-central-1 for Canadian data residency.