System overview
DBHost is a two-tier system: a control plane on Vercel and a data plane on a VPS.Design decisions
Why split control plane and data plane?
- Security isolation — Vercel never has superuser database credentials. The agent holds the Postgres superuser password; the control plane only has a bearer token.
- Independent scaling — Frontend can scale on Vercel’s edge network. VPS handles database operations.
- Operational simplicity — Vercel handles TLS, CDN, deploys. VPS only runs database workloads.
Why PgBouncer?
PostgreSQL creates a new process per connection. With many tenants, this wastes memory. PgBouncer multiplexes many client connections onto a small number of backend connections. The agent manages PgBouncer by directly editing its INI config file and sending SIGHUP to reload. This avoids needing PgBouncer admin credentials or a management socket.Why Drizzle over Prisma?
- Zero runtime overhead (generates raw SQL)
- TypeScript-native (no code generation step)
- Migration system is SQL-based (reviewable, reversible)
- Smaller bundle size
Why FastAPI?
- Async-first (all database operations are I/O-bound)
- Minimal — no heavy framework for a ~10 endpoint agent
- Pydantic models for request/response validation
- psycopg 3 integrates cleanly with async/await
Why Clerk?
- Enterprise-grade auth without building it
- OAuth, SAML, MFA out of the box
- Backend API for admin operations (ban, delete, change email)
- Webhook system for user sync
Data flow: creating a database
agent.deleteDatabase(name).