Path B (Full Stack)
Path B is the full-stack runtime:
- Auth: better-auth
- Backend: Hono on Cloudflare Workers
- DB: Cloudflare D1 (SQLite edge) via Drizzle
- Rate limiting: fixed-window limiter on AI proxy routes (
RATE_LIMIT_KVwhen bound, in-memory fallback otherwise) - Deploy: Wrangler or Alchemy
When to pick Path B
Section titled “When to pick Path B”Pick it if you need:
- custom API endpoints
- server-side auth/session management
- AI proxy + rate limiting + usage logging
- a clean path to multi-platform later
Local dev
Section titled “Local dev”cd backendnpm installnpm run devbackend/src/index.ts mounts:
/api/auth/*/api/ai/chat/api/chat/*/api/user/profile/api/user/settings/api/feedback/api/health, /api/info, /api/me, /api/users*Database schema
Section titled “Database schema”Drizzle schema lives in:
backend/src/db/schema.ts
Key route files:
backend/src/routes/auth.tsbackend/src/routes/ai-proxy.tsbackend/src/routes/chat.tsbackend/src/routes/profile.tsbackend/src/routes/settings.tsbackend/src/routes/feedback.tsbackend/src/routes/api.ts