Collaborative Document Repository
Problem Statement
Design the Low-Level Design (LLD) for a Collaborative Document Repository, similar to Google Docs, Confluence, or Notion, where users can create, edit, share, and collaborate on documents in real-time.
The system should support versioning, concurrent edits, access control, and searchability of documents, while ensuring data consistency and collaboration-friendly architecture.
🎯 Core Requirements
1. Document Management
2. Collaboration
3. Access Control
4. Versioning & History
5. Search
6. Optional Enhancements
⚙️ Functional APIs
OperationDescription
createDocument(userId, title, content)
Creates a new document and assigns ownership.
editDocument(documentId, userId, changes)
Edits document if user has permission.
getDocument(documentId, userId)
Retrieves the latest version of the document.
shareDocument(documentId, targetUserId, permission)
Grants access to another user.
listDocuments(userId)
Lists all documents owned or shared with user.
getVersionHistory(documentId)
Fetches all previous versions of a document.
restoreVersion(documentId, versionId)
Restores content to a specific version.
🧱 Suggested Class Design
ClassResponsibility
Document
Represents a document with metadata, current content, and versions.
DocumentVersion
Stores versioned content with timestamp and author.
User
Represents a system user with name, email, and role.
Permission
Defines access levels (read/write/comment).
CollaborationSession
Manages real-time edits for concurrent users.
DocumentRepository
Handles storage, retrieval, and version persistence.
VersionManager
Manages version creation, retrieval, and rollback.
AccessControlManager
Manages document sharing and permission validation.
SearchService
Provides text and metadata search capabilities.
🧩 Example Entity
Document
1
2documentId: "doc-1234"
3title: "Project Plan"
4ownerId: "user-001"
5content: "Initial content..."
6createdAt: 2025-10-24
7lastModifiedAt: 2025-10-24
8versions: [v1, v2, v3]
9permissions: {
10 "user-002": WRITE,
11 "user-003": READ
12}DocumentVersion
1
2versionId: v2
3content: "Updated project plan with new timeline"
4modifiedBy: "user-002"
5timestamp: 2025-10-24T14:10:00Z🧠 Design Considerations
Concurrency Management:
Versioning:
Permissions:
Scalability:
🔄 Example Flow
1. Document Creation
1
2User A → createDocument("Project Plan")
3System → Creates Document (doc-1234) with A as owner2. Collaboration
1
2User A shares with User B (WRITE access)
3Both edit doc-1234 concurrently
4System merges changes and updates version history3. Versioning
1
2User B saves changes → New version (v3) created
3User A restores version v2 if needed4. Access Control
1
2User C (no permission) tries to access doc-1234 → Access Denied🧱 Sample Class Diagram (Conceptual)
1
2+--------------------+
3| Document |
4+--------------------+
5| documentId |
6| title |
7| content |
8| ownerId |
9| versions[] |
10| permissions{} |
11+--------------------+
12
13+--------------------+
14| DocumentVersion |
15+--------------------+
16| versionId |
17| content |
18| modifiedBy |
19| timestamp |
20+--------------------+
21
22+--------------------+
23| AccessControlMgr |
24+--------------------+
25| +grantAccess() |
26| +validateAccess() |
27+--------------------+
28
29+--------------------+
30| VersionManager |
31+--------------------+
32| +saveVersion() |
33| +restoreVersion() |
34+--------------------+
35
36+--------------------+
37| CollaborationSession|
38+--------------------+
39| +handleEditEvents()|
40| +broadcastChanges()|
41+--------------------+🚀 Possible Extensions
✅ Goal:
Design an extensible, object-oriented Collaborative Document Repository that supports multi-user editing, versioning, permissions, and real-time collaboration — with a focus on modularity, scalability, and consistency.