"Design Google Docs" and "design a shared whiteboard" are popular senior-level questions. The hard part is not storage or WebSockets; it's what happens when two people edit the same thing at the same time while one of them is offline. The two standard answers are Operational Transformation (OT) and CRDTs. This page covers the CRDT side well enough to discuss it confidently.
A Conflict-free Replicated Data Type is a data structure whose replicas can be updated independently, without coordination, and are guaranteed to converge to the same state once they have seen the same set of updates, regardless of the order in which updates arrive. That property is called strong eventual consistency.
For a document, every character gets a globally unique, ordered identifier (RGA, Logoot, YATA as used by Yjs, or the approach in Automerge). Inserting between two characters creates an identifier that sorts between theirs; deleting leaves a tombstone so concurrent inserts that reference it still have a position. Because positions are identifiers rather than integer indexes, concurrent edits never need to be transformed against each other.
| OT | CRDT | |
|---|---|---|
| Needs a central server to order ops | Typically yes | No (peer-to-peer and offline friendly) |
| Metadata overhead | Low | Higher (IDs, tombstones), needs compaction |
| Correctness proofs | Notoriously tricky | Follow from merge properties |
| Real-world use | Google Docs | Figma-style multiplayer (CRDT-inspired), Yjs, Automerge, Redis Enterprise active-active |
Clients apply edits locally for zero-latency typing and send updates to a sync service over WebSockets. The service relays updates to other clients in the same document, appends them to a durable log, and periodically writes compacted snapshots so new clients don't replay the full history. Presence data (cursors, selections) is ephemeral and doesn't need CRDT guarantees. Mention tombstone garbage collection once all replicas have acknowledged a version.
"I'd use a sequence CRDT so that clients can edit offline and merge without a central lock, accept the metadata overhead, and control it with snapshots and tombstone compaction."
If you want to rehearse explaining designs like this under time pressure, linkjob.ai is the AI interview assistant my team builds. Disclosure: I work on it.
Further reading: Shapiro et al., "Conflict-free Replicated Data Types" (2011); Martin Kleppmann's talks on CRDTs and local-first software.