Status: Accepted (2026-11-27). Supersedes the process layout of 0009.
The realtime tier must never materialize full documents (ADR 0019), yet queries, MCP outlines, PNG render and compaction need them. Hand editing, 100k sockets and heavy reads must not compete for the same memory or event loop.
| Tier | Package | Runtime | State | Scales by |
|—|—|—|—|—|
| Edge LB | (infra) | managed LB / HAProxy | none | - |
| Realtime gateway + room owners | apps/realtime | Node 26 + uWS.js, threads (ADR 0020) | sockets, rooms, structural indexes, rings | file-id hash across instances |
| API service | apps/api | Node 26 node:http | none (DB + small caches) | stateless replicas |
| Doc workers | apps/docworker | Node 26 processes | LRU of materialized pages, hard memory cap | page-id hash across workers |
| Compactor | apps/docworker --mode=compactor | separate processes, one job at a time | one page while compacting | job queue |
| Postgres | - | managed or self-hosted | relational + journal + snapshot metadata | vertical, read replica |
| Blob store | S3-compatible or local disk | - | immutable snapshot + structure files | - |
| MCP | apps/mcp | Node 26, stdio or Streamable HTTP | per agent session only | stateless replicas |
How they talk
/v1/..., OpenAPI). Snapshots: binary, streamed from the blob store./v1/realtime?file=), LB-routed by file id.minSeq for read-your-writes.FOR UPDATE SKIP LOCKED, streams snapshot + journal, writes the new snapshot + structure section, exits or frees memory.NOTIFY linora_auth; realtime main threads LISTEN and close or downgrade affected sockets.page_ops and files.next_client_id; compactor writes snapshots; API writes everything relational.Single-box dev runs all tiers as separate npm run dev:* processes against Docker Postgres and a local blob directory. Production adds tiers independently.