Design a Collaborative Document Editor
Design a Docs- and canvas-like collaborative editor with convergent text and visual-object editing, anchored annotations, history, presence, and permissions.
Problem statement
For this exercise, assume one collaborative workspace item may contain rich-text document content and structured visual objects such as images, frames, and annotations.
Multiple authorized users edit text and visual-object transforms in real time, see presence and cursors, converge after concurrent operations, and retrieve version history from snapshots plus deltas.
Users also create threaded comments anchored to a text range, visual object, or normalized visual position; deleting an anchor target leaves the thread readable as orphaned.
Discuss OT versus CRDT or another convergent operation model, low-latency connection handling, item-ID partitioning, regional replication, comment revisions, and access control. Exclude raw pixel manipulation, media transcoding, reactions, attachments, search, and notification delivery.
The reported load-balancing scenario includes millions of users editing millions of documents simultaneously, with multiple users able to edit the same document. Use the labeled practice values for a concrete peak-capacity estimate; daily users and stored documents do not determine this concurrent work.
What to build
- Authorized users can create, open, and edit a document.
- Multiple users can edit document text and structured visual objects concurrently and converge on the same content and geometry.
- Authorized collaborators can create, reply to, edit, resolve, and reopen threaded comments anchored to text ranges, visual objects, or normalized visual positions.
- Collaborators can see current participant presence and cursor positions.
- Users can inspect and restore document history represented by snapshots and deltas.
- Owners can grant and revoke viewer or editor access to a document.
At scale
- Source fact: the design must support real-time collaborative editing and low-latency synchronization.
- Source fact: the design discussion includes delta history, snapshot plus diff retrieval, document-ID sharding, and regional replication.
- Practice assumption: 10 million daily active users, 100 million stored documents, and up to 100 active editors on one document. At peak, assume 3 million simultaneous users across 2 million actively edited documents, with one active editor session per user for capacity estimates; these exact peak values are practice assumptions.
- Practice assumption: accepted edits should be visible to connected collaborators within 200 ms at p95 and survive reconnects.
- Practice assumption: start with one authoritative editing region per active document while serving read-only access from regional replicas.