Overview
The platform is a single Hono application running on Cloudflare Workers, defined in api/src/app.ts. There is one app instance; everything is composed onto it as middleware and mounted route groups. The same app serves three distinct surfaces:
Authentication & authorization
Every /v1/ route runs the requireTenant middleware (api/src/middleware/auth.ts) before any handler. It establishes who the caller is and which tenant they act for; the tenant is never* taken from a request header or body.
Errors & validation
The error envelope
Rate limiting
Throttling lives in api/src/middleware/rate-limit.ts. Two limiters share one fixed-window implementation but are keyed differently and applied to different surfaces.