0008. Backend: Hono API, PostgreSQL + Drizzle, Postgres-backed jobs
- Status: Accepted
- Date: 2026-11-26
- Phase: 3
Context
Section titled “Context”The platform needs an HTTP API (accounts, games, versions, publish, catalog, packs, moderation), background jobs (build, validate, screenshot, headless runs), and a relational data model that is ready for money (purchases, revenue share, payouts). It must run locally with one command and move to the cloud by config.
Decision
Section titled “Decision”- API: Hono on Node, with
@hono/zod-openapiso routes, validation and an OpenAPI document come from the same Zod schemas. The generated OpenAPI spec produces the typed@ludrel/sdkclient. Hono also runs on Lambda/Workers/Bun if we ever need it. - Database: PostgreSQL (relational core +
jsonbfor game/scene/level documents), Drizzle ORM with SQL migrations checked into git. - Jobs: pg-boss (job queue on Postgres) behind a
JobQueueinterface; swap to SQS later if needed. - Object storage: S3 API behind a
BlobStoreinterface. Locally an S3-compatible container (choose between MinIO, Garage and SeaweedFS at Phase 3 — MinIO’s open-source distribution changed in 2025, check status then). - Cache / pub-sub: none until needed; Valkey (Redis-compatible) when multiplayer or rate limiting needs it.
Alternatives considered
Section titled “Alternatives considered”| Option | Pros | Cons |
|---|---|---|
| Fastify | Mature, fast, plugin ecosystem | Node-only; OpenAPI story slightly more config |
| NestJS | Structure for big teams | Heavy decorators/DI; overkill solo; harder for AI to edit safely |
| tRPC | Great DX for TS-only clients | We need a public, language-neutral API for the SDK and external AI tools |
| Supabase (BaaS) | Auth+DB+storage+realtime in one | Ties data model and auth to a vendor; RLS-heavy logic is harder to test |
| Prisma | Popular, good DX | Heavier runtime/engine; Drizzle is closer to SQL and lighter |
| Kysely | Excellent typed query builder | No schema/migration story of its own |
| MongoDB | Flexible documents | Money and lineage need relational integrity; Postgres jsonb covers documents |
Consequences
Section titled “Consequences”One database to operate. Postgres must be sized for analytics events later — plays/retention events go to a separate append-only table (partitioned) and can move to a warehouse/ClickHouse if volume requires.