Version: immutable content snapshot of a logical file.
Manifest: ordered list of chunk hashes for one version.
Chunk: byte block stored by content hash; chunks may be deduplicated only when privacy policy permits it.
Resource: FILE or FOLDER, the target of a share or link.
Share: authenticated principal-to-resource grant.
Share link: bearer-token grant with independent restrictions.
This separation is essential: names, folders, ACLs, and version history are metadata; bytes live in object storage. Do not store a multi-GB file as one row, load it wholly into memory, or mutate a committed version in place.
Deletion is normally a state transition to TRASHED, not immediate byte removal. A retention worker permanently deletes metadata and decrements chunk references only after retention and legal-hold checks.
Effective-access algorithm
Authenticate the actor (or validate a link token separately).
Load the resource and reject missing, trashed, quarantined, or inaccessible ancestors.
If actor is owner, allow owner capabilities.
Load active direct grant on the resource.
Walk ancestors to load active folder grants for the actor, stopping at root.
Combine grants according to a documented rule: use the most specific direct grant first; otherwise the strongest inherited grant. This guide has no explicit deny rule.
Map effective role and resource policy to the requested action; authorize immediately before the protected write/download URL is issued.
Client calls startUpload with file metadata, expected bytes, optional content hash, parent, and target/base version.
Server authorizes CREATE_CHILD or WRITE, creates an expiring UploadSession, returns chunk size and missing-part state if resuming.
Client splits the stream into fixed-size parts (for example, 4–16 MiB); for each part it calculates a hash and uploads it.
Chunk store uses an atomic put-if-absent by hash. It verifies the supplied hash before accepting the part.
Client calls complete with the ordered manifest and whole-file checksum.
Server validates every part, authorizes again, detects base-version conflicts, writes immutable Manifest, FileVersion, updates File.currentVersionId, and inserts an outbox event in one transaction.
Background work indexes, notifies, and signals sync clients. Session cleanup removes orphaned unreferenced chunks after a safety window.
Fixed vs content-defined chunks: fixed chunks are simpler and predictable; content-defined chunking improves dedupe after insertions but adds CPU and implementation complexity.
Deduplication privacy: global hash-based dedupe can expose whether another tenant possesses content. Prefer tenant-scoped dedupe or encrypted chunk domains; never let a “chunk exists” response become an information leak.
Reference counts: increment only when a committed manifest begins referencing a chunk; decrement in the deletion transaction. Physical garbage collection is asynchronous and rechecks references.
Integrity: use cryptographic chunk hashes, ordered manifest positions, total length, and a final content hash. HTTPS alone is not a storage-integrity model.
Versioning: metadata rename/move need not create content versions. Content replacement always creates one. Restore points the head at a new version made from an earlier manifest, preserving history.
For a binary file, do not silently overwrite another editor’s unseen version. On completion, compare baseVersionId with current head:
Equal: commit normally.
Different: return 409 Conflict, or create name (conflicted copy) with the client’s uploaded version, depending on product policy.
Text three-way merge is a specialized extension; it needs a base, server head, and client proposal, and is unsuitable as a generic binary-file default.
Object-store conditional create / DB unique hash; never check-then-insert without atomicity.
ACL cache after revocation
Invalidate event; for sensitive reads, use short TTL or versioned ACL epoch.
Use fine-grained locks only within a process, keyed by file/session/resource. Never hold a lock across network upload, object storage, notification, or user callback. Lock ordering must be stable when moving between folders to prevent deadlocks. In a multi-instance deployment, use DB conditional writes/transactions rather than relying on in-memory locks.
Use keyset/cursor pagination, not deep offsets. A cursor encodes the last stable sort tuple, for example updatedAt|fileId, signed or opaque to clients. Query cost is typically O(log N + pageSize) using a suitable ordered index, versus expensive skipping/scanning for deep offsets.
Search should return only candidates the caller may discover. Authorization changes race with indexing, so exact open/download authorization still happens after result selection.