Practice Hub /
Real-Time & CollaborationHard~45 min interview roundNotionFigmaAtlassian

Real-Time Collaborative Document Editor (Google Docs / Notion)

Design a multi-cursor rich-text editor with local-first edits, CRDT/OT conflict resolution, offline syncing, and smooth presence cursors.

1. Interactive System Architecture Diagram

Click any architecture component below to inspect its exact responsibilities and trace connected data flows.

Keystroke Op Persist Delta WS Binary Sync Initial Doc Editor Surface ContentEditable + Cursors Sync Engine CRDT / Yjs Graph IndexedDB Vault Offline Ops Log WebSocket Sync Hub Doc Room Broadcast Initial Doc Snapshot SSR / REST Bootstrap
Selected ComponentEditor Surface — ContentEditable + Cursors
  • Maintains custom document tree (`ProseMirror` / `Lexical`) rather than raw untyped DOM.
  • Translates remote cursor indices into non-blocking GPU-composited caret overlays.
  • Exposes undo/redo scoped strictly to local user operations (never undoes teammate edits!).

2. Interactive Trade-Off Simulator

Toggle between real architectural options to compare Pros, Cons, and exactly when to pick each choice in interviews.

Concurrency Model

How should simultaneous character edits by 10 users be merged?

Pros

  • Mathematically guarantees eventual consistency even after offline editing and out-of-order delivery.
  • Zero dependency on a single central serializer for local edits.

Cons & Pitfalls

  • Stores extra tombstone metadata for deleted characters unless garbage-collected.
Interview Rule of Thumb: Pick CRDTs when offline-first editing, Notion/Figma blocks, or multi-region sync matter.
Real-Time Transport

Which network transport carries bidirectional keystrokes & cursor presence?

Pros

  • True full-duplex low-latency pipe for sending local ops and receiving peer deltas + cursors.
  • Binary Uint8Array frames avoid JSON parse/stringify overhead per keystroke.

Cons & Pitfalls

  • Requires stateful socket servers & sticky load balancing or Redis pub/sub.
Interview Rule of Thumb: Pick WebSockets for bidirectional collaborative editing and presence.

3. RADIO Framework Breakdown & Interview Checklist

Review each RADIO pillar cleanly and check off sections as you master them.

0 / 5 Sections Reviewed
R

Requirements & Scope

  • Functional: Rich-text blocks, concurrent multi-user typing, remote named cursors, local undo/redo, offline draft.
  • Non-Functional: < 16ms local keystroke render, < 150ms peer propagation, zero lost characters offline.
A

Architecture Components

  • Rich-text DOM abstraction -> CRDT State Engine -> IndexedDB Offline Queue -> WebSocket Relay.
  • Awareness/Cursor channel decoupled from persistent CRDT mutation history.
D

Client Data Model

  • `DocBlock: { id: string, type: "paragraph"|"heading"|"code", crdtXmlText }`
  • `AwarenessUser: { clientId, name, color, anchorPos, headPos }`
I

Interface & API Contracts

  • `GET /api/v1/docs/:id/snapshot` -> loads latest compacted doc bytes cleanly.
  • `WSS /sync/:docId` -> exchanges sync-step1 (state vector), sync-step2 (diff), & awareness frames.
O

Performance & Optimizations

  • Batch rapid keystrokes over 50ms micro-windows before emitting WebSocket packets.
  • Throttle outgoing cursor awareness events (`requestAnimationFrame` / 60ms) cleanly.
  • Virtualize long 50-page documents by block chunks so browser only lays out visible blocks.