What is a CRDT?
A Conflict-free Replicated Data Type is a data structure that can be independently modified on multiple replicas and still converge to the same state when all updates are exchanged — without central coordination or operational transforms.
RGA (Replicated Growable Array)
For text editing we model the buffer as a sequence of characters. Each character is given a unique identifier (often a Lamport timestamp + node ID). Insertion inserts a new identifier between two existing ones; deletion marks an identifier as tomb-stoned. Because identifiers are totally ordered, merging two replicas' update logs deterministically reconstructs the same sequence.
Demo Mechanics
- Four panes represent four independent peers.
- Typing feeds insert operations into the local peer's buffer.
- Messages are broadcast with a simulated random latency (200 – 800 ms) to mimic a network.
- The Pause Network button toggles propagation so you can create divergent states then watch them merge.
Why Local-First?
Unlike traditional client–server collaboration, CRDTs enable local-first
apps: edits are instant (no round-trip), available offline, and merge automatically once connectivity returns.
Further Resources
- Local-first software manifesto
- crdt.tech — academic papers and implementations
- Original inspiration by Evan Wallace's rope-based editor