KatInterview

Design a Live Multi-User Document Editor

System DesignModel answer
MediumModel answerSystem Designcollaborative editingoperational transformationCRDTs

Last updated

Design the client and server for a collaborative text editor where multiple users edit the same document simultaneously and see each other's changes in near real time.

Live Multi-User Document Editor

You are building a web-based document editor where several people can open the same file, type at the same time, and watch each other's changes appear within a second or two — think Google Docs in spirit.

The interview targets a frontend engineer, so your answer should cover both sides of the system: the client (how it models the document, handles local edits, and applies incoming changes from others) and the server (how it coordinates those edits and keeps everyone consistent).

What you need to address

  • How the document is represented and how edits are modelled
  • How a user's own keystrokes appear immediately without waiting for the server
  • How two users editing the same spot at the same time are resolved so no edit is lost and all clients end up with identical text
  • The sync protocol between client and server: transport choice, message ordering, acknowledgement, and reconnection
  • Server responsibilities: authority over ordering, storage, and scaling across many active documents
  • Presence indicators: live cursors, selections, or an active-users list

Constraints

  • No edit from any connected user may be silently discarded; once editing stops, every client must hold the same document.
  • Local edits must feel instant — no round-trip latency visible to the typist.

Good clarifying questions to raise

Before diving in, consider asking:

  • Plain text only, or does formatting (bold, lists, embedded images) need to be supported?
  • How many concurrent editors per document, and how many documents are live at once?
  • Is offline editing with eventual merge-on-reconnect in scope?
  • Which presence features are required?
  • Is version history or point-in-time restore needed?
  • What permission model applies (view / comment / edit)?

Hints

Hint 1

Start by choosing a conflict-resolution strategy — Operational Transformation (OT) or CRDTs — and be ready to walk through a concrete example of two users inserting text at the same position at the same time.

Hint 2

Think in three distinct client-side buckets: the committed document state, a queue of locally applied but unacknowledged operations, and incoming remote operations that need to be rebased against that queue before being applied.

Hint 3

Cursors are positions in the document, so any operation that inserts or deletes text before a cursor must shift that cursor's index — remote cursor updates need the same transformation logic as text operations.