Status: Accepted (2026-11-27, revised for ADRs 0020-0022)
Today everything is one Vite app in src/ with no backend. The product needs a browser client, a realtime tier, an API service, doc workers/compactor, an MCP adapter and a headless document model shared by several of them. Build agents work in parallel, so ownership must map to directories.
npm workspaces (npm 11 is installed; no extra tool):
apps/web/ Vite app: shell UI + panels + wiring (from src/main.ts, src/ui/, index.html, style.css)
apps/realtime/ WS gateway + room owners (Node 26 + uWebSockets.js, threads)
apps/api/ public REST API /v1 (stateless)
apps/docworker/ doc workers (queries, render) and compactor mode
apps/mcp/ MCP adapter over the public API (stdio + Streamable HTTP)
packages/doc/ headless document core + ScanBatch + StructIndex + JSON op helpers
packages/engine/ WebGL render engine (from scene.ts render half, renderer.ts, shaders.ts, font.ts, camera.ts, perf.ts)
packages/editor/ tools, commands, gestures, overlay (from editor.ts, history.ts, overlay.ts)
packages/sync-client/ realtime connection (DOM-free) + page replica session, undo stacks, presence
packages/server-common/ config, Postgres pool, token sign/verify, logging, metrics (server tiers only)
shared/ @linorahq/shared: contracts only (exists now)
db/migrations/ SQL migrations (0001_init.sql exists as the schema contract)
tools/ dependency check, OpenAPI/wire-spec generators, benchmark runner, load test
Packages export TypeScript source ("exports": "./src/index.ts"). Vite compiles it for the web; Node 26 strips types natively for servers, tools and tests. There is no library build step.
src/ and add top-level dirs: no home for shared code, no enforceable boundaries.Phase 0 moves files with git mv (no logic change) and installs every dependency once, so parallel packages never edit the lockfile. Until then, tsconfig.json paths + vite.config.ts alias make @linorahq/shared importable by the web app.