System design
Three containers, one server process hosting nine modules, and one Postgres database with a schema per module.
Workspace runs as three containers: Caddy for HTTPS, one app container (a Next.js web app and one Node 22 server hosting every module) and PostgreSQL. No message broker, no cache server. One installation holds one company; it scales up on a bigger server, not out to more containers.
Modules
The backend is one process (backend/server). Each module owns a folder, a Postgres schema, a login role, its
migrations and an HTTP API. A lint rule refuses imports between modules; they call each other's API in memory or
react to events. The web app (frontend/web, Next.js 15) is the BFF in front of the gateway.
| Module | Owns |
|---|---|
| gateway | Verifies sessions and API keys, rate limits, routes /api/<module>/*; MCP and the extension intake |
| identity | Sign-in (passwords, tokens, two-step), members, roles, teams, API keys, audit |
| platform | The workspace, first-run setup, master data, outbound webhooks |
| chat | Channels, DMs, threads, files, calls; Socket.IO realtime and live co-editing |
| work | Projects, tasks, documents, drive, calendar and meetings, approvals, goals, outcomes |
| home | The "Needs you" feed, notifications, reminders, daily digest, Web Push |
| employee | Profiles, departments and reporting lines, attendance, leave, announcements |
| ai | Model gateway, assistant, usage and budgets, AI Insights intake, policy and retention |
| search | Full-text index in Postgres, rebuilt from events |
State changes other modules care about are written to an outbox in the same transaction and delivered in process, at least once, to every consumer. A failed event retries, then waits in a dead-letter table for a replay. Files go to local disk or S3 through signed URLs; search is a Postgres full-text index that can be rebuilt from the modules' own data.
Five rules behind every change
- No module reads another module's schema. Its Postgres role cannot. Data moves through module APIs (in memory) or events.
- One workspace. No workspace column, row-level security or workspace id anywhere; a second company is a second installation.
- Authorization is
authorize(principal, permission, resource)in the owning module, for people, API keys and AI agents alike. - State changes others care about go through the outbox, in the same transaction.
- Nothing may require AI. Generative endpoints answer
503 ai_not_configuredand the UI hides them.
Why it is built this way
Each decision is an architecture decision record in docs/adr, never rewritten: a changed decision gets a new record that supersedes the old one. Three explain most of what you see here:
- 0020: the AI Insights principles (consent, self-view, no surveillance, audited full text, data stays on the server, off by default).
- 0021: one server process for every module, one app container behind Caddy.
- 0023: one workspace in the data model, no workspace column or row-level security.
Full reference
In the repository: system design (goals, containers, each module's endpoints and topics, realtime, search, files, meetings, failure modes, testing), database (schemas, roles, migrations, one page per module) and events (outbox, relay, consumer groups, the catalog of every event).
Contributor guide
Everything a developer needs to change Workspace with confidence, from the system's shape down to the tables and the first pull request.
Request path, security and AI gateway
How a request reaches a module, how people sign in and how access is checked, and how AI calls and AI Insights data flow.