How It Works
The runtime path is intentionally short and explicit so it is easy to reason about performance and failure modes.
Runtime path
Section titled “Runtime path”src/server.tsloads env config and builds a Fastify instance with Zod type providers.registerPlugins()wires CORS, database, auth, and routes under/api/v1.- Requests flow: route -> controller -> service -> Drizzle ORM -> Turso.
- The server listens on
0.0.0.0:${PORT}(default51214). - In tests (
NODE_ENV=test), the server does not auto-start.
Client -> /api/v1 -> routes -> controllers -> services -> db (Drizzle -> Turso)Why these choices
Section titled “Why these choices”Fastify
Section titled “Fastify”Performance first. Fastify keeps the request path lean and predictable.
Turso (libSQL)
Section titled “Turso (libSQL)”Edge-friendly SQLite with low-latency reads at scale.
Identity is handled outside the API so passwords never touch the service.
Schemas validate input and serialize output consistently, keeping contracts stable.
Auth boundaries
Section titled “Auth boundaries”- Public reads:
GETendpoints for posts and categories. - Protected writes:
POST,PUT, andDELETErequire a valid Clerk JWT.