Design a File Storage System (Dropbox)
HardReal World SystemsFile SystemVersioningSyncPermissionsChunk Upload
Problem Statement
Design a cloud file storage system like Dropbox where users can upload, organize, share, and sync files across devices — with versioning, chunked uploads, and access control.
Requirements
Functional Requirements
- Users upload and download files
- Folder hierarchy: create, rename, move, delete folders
- File operations: upload, download, rename, move, copy, delete
- Chunked upload: large files split into chunks and uploaded independently; reassembled server-side
- File versioning: keep last N versions of each file; restore any previous version
- Sharing: share file/folder with specific users (VIEW/EDIT) or via public link
- Sync: detect local changes and sync to cloud; pull remote changes to local
- Storage quota per user (e.g., 15 GB free)
- Search: find files by name, type, or content (filename only for interview)
Non-Functional Requirements
- Concurrent uploads for same file handled safely
- Thread-safe file/folder metadata updates
- Singleton FileStorageService
Key Entities
- File: id, name, size, type, owner, parentFolder, chunks, versions, createdAt, modifiedAt
- Folder: id, name, owner, parent, children (files and folders)
- FileVersion: versionNumber, fileId, content hash, size, savedAt
- Chunk: fileId, chunkIndex, hash, size, data
- Permission: userId, resourceId, resourceType, access (VIEW/EDIT)
- FileStorageService: Singleton
Constraints
- Max file size: 10 GB
- Chunk size: 4 MB
- File versions: last 10 retained; older purged
- Storage quota enforced before upload
- Concurrent chunk uploads for same file: allowed (all chunks needed before assembly)
!Constraints
- Max file size 10 GB; chunk size 4 MB
- Storage quota must be checked before accepting upload
- Concurrent chunk uploads allowed; assembly triggered when all chunks received
- File versions: last 10 retained, older purged automatically
- Sharing links expire after configurable duration (default 7 days for public links)
Output
Run or submit your code to see output here.