Design Dropbox Client Application
Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2021-06-12
Problem Statement
Designing a Dropbox-like client application that allows users to upload, download, sync, and manage files between their local device and cloud storage. Focus is on object-oriented design, modular components, and data synchronization logic.
✅ Functional Requirements
1.File Management
•Upload and download files to/from cloud storage.
•Create, rename, delete, and move files/folders locally and in the cloud.
•Maintain file metadata (name, size, last modified, checksum).
2.Synchronization
•Detect changes in local files and sync with the cloud.
•Detect changes in cloud files and update local copy.
•Handle conflict resolution (e.g., if a file is edited locally and in cloud simultaneously).
3.User Account & Authentication
•Handle login, logout, and user sessions.
•Associate files and sync operations with the authenticated user.
4.Versioning & History
•Maintain versions of files to allow rollback.
•Optionally support restore deleted files.
5.Offline Support
•Allow local operations when offline.
•Queue operations for sync when connection is restored.
6.Notifications (Optional)
•Notify user of sync success/failure, conflicts, or storage limits.
🔐 Constraints & Assumptions
•Assume backend cloud APIs exist for file storage, metadata, and authentication.
•Focus is on LLD, client architecture, sync logic, and modular components.
•Handle network failures gracefully.
🧱 Key Components & Classes
1.File Class
1
2class File {
3private:
4 string name;
5 string path;
6 int size;
7 string checksum;
8 DateTime lastModified;
9public:
10 void updateMetadata();
11 string getChecksum();
12};1.Folder Class
1
2class Folder {
3private:
4 string name;
5 string path;
6 vector<File*> files;
7 vector<Folder*> subFolders;
8public:
9 void addFile(File* file);
10 void removeFile(File* file);
11};1.SyncManager Class
1
2class SyncManager {
3private:
4 LocalFileSystem* localFS;
5 CloudService* cloudService;
6public:
7 void syncFile(File* file);
8 void syncFolder(Folder* folder);
9 void handleConflict(File* localFile, File* cloudFile);
10};1.LocalFileSystem Class
•Tracks local files and folders, detects changes (create, delete, modify).
2.CloudService Class
•Interfaces with cloud backend to upload, download, fetch metadata, and handle versioning.
3.UserSession Class
•Manages authentication, tokens, and user-specific sync operations.
4.NotificationManager (Optional)
•Notifies user of sync events, conflicts, or errors.
🔄 Example Workflow
1.User modifies a local file → LocalFileSystem detects change.
2.SyncManager queues file for sync.
3.CloudService.uploadFile() uploads to cloud.
4.If conflict detected → SyncManager.handleConflict() resolves it (e.g., keep both versions).
5.Sync complete → NotificationManager informs the user.
🧪 Expected Deliverables
•Class diagram showing File, Folder, SyncManager, LocalFileSystem, CloudService, and UserSession.
•Implementation of file/folder operations, sync logic, conflict resolution.
•Test cases:
•File upload/download
•Folder sync
•Conflict handling
•Offline operations queued for later sync
💡 Discussion Points
•Conflict resolution strategies: last-modified wins, user prompt, or version merge.
•Handling large files efficiently (chunked upload/download).
•Optimizations for network usage and storage.
•Extensibility for sharing files and collaborative editing.