Backend overview
apps/backend is a small Cloudflare Worker that hosts Clay’s HTTP API. Keep it as a direct Hono app until the API surface is large enough to justify more structure.
Layout
Boundaries
Hono handlers validate at the boundary
Define route schemas with Zod and
@hono/zod-openapi next to the handler that serves the route.
Every request (params, query, body, headers) is rejected with a typed 4xx when the schema fails.OpenAPI 3.1, not 3.0
The contract is OpenAPI 3.1. The Worker exposes the document at runtime through
app.doc31("/openapi.json", ...) and at build time through getOpenApiDocument(). Do not
downgrade.Keep the backend flat while it is small
Do not add dependency injection, containers, repository layers, or service folders before the
code needs them.
Split only by pressure
When routes grow, extract route files first. Add services only when repeated business logic
appears in more than one handler.
Related
API reference
The implemented routes, schemas, and OpenAPI source.
Deploy
The Wrangler commands used to publish the Worker.
Architecture
The full Turborepo surface layout this backend lives inside.

