Design Google Docs (Collaborative Document Editor)
Problem Statement
Design the Low-Level Design (LLD) for a simplified version of Google Docs, a real-time collaborative document editing system.
The system should allow multiple users to view and edit the same document simultaneously, with changes being reflected in real time. The design should focus on document representation, user sessions, version control, and concurrency handling, rather than network or UI implementation.
🎯 Core Requirements
1. Document Management
2. Real-Time Collaboration
3. Version Control
4. User Sessions & Permissions
5. Change Tracking
⚙️ Key Operations (APIs)
APIDescription
createDocument(User user, String title)
Creates a new document.
openDocument(String docId, User user)
Opens a document for viewing/editing.
editDocument(String docId, User user, EditOperation edit)
Applies an edit (insert, delete, replace).
getDocumentContent(String docId)
Retrieves current content.
getEditHistory(String docId)
Returns version/change history.
addCollaborator(String docId, User user, Role role)
Grants access to other users.
🧱 Suggested Class Design
ClassResponsibility
Document
Represents a text document with content, metadata, and edit history.
User
Represents a system user with name, ID, and permissions.
Session
Represents an active editing/viewing session by a user.
EditOperation
Represents an atomic change (insert, delete, replace) with metadata.
CollaborationManager
Coordinates real-time edits across sessions.
VersionManager
Handles document versions, undo/redo.
PermissionManager
Controls access (view/edit/share).
ChangeNotifier
Sends updates to all connected clients/sessions.
🔄 Example Flow
Example:
🧠 Design Considerations
1. Concurrency Handling
2. Synchronization
3. Scalability
4. Persistence
🚀 Possible Extensions
🧩 Example Entities
Document
1
2id: "doc123"
3title: "System Design Notes"
4content: "Google Docs LLD"
5createdBy: "Sahil"
6collaborators: [UserA(Owner), UserB(Editor)]
7versions: [v1, v2, ...]EditOperation
1
2operationType: INSERT
3position: 5
4text: "World"
5user: UserB
6timestamp: 2025-10-24T13:00✅ Goal:
Design the classes, interactions, and core logic to support real-time collaborative editing, version management, and access control for a Google Docs–like application.