KatInterview

Build a Real-Time Multi-User Document Editing Platform

System DesignModel answer
MediumModel answerSystem Designsystem-designcollaborationcrdt

Last updated

Design a platform where many people edit one document simultaneously, covering merge rules, live streaming, durable history, reconnect, and periodic Git checkpoints.

Build a Real-Time Multi-User Document Editing Platform

You are asked to design a service in which several people can edit the same document at the same moment, see each other's changes almost immediately, and keep working through brief network drops.

Walk through your design for the following areas:

  1. Client side: how the document is represented and tokenized, how local edits are turned into change records, how cursors and selections are handled, and how the UI applies edits optimistically.
  2. Server side: how changes are streamed between participants, how each accepted change gets a stable identity and a defined position in the history, and how session data is journaled.
  3. Merge behavior: what rule guarantees that two people typing in the same region end up with the same text, deterministically.
  4. Storage: compare saving full snapshots as blobs with keeping an append-only stream of changes. Explain what you would combine and why.
  5. Git integration: how the document's history relates to Git commits.

Assumptions

  • Multiple users may edit one document concurrently, and any of them may disconnect for a short while and come back.
  • Every accepted change must have a stable identity and either a global order or a deterministic merge rule.
  • Git commits act as durable milestones. They are not the low-latency channel that carries live edits.

Questions you should consider asking up front

  • Is the content plain text, rich text, or structured blocks?
  • Does editing need to work fully offline?
  • What conflict and consistency behavior do users expect to see?

State your assumptions about these, then give a design with its trade-offs.

Hints

Hint 1

Pick one merge approach (central ordering with transformation, or a replicated data type with unique element IDs) and be explicit about how it makes concurrent edits converge to identical text.

Hint 2

Think of the durable state as two layers: an append-only journal of acknowledged changes that is the source of truth, plus periodic snapshots that bound how much of the journal must be replayed on load or reconnect.

Hint 3

Reconnect should be driven by sequence numbers: the client reports the last sequence it saw plus any unacknowledged local changes, and the server replies with either the missing tail of the journal or a recent snapshot plus the tail. Git commits should be cut from snapshots at milestones, not per keystroke.