The backend
The backend is the one service behind every page and every API call. It holds the database and decides who may see what, and it does the work a request asks for. Everything in it lives in the adhbackend repository, and this page walks through its parts.
| Piece | What it is |
|---|---|
| Boot | It registers the MCP sources, opens the database pools and the notification hub, seeds templates, checks the registries, mounts the routes and starts the workers. |
| The schema | The Drizzle schema, one file per Postgres schema. |
| The migrations | Generated by pnpm db:generate and applied by pnpm db:migrate and pnpm db:deploy. |
| The generated routes | The routes made from tables: the generator, the factory, the exposure tiers, hooks and decorators. |
| The hand-written routes | The routes written by hand. |
| The middleware | What every request passes through: auth, tenancy, CORS, usage, feature gates and body limits. |
| MCP | The MCP server, its catalog, the gateway and the tool sources. |
| The agent rules | What a persona may do: its grants, approvals and the hard floor. |
| AI processing | The job queue, its routes, the result appliers and webhook delivery. |
| LLM | The model providers (openai, anthropic, gemini), prompt facets, canned chat, embeddings and catalog sync. |
| Shipr | Deployment: the ladder, the courier and the runner. |
| Sync | Syncing to devices: pull, push and enrollment. |
| Billing | Stripe: the gate, the webhook, offers and accounts. |
| Integrations | The connectors to outside services and the worker that syncs them. |
| OpenAPI | The builder behind the OpenAPI document. |
| The AI node | The AI node worker. |
| The MCP catalog script | Writes the MCP catalog the help site reads. |
| The sync catalog script | Writes the sync catalog. |
| The worker token tool | Mints an AI node worker token. |
Some work goes on in the background, in workers the backend starts at boot: the lease reaper, webhook delivery, the change-event relay, the announcements drain, the visitor-chat reaper, the retention sweeps, the project due sweep, the audience email scheduler, URL unfurling, the integration sync workers (switched on by INTEGRATION_SYNC_WORKERS_ENABLED) and the Shipr runner (switched on by SHIPR_RUNNER_ENABLED).