Deployment
Production target architecture for Race Platform. The same source tree that runs in docker-compose locally swaps in managed cloud services through driver environment variables.
Cloud target
| Layer | Local | Production |
|---|---|---|
| DB | Postgres 16 (docker) | Supabase Postgres + Auth + Realtime |
| Object storage | MinIO (docker) | Cloudflare R2 |
| KV | Redis (docker) | Cloudflare KV |
| API | Hono on Node (docker) | Cloudflare Workers |
| Realtime | ws on Node (docker) | Cloudflare Durable Objects |
| Queue | (none) | Cloudflare Queues (webhook retries, KPI jobs) |
| Strategy engine | Python (docker) | Fly.io |
| Search / AI memory | (none yet) | Cloudflare Vectorize |
| Edge ingester | Rust binary | Rust binary on pit-box laptop |
Everything is provisioned via OpenTofu — see
infra/opentofu/ for the modules and .tfvars shape.
Environment-driven driver selection
Adapters live in apps/<svc>/src/adapters/, interfaces in
apps/<svc>/src/ports/. Selection happens at runtime via these
env vars:
| Env var | Choices | Default |
|---|---|---|
STORAGE_DRIVER | minio / r2 | minio |
KV_DRIVER | redis / cf-kv | redis |
DB_DRIVER | postgres / supabase | postgres |
REALTIME_DRIVER | ws / cf-do | ws |
There is no cloud-provider name in business logic — adding AWS as a future driver target is one new adapter, not a refactor.
Cost target
- $0 during local development
- ~$40/month through alpha pilots (Supabase Free + Cloudflare Workers Free tier + R2's zero-egress pricing)
- Scales linearly with pilot teams added
What you can do today
- Run the full stack locally with the docker-compose path
- Run the OpenTofu plan against a Cloudflare + Supabase project
in dry-run mode (
tofu plan) - Build the API for the Workers target (
pnpm build)
What's coming
- First-pilot production rollout — wires up Supabase + R2 + Workers end to end
- CI deploy pipeline — GitHub Actions → Cloudflare Workers on every main merge
- Per-environment Secrets management — Doppler / Cloudflare Secrets
- Database backups — automated nightly Supabase snapshots + S3 dump