Design a Document Management System

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2024-08-12

Problem Statement

Design the low-level architecture for a Document Management System (DMS) that allows users to create, edit, store, retrieve, and organize documents. The system should support versioning, search, and access control.


🔷 Functional Requirements:

1.Create Document:
•Users can create a document with a title, content, and metadata (e.g., tags, author, category).
2.Edit Document:
•Users can edit a document; each edit creates a new version.
•The system should maintain version history and allow reverting to any previous version.
3.Retrieve Document:
•Retrieve the latest version or a specific version of a document by ID.
4.Delete Document:
•Allow soft delete (mark as deleted); deleted documents can be restored.
5.Search Documents:
•Search documents by title, tags, content keywords, or author.
6.Folder/Category Structure:
•Support organizing documents in folders or categories.
7.Access Control (Optional):
•Allow assigning read/write/delete permissions per user or role.


🔷 Constraints & Assumptions:

•Document content is plain text or markdown (no rich formatting).
•No file upload required; just simulate using strings.
•Versioning must be retained for each document.
•Assume in-memory storage (e.g., lists/maps) — no persistence needed.
•Ignore authentication, but support a User class to simulate permissions if required.


🔶 Expected Design Focus:

•Key classes: Document, Version, User, Folder, DocumentManager, SearchService
•Use composition for versioning (Document → List<Version>)
•Use interfaces/abstractions for Search and AccessControl
•Ensure OOP principles (e.g., SRP, OCP, encapsulation)


🔷 Bonus Features (Optional):

•Add tagging system with hierarchical or faceted tags.
•Add sharing (generate public/private links).
•Track last opened/accessed time for each document.
•Add commenting or collaborative editing hooks.


✅ Sample Use Case:

1plaintext 2CopyEdit 31. User A creates a document titled "Design Notes". 42. A edits the document 3 times → 3 versions are saved. 53. A retrieves version 2 to compare changes. 64. A deletes the document → marked as soft deleted. 75. A restores the document from trash. 86. User B searches for "Design" and sees the restored document.


Solution

Comments