Solutions Directory¶
This directory contains documented solutions for complex problems encountered during Reggie development and deployment.
AWS Migration via SST¶
File: aws-migration-sst-complete-solution.md
Status: Phase 2 deployed to dev stage (2026-03-05)
Complete documentation of the migration from PaaS (Vercel + Railway + Supabase) to AWS using SST infrastructure-as-code framework.
Four Critical Fixes¶
- Docker Build Context Optimization (Fix 1)
- Problem: 1.5 GB monorepo sent per build
- Solution: Set
image.context: "./backend"in SST config -
Impact: 140x faster builds
-
Environment Variable Mapping (Fix 2)
- Problem: SST
linkfeature doesn't constructDATABASE_URLthat FastAPI expects - Solution: Use
$interpolateto construct URL from RDS properties -
Impact: FastAPI can read all required environment variables from SST secrets
-
Database Schema Bootstrap (Fix 3)
- Problem: Alembic migrations reference Supabase-specific schemas (
auth.*) that don't exist on fresh RDS - Solution: Use
Base.metadata.create_all()+alembic stamp headto bootstrap schema on fresh instances -
Impact: RDS provisioning completes without migration errors
-
SST v4 VPC Component Versioning (Fix 4)
- Problem: Breaking changes in
sst.aws.Vpccomponent between SST versions - Solution:
sst remove --stage <stage>thensst deploy --stage <stage> - Impact: VPC created with latest component format
Key Files¶
- SST Configuration:
sst.config.ts(incorporates all four fixes) - Docker Configuration:
backend/Dockerfile(multi-stage build) - Bootstrap Script:
backend/scripts/bootstrap_schema.py(schema initialization) - App Configuration:
backend/app/config.py(environment variable parsing)
Deployment Status (dev stage)¶
| Service | URL | Status |
|---|---|---|
| Web App | https://d1kvp1h7e9gtgw.cloudfront.net | Live (200) |
| Admin App | https://d3dl7l95t7kngj.cloudfront.net | Live (307 → login) |
| Backend API | http://ReggieApiLoadBa-doktwzst-534252255.eu-west-2.elb.amazonaws.com | Live (health: connected) |
| API Docs | http://ReggieApiLoadBa-doktwzst-534252255.eu-west-2.elb.amazonaws.com/api/v1/docs | Live (200) |
Architecture¶
- Frontend: CloudFront + Lambda + S3 (Next.js via SST)
- Backend: ECS Fargate 0.25 vCPU (FastAPI) + ALB
- Database: RDS PostgreSQL db.t4g.micro (free tier)
- Networking: No NAT, public subnets for cost savings
- Auth: Clerk (migrated from Supabase Auth -- see ADR-001)
- Storage: Cloudflare R2 (EU jurisdiction)
Quick Start¶
Deploy to dev:
Bootstrap RDS schema (one-time):
Run smoke tests:
Local development (unchanged):
Known Gaps¶
- ML models not in Docker image — Rules engine works, ML ensemble unavailable
SKIP_MIGRATIONS=truehardcoded — Can remove once bootstrap is confirmed operational- Auth JWT validation — Needs SUPABASE_SERVICE_ROLE_KEY configuration
Cost Estimate¶
| Item | Monthly |
|---|---|
| Free tier (12 months) | ~$10 |
| After free tier expires | ~$55 |
Related Documentation¶
- Full plan:
plans/aws-migration-sst.md(4 phases) - Migration workflow:
docs/solutions/workflow-issues/ci-migration-fails-fresh-db-20260224.md - Enterprise architecture review:
docs/enterprise-architecture-review.md - Developer guide:
CLAUDE.md
Troubleshooting¶
See "Troubleshooting Quick Reference" in aws-migration-sst-complete-solution.md for common errors and fixes.