Collaborative Document Editor
A local-first editor with a hand-rolled sync engine — built to find out what real-time collaboration actually costs. It is live, and you can open it.
- ARCHITECTURE
- CRDT-based conflict resolution · Hand-written push/pull sync engine · Restore-as-diff version control
- CONSTRAINT
- Offline-first operation with deterministic state convergence upon reconnection
- TRADEOFF
- CRDT data-structure convergence over OT model complexity · Restore-as-diff over snapshot overwrite simplicity
- STACK & SCOPE
- Vitest · CIOffline-capable synchronization engine · State convergence testing · Owner/Editor/Viewer role model
- STATE
- LIVE
- MODEL
- CRDT
- OFFLINE
- YES
- ROLES
- 3
Open it — it is running, and it works with the network off.
The problem
Two people editing one document is easy until one of them goes offline, keeps typing, and comes back. Everything interesting about collaborative editing is in that reconnection.
I wanted to understand it rather than install it, so the sync engine is mine.
The decisions
Conflict resolution runs on a CRDTREJECTEDOperational transformationWHYOT needs a central server to order operations, which means offline edits have nowhere to live until you reconnect. A CRDT converges without asking permission, which is the whole feature. rather than a transform-based model, which is what makes offline editing a property of the data structure instead of a feature I have to defend.
I wrote a push/pull sync engine by handREJECTEDAn off-the-shelf sync providerWHYThe provider would have worked. It would also have meant the one genuinely hard part of this project was the part I didn't build, which defeats the point of building it., with a Vitest suite that asserts convergence rather than asserting that the UI looks right.
Version history restores as a diff rather than as a snapshot, so recovering an old version is an edit the other collaborators receive normally — not a write that silently discards whatever they did in the meantime.
The outcome
Deterministic merges, offline editing, restore-as-diff, and Owner / Editor / Viewer roles. Deployed with CI. It is the project on this site you can actually use, which is why it is here rather than in the list below.