0006. Pages are the unit of sync, storage and loading
Status: Accepted (2026-11-27)
Context
Files hold several pages; a page can be huge (682K+ layers). Users look at one page at a time.
Decision
- Each page is an independent document: its own root node, seq counter, snapshots and journal, its own server room.
- A file’s page list (name, order) is relational data edited over REST, broadcast as
file_event on the file’s WS connections.
- The client loads only the open page:
GET /api/pages/:id/snapshot (gzip, decoded in a Web Worker) then WS subscribe with sinceSeq. Switching pages drops the old page doc (optionally keep one warm page if memory allows).
- One WS connection per (client, file), multiplexing page subscriptions by a server-assigned room number (same for every subscriber of a page, so broadcasts are encoded once).
- Moving nodes between pages = create on target + delete on source (new ids), like Figma.
- Top-level frames inside a page are the “screens”.
Alternatives
- Whole file as one document: loads every page, one seq for all edits, huge snapshots.
- Per-frame documents: cross-frame moves become cross-document transactions.
Consequences
No cross-page atomicity (not needed). The realtime tier keeps a small room per page that has subscribers (~2 KB + 64 B/peer + a bounded catch-up ring) and a structural index only while the page is being edited (ADR 0019); idle rooms are evicted. Doc workers materialize only pages that are queried.