Design a Dropbox

Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2024-01-03

Problem Statement

Design a high-level system that allows users to upload, store, synchronize, share, and access files from any device. The system should support large-scale storage, real-time sync, versioning, and secure access.


Functional Requirements (FR)


User Management


•Users can register/login via email or OAuth.
•Maintain user profiles and storage quotas.


File Upload & Download


•Upload files of any type and size (with chunking for large files).
•Download files from any device.


Synchronization


•Sync files across multiple devices in near real-time.
•Detect and resolve conflicts from concurrent edits.


File Sharing & Permissions


•Share files or folders with specific users or via public links.
•Control read/write access permissions.


Versioning & Recovery


•Maintain file version history.
•Allow rollback to previous versions.


Search & Metadata


•Search files by name, type, size, or content (optional).
•Store metadata such as creation date, owner, last modified.


Notifications


•Notify users of shared files, edits, or storage limits.


Offline Access


•Allow users to work offline and sync changes when back online.


Non-Functional Requirements (NFR)


•Scalability: Handle millions of users and petabytes of data.
•High Availability: Ensure file access is reliable 24/7.
•Low Latency: Quick file sync and retrieval.
•Durability: Data must not be lost; replicate across regions.
•Security: Encrypt files in transit and at rest; enforce access controls.


Core Components


API / Application Layer


•Handles user requests for file operations (upload, download, sync, share).
•Validates authentication, permissions, and storage limits.


File Storage Service


•Stores files in object storage (e.g., Amazon S3 or distributed storage).
•Handles chunked uploads for large files.


Metadata Database


•Stores file metadata: fileId, userId, size, type, versions, permissions.
•Supports efficient queries for search and listing files.


Synchronization Service


•Detects file changes and propagates them to user devices.
•Resolves conflicts using versioning or operational transforms.


Sharing & Permissions Service


•Manages file/folder access control and link-based sharing.


Versioning & Recovery Service


•Maintains historical versions of files for rollback.


Notification Service


•Sends alerts for file sharing, edits, or storage issues.


Caching / CDN Layer


•Cache frequently accessed files for low-latency retrieval.
•Optional: Use CDN for global performance improvement.


Monitoring & Analytics


•Track storage usage, access patterns, and system health.


High-Level Data Flow


1.User uploads file → API Layer → File Storage Service (chunked upload if large) → Update Metadata DB → Notify devices via Sync Service.
2.User downloads file → API Layer → Fetch from storage → Return file to client.
3.File edited on a device → Sync Service → Update File Storage → Update Metadata → Propagate changes to other devices.
4.User shares file → Sharing Service → Update permissions → Notify target users.
5.Versioned edits → Versioning Service → Store historical copies → Allow rollback.


Design Considerations


•Use chunking and parallel uploads for large files.
•Implement deduplication to save storage.
•Use distributed storage with replication for durability.
•Conflict resolution via last-writer-wins or operational transforms.
•Use CDN and caching for low-latency file delivery.
•Ensure strong encryption for security at rest and in transit.
•Support horizontal scaling for API servers, storage, and sync services.


✅ This is a complete HLD Problem Statement for a Dropbox-like Cloud Storage Service, covering modules, data flow, file sync, versioning, and scalability.

Solution

Comments