Google Docs-style sharing, without building Google

Folders, documents, shared links, and inherited permissions. Bailiff handles the graph traversal so your database doesn't have to.

The scenario

Users create documents and organize them in folders. They share folders with colleagues, and every document inside should be automatically accessible. Some documents have individual sharing overrides. Public links provide view-only access.

📂
Shared Folder
Team: Engineering
📄
Spec v2
✓ Inherited
📄
Roadmap
✓ Inherited
📄
Budget
+ Direct share

The problem with hard-coded logic

Recursive queries

Checking "can this user see this file?" means traversing the folder tree in your database with expensive recursive queries.

Inconsistent sharing

Folder sharing, direct sharing, and public links are implemented as separate systems that don't always agree.

Performance at depth

Deep folder hierarchies get slower as nesting increases. Your API latency depends on folder depth.

Can't explain access

When a user reports they can't access a file, debugging requires tracing through multiple tables and code paths.

How Bailiff models it

Hierarchical relationships

Documents belong to folders. Folders can contain other folders. Bailiff traverses the graph automatically when you check permissions.

// Document inherits from folder
await bailiff.relate('doc:spec-v2', 'parent', 'folder:engineering');

Share at any level

Share a folder with a team and every document inside is accessible. Share a single document with an individual for fine-grained overrides.

await bailiff.assign('team:engineering', 'editor', 'folder:engineering');
// Alice can now edit doc:spec-v2 (inherited)
await bailiff.check('alice', 'edit', 'doc:spec-v2'); // true

Explain the access path

Every check shows the full inheritance chain: user → team → folder → subfolder → document. Debugging is instant.

Try it in the playground

The Collab Drive scenario demonstrates folder sharing, inheritance, and public links. Switch identities to see how access flows down the hierarchy.