Lesson 5 of 16
39. Design File Storage and Sync (Google Drive / Dropbox)

39.4 What do we store?

3 min read+10 XP
blocks (object storage) key = SHA-256 of the block → bytes (encrypted at rest) files (sharded SQL) namespace_id, path, file_id, latest_version, deleted? file_versions file_id, version, block_hashes[], size, modified_by, modified_at journal namespace_id, seq, file_id, version (the change log devices sync from) namespaces a user's folder, or a shared folder (its own namespace) acl namespace_id, user_id, role

A namespace is a user's root or a shared folder; it's the shard key and the unit of sync, so everything inside one shared folder lives together.

Interviewer pushback:

  • "Why keep block hashes per version?" → Version history is then just old lists of hashes. Restoring yesterday's file is a metadata change; the blocks are already stored.

Memory code: "Blocks by hash, files as lists of hashes, a journal to sync from."