Bỏ qua, tới nội dung chính

Kiến trúc · ADR 0026

ADR-0026: Backend hosting — Render (API), Supabase (Postgres), Upstash (Redis)

Trạng thái
Ngày
Người quyết định

Context

The API, worker, Postgres and Redis run only on the developer's machine. We need a first public deployment for the capstone demo, on a free tier, without a credit card, and without provisioning anything on the shared claude.ai account.

Decision

  • Postgres → Supabase, the project already created for SmartLearn (lqbnldwxodvhmevfunkw). vector and pg_trgm are pre-installed, which the catalog and AI phases (M2–M6) will need. Prisma owns the tables; migrations are applied with db:deploy.
  • Redis → Upstash, free tier, TLS URL (rediss://…) in REDIS_URL.
  • API → Render, a Docker web service on the free plan, built from apps/api/Dockerfile with the repo root as context, described by render.yaml. The managed host assigns the port through PORT, which main.ts now honours.
  • Worker → not deployed yet. Render background workers are paid and nothing enqueues jobs in the auth phase. It lands later as its own service from apps/worker/Dockerfile, sharing the same REDIS_URL.

Consequences

  • Free Render web services spin down when idle, so the first request after a quiet spell is slow. Acceptable for a demo; revisit if a mentor needs it warm.
  • Secrets (DATABASE_URL, REDIS_URL, JWT_ACCESS_SECRET, …) live only in the Render dashboard and local .env.local, never in the repo — the render.yaml entries are sync: false.
  • Migrations are run from a developer machine against Supabase (db:deploy), not on container boot, so a bad migration can never wedge a rolling deploy.
  • The runbook is docs/deploy/backend.md.