Design Workspace File Organization
Design a scalable hierarchy for browsing, creating, renaming, and moving files and folders without cycles, orphaned nodes, or stale listings.
Problem statement
For this exercise, assume a team workspace organizes file metadata in a nested folder hierarchy. An authorized member browses a folder, creates files and folders, renames them, and moves one file or folder to another parent.
Stable node IDs must survive renames and moves, and canonical case-folded names must be unique among one parent's direct children. A successful move must not create a cycle, orphan the node, or make it appear under two parents.
Binary file storage, file editing, full-text search, sharing-policy authoring, and cross-workspace moves are outside scope; assume an upstream identity service supplies the current workspace and authorization context.
What to build
- List a folder's direct children with stable pagination and enough metadata to render a file browser.
- Create files or folders under an authorized parent and rename a node without changing its stable ID.
- Move a file or complete folder subtree to a new parent atomically while preventing cycles and duplicate parentage.
- Retry or reconcile a timed-out create, rename, or move without applying the logical mutation twice.
At scale
- For this exercise, assume one workspace may contain one million file and folder nodes, a hierarchy depth of at most 50, and a folder page size of at most 200 direct children.
- For this exercise, assume 10,000 folder-list reads and 2,000 metadata mutations per second at peak, with heavy traffic on workspace roots.
- For this exercise, assume folder-list reads should complete within 100 ms at p95 and accepted metadata mutations within 500 ms at p95.
- For this exercise, assume an acknowledged move is atomic from readers' perspective and survives a service-instance failure; stale writes return an explicit conflict.