Design a Bookmark Management System
Problem Statement
π― Objective
Design a system that allows users to save, organize, and manage bookmarks for web pages, documents, or resources efficiently.
The system should support creating, updating, deleting, searching, and categorizing bookmarks while maintaining a good user experience and extensibility.
πΉ Context
Users often want to save links to articles, videos, or websites they find useful and retrieve them later.
You are tasked with designing a Bookmark Management System (like Pocket, Raindrop.io, or Chrome Bookmarks) with object-oriented principles and a scalable structure.
β Functional Requirements
Bookmark Operations
Folder & Tag Organization
User Management
Sync & Persistence (Optional)
Optional Features (if time allows)
βοΈ Non-Functional Requirements
RequirementDescription
Performance
Must handle quick search and retrieval.
Extensibility
Easy to add new features (e.g., sharing, syncing).
Scalability
Should handle thousands of bookmarks per user.
Reliability
Should not lose data (persistence).
Thread Safety
If concurrent access (e.g., multiple devices).
π§© Core Entities & Responsibilities
ClassDescription
User
Represents a user of the system; owns multiple folders and bookmarks.
Bookmark
Represents a saved item with attributes (URL, title, tags, favorite).
Folder
Allows hierarchical organization of bookmarks.
Tag
Used for quick categorization.
BookmarkManager
Core service to manage bookmarks β add, remove, edit, search.
SearchService
Handles bookmark search and filtering logic.
PersistenceService
Saves and loads bookmark data from storage.
π§Ύ Sample Class Diagram (Text Representation)
1
2ββββββββββββββββββββββββββββββββ
3β User β
4ββββββββββββββββββββββββββββββββ
5β - userId β
6β - name β
7β - rootFolder: Folder β
8ββββββββββββββββββββββββββββββββ
9β + addBookmark(b: Bookmark) β
10β + searchBookmarks(query) β
11ββββββββββββββββ¬ββββββββββββββββ
12 β
13 βΌ
14ββββββββββββββββββββββββββββββββ
15β Folder β
16ββββββββββββββββββββββββββββββββ
17β - name β
18β - bookmarks: List<Bookmark> β
19β - subFolders: List<Folder> β
20ββββββββββββββββββββββββββββββββ
21β + addBookmark(b) β
22β + addFolder(f) β
23β + getBookmarks() β
24ββββββββββββββββββββββββββββββββ
25
26ββββββββββββββββββββββββββββββββ
27β Bookmark β
28ββββββββββββββββββββββββββββββββ
29β - id β
30β - title β
31β - url β
32β - tags: List<Tag> β
33β - isFavorite: bool β
34β - createdAt β
35ββββββββββββββββββββββββββββββββ
36
37ββββββββββββββββββββββββββββββββ
38β Tag β
39ββββββββββββββββββββββββββββββββ
40β - name β
41ββββββββββββββββββββββββββββββββ
42
43ββββββββββββββββββββββββββββββββ
44β BookmarkManager β
45ββββββββββββββββββββββββββββββββ
46β + addBookmark(user, b) β
47β + deleteBookmark(user, id) β
48β + search(user, query) β
49β + organizeByTag(user, tag) β
50βββββββββββββββββββββββββββββββββοΈ Sample Workflow
π§ Design Considerations
Data Structures:
Patterns Used:
Composite
Singleton
DAO/Repository
Observer (optional)
π§© Example Function Signatures (Pseudocode)
1
2class Bookmark:
3 def __init__(self, id, title, url, tags=None, favorite=False):
4 self.id = id
5 self.title = title
6 self.url = url
7 self.tags = tags or []
8 self.favorite = favorite
9
10class Folder:
11 def __init__(self, name):
12 self.name = name
13 self.bookmarks = []
14 self.subfolders = []
15
16 def add_bookmark(self, bookmark):
17 self.bookmarks.append(bookmark)
18
19class BookmarkManager:
20 def __init__(self):
21 self.users = {}
22
23 def add_bookmark(self, user_id, folder_name, bookmark):
24 user = self.users[user_id]
25 folder = user.getFolder(folder_name)
26 folder.add_bookmark(bookmark)
27
28 def search_bookmarks(self, user_id, query):
29 # Search by title or tags
30 ...π¬ Example Interview Prompt Summary
Design a Bookmark Management System.
Users should be able to save, organize, and search bookmarks under folders or tags.
Discuss your class design, relationships, and how youβd ensure scalability, extensibility, and persistence.
π Possible Extensions