Collaborative document editor
Google-Docs-style co-editing: sequence CRDTs merge concurrent keystrokes, an op-log is the source of truth, and snapshots keep join time flat.
What this design does
Two people typing in the same paragraph with no locks and no lost keystrokes — the trick is a sequence CRDT, which makes every insert commutative so replicas converge regardless of arrival order. The op-log is the durable truth; periodic snapshots keep 'open document' from meaning 'replay a year of keystrokes'. The same shape powers Notion, Linear and our own live collab.
The patterns it composes
- Sequence CRDT (RGA/LSEQ) — concurrent inserts commute — replicas converge without coordination
- Op-log replication / sync protocol — clients exchange operations since a version vector, not documents
- Log-as-source-of-truth + snapshot compaction — the log is authority; snapshots bound replay time
- WebSocket connection registry — the gateway knows which sockets watch which document
- Presence — cursors and who's-here ride the same session, ephemeral by design
Import it, attach your own numbers, and verify the design against failures — or read the engineering notes.