PremiumSeniorArchitect

Design a Collaborative Document Editor

System design for a collaborative editor like Google Docs: real-time sync (CRDTs vs OT), cursor presence, rich text (contentEditable vs ProseMirror/Tiptap), conflict resolution, offline, version history, comments, and permissions.

Frontend DigestFebruary 20, 20265 min read

Designing a collaborative document editor tests real-time sync, rich text editing, conflict resolution, and complex state. Here's a structured approach.

Requirements Clarification

Functional Requirements

  • Editing: Rich text (bold, italic, lists, headings); possibly images, tables.
  • Collaboration: Multiple cursors; see others' edits in real time; no overwrites.
  • Comments: Inline comments and suggestions; resolve, reply.
  • History: Version history; restore previous version.
  • Offline: Edit offline; sync when back online.
  • Permissions: View-only, comment-only, edit; per-user or per-document.

Non-Functional Requirements

  • Low latency for collaboration (<100ms typical).
  • Conflict-free merging; eventual consistency.
  • Accessibility: keyboard navigation, screen reader support for structure.
  • Scale to documents with 100k+ characters and 10+ concurrent users.

High-Level Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                     DocumentEditorRoot                                │
├─────────────────────────────────────────────────────────────────────┤
│  EditorCore (ProseMirror / Tiptap / Slate)                            │
│  - Document model (OT/CRDT)                                           │
│  - Local edits → transform → broadcast                                 │
├─────────────────────────────────────────────────────────────────────┤
│  CollaborationLayer                                                  │
│  - WebSocket: receive remote ops, merge, apply                         │

Continue reading Design a Collaborative Document Editor

Sign in or create a free account to read the rest of this article and all premium content.

Sign in to continue reading