Appearance
Architecture overview
Orbit is a modular monolith: one Rust binary, orbit, holds a small kernel and every module compiled into it. Postgres is the only required dependency. The web app (React) and a Better Auth sidecar (TypeScript) complete the stack.
In depth
This page is the short version. Architecture in depth covers the kernel, bus, events, jobs, database roles and row-level security in detail.
The pieces
| Piece | Where | Does |
|---|---|---|
orbit binary | crates/orbit-bin | Runs the roles below and the operator commands |
| Kernel | crates/kernel | Module registry, command and query bus, tenancy, Ctx, ID newtypes |
| Authorisation | crates/authz | Cedar schema, policies and entity loaders |
| Events and jobs | crates/events, crates/jobs | Transactional outbox, relay, apalis jobs, cron |
| Personal data and files | crates/pii, crates/storage | Field encryption, encrypted file storage |
| Doors | crates/api-graphql, crates/api-mcp, crates/api-scim, crates/cli | GraphQL, MCP, SCIM and the CLI |
| Modules | modules/<id> | One business area each: schema, handlers, policies, manifest |
| Auth sidecar | services/auth | Sign-in, organisations, invitations, SSO, JWTs |
| Web app | web/ | Admin web and the employee self-service app |
Process roles
One image, one binary. The flag picks what a process runs.
| Command | Runs |
|---|---|
orbit migrate | Every migration, then exits. The only process with the owner login |
orbit --role web | HTTP: the web app, these docs at /docs, /graphql, /mcp, /scim/v2, /files, and the /api/auth proxy to the sidecar |
orbit --role worker | The event relay and the job worker |
orbit --role scheduler | Cron schedules that enqueue jobs |
orbit --role all | All three serving roles, for development |
Each serving process refuses credentials it must not hold (the owner URL, and the worker or doors URL when it doesn't run that role) and checks that no login is a superuser.
Postgres and database roles
- One schema per module (
leave.*,payroll.*). A module never reads another's tables; it uses the other module's queries and events. - Tenant scoping twice: every statement filters by
tenant_id, and forced row-level security hides other tenants' rows as a second safety net. - Least-privilege logins: the owner (migrations only), the runtime role (handlers), the worker role (relay, jobs, scheduler) and the doors role (identity functions only). Each module also gets its own database role with grants on its own schema only (ADR 0005).
A request, end to end
- A door (GraphQL, MCP, CLI or SCIM) authenticates the caller and turns the request into a bus call. Doors hold no business logic.
- The bus opens a transaction scoped to the tenant and asks Cedar whether the actor may attempt the action.
- It checks the module is enabled for the tenant, then runs the handler.
- The handler checks the specific record with Cedar (
ctx.authorize), changes state and emits events into the outbox, all in the same transaction. - For a command, the bus writes the audit entry in that transaction and commits. Denied attempts are audited too.
Events and jobs
The relay publishes committed outbox rows in order, per tenant, at least once; handlers are idempotent. Failing subscribers retry with backoff, then dead-letter. Events for a disabled module are held and replayed when it is enabled again. Jobs run per tenant, only where their module is enabled.
Rules that never bend
- Every action goes through the bus and Cedar. No "internal" shortcuts.
- Money is never a float:
rust_decimal::Decimalin Rust, decimal strings in the API. - History is immutable: locked payroll runs, signed acknowledgements and audit entries are never updated. Corrections are new records.
- Agents may draft and recommend. Approving, locking payroll and changing pay need a person, or an explicit confirmation for tools marked sensitive.