KatInterview

Real-Time Collaborative Text Editing System Design

System DesignModel answer
MediumModel answerSystem Designcollaborative-editingcrdtot

Last updated

Design a multi-user document editor with concurrent edits, convergence, offline reconnect, version history, permissions, and live presence.

You are asked to design a service that lets multiple people edit the same document simultaneously and watch each other's edits appear live. The interviewer wants an end-to-end design, not just an algorithm name.

Scope to nail down before designing

  • Document model: assume plain UTF-8 text with per-character or per-run styling added later as an extension. Say explicitly what you are deferring.
  • Concurrency semantics: two users type at (nearly) the same offset — what does everyone converge to?
  • Offline: a client goes dark for minutes, makes edits, then reconnects. Must those edits merge, and how?
  • Permissions: owner / editor / commenter / viewer, plus share links.
  • History: what can be viewed, restored, or audited, and for how long?
  • Presence: cursors, selections, "who's online" — is this durable or ephemeral?

What to produce

  1. Clarifying questions you would ask and the assumptions you would state.
  2. The core data model for a document and for a single edit operation.
  3. A convergence strategy (OT or CRDT), with a justification and its failure modes.
  4. The client–server synchronization protocol, including reconnection and offline replay.
  5. Snapshots, durable history, and recovery.
  6. Access control enforcement points.
  7. Presence handling as a separate, non-durable channel.
  8. Capacity estimates, bottlenecks, and what you would monitor.

Hints

Hint 1

Before choosing OT or CRDT, force the question of whether offline edits must merge — that single answer changes the whole architecture.

Hint 2

Model an edit as a small, invertible, causally-tagged operation against a known base version; then convergence becomes 'apply ops in a total order everyone agrees on'.

Hint 3

Keep presence on a separate websocket/pub-sub path with no durability; mixing cursor updates into the durable op log will dominate your write volume.