
🧩 System Design Prompt #3: Design a Collaborative Document Editing Platform (like Confluence)
🎯 Prompt:
Design a simplified version of Confluence where multiple users can:
- Create and edit documents (rich text)
- Collaborate in real time (see each other’s edits)
- Comment on sections of the document
- Version history and rollback
- Access control (read-only, edit, admin)
The system should support teams with thousands of users and large documents.
✅ What You’re Being Tested On:
- Real-time collaboration and concurrency
- Rich document storage and versioning
- Access control and permission systems
- Scalability under team-based usage
- Syncing updates across clients
🧠 What You Should Cover:
1. Clarify the Requirements
Ask things like:
- Do we need Google Docs–level real-time editing?
- How big can documents be?
- Should edits be autosaved? If so, how frequently?
- What types of roles or permissions are needed?
2. Core Features
- Create/edit documents (markdown or rich-text)
- Real-time updates via WebSocket or polling
- Comments on text blocks
- Version control (auto-save history)
- Permissions: owner, editor, commenter, viewer
3. System Components
📎 Frontend Client
- Rich text editor with WebSocket client
- Autosave logic and sync with server
⚙️ Backend Services
- Document Service: create, update, store documents
- Collaboration Service: manages live editing sessions (WebSockets)
- Comment Service: attach comments to paragraphs or ranges
- Versioning Service: saves historical snapshots
- Permission Service: handles access roles
4. Data Model
documents
document_id UUID PRIMARY KEY
title TEXT
owner_id UUID
content JSONB (structured blocks)
created_at, updated_at
document_versions
version_id UUID
document_id UUID
content JSONB
created_at
created_by
comments
comment_id UUID
document_id UUID
text TEXT
range_start, range_end (or block reference)
created_by, created_at
permissions
document_id UUID
user_id UUID
role ENUM('owner', 'editor', 'commenter', 'viewer')
5. Real-Time Collaboration (CRDT / OT)
To handle multiple users editing the same doc at once:
- Use CRDT (Conflict-Free Replicated Data Types) or Operational Transformation (OT).
- CRDTs are more modern and peer-friendly.
- Use WebSockets to:
- Broadcast operations (insert/delete/change) to other collaborators
- Maintain in-memory “editing sessions” per document
- Sync changes every few seconds to a durable store.
6. Versioning and Rollbacks
- Save a version every X minutes or on significant changes.
- Store diffs or snapshots (tradeoff: space vs speed).
- Allow users to view and restore previous versions.
7. Access Control
- Enforced at the API and database level.
- Use middleware or permission service to check role on each request.
- Owners can share or revoke access.
8. Scalability Considerations
- Session Store: Use Redis or in-memory cache for tracking who’s collaborating on what
- WebSocket Scaling: Use a pub/sub layer (e.g., Redis Streams or Kafka) for syncing across nodes
- CDN for static assets
- Document partitioning/sharding if the data set becomes large
- Limit document edit concurrency if needed
9. Advanced Features (Nice to Have)
- Inline commenting (like Google Docs)
- Offline editing + sync
- Email/webhook notifications for doc activity
- Document templates
- Analytics: page views, top editors