FILE MANAGEMENT

A filing cabinet that already knows the rules.

Drawings and documents used to live wherever the last person saved them — one project's structure never quite matched the next, and there was no consistent way to say "Team Lead can see structural drawings but not invoices."

PythonDjangoPostgreSQL
BCE / Standard Project Structure — Auto-Seeded
01-FinancialInvoices, budgets, cost documents
CEO, Senior, Accountant only
02-Discipline / 01-ARCH / IN · WIP · OUTArchitectural drawings, by phase
CEO, Senior, Team Lead, Junior
02-Discipline / 02-STR / IN · WIP · OUTStructural drawings, by phase
CEO, Senior, Team Lead, Junior
02-Discipline / 03-ELEC, 04-MECHElectrical & mechanical, same IN/WIP/OUT split
Same access
03-AdministrativeCorrespondence, general project docs
Role-configurable
The Result

A consistent, permission-aware folder structure now auto-creates itself for every new project, and holds up cleanly past a few hundred files.

The Breakdown

No Consistent Structure

Every project organized differently

Auto-Seeded From a Template

Same structure, every single time

Files, Exactly Where Expected

Role-aware, versioned, at scale

The Problem

A firm running bridges, residential, industrial, and administration projects side by side needed one folder structure that made sense for all of them — financial documents, discipline drawings (architectural, structural, electrical, mechanical), and general administration — without forcing every project into a rigid, hand-built hierarchy each time. It also needed to hold up at scale: hundreds of files per project, permission checks on every single one, and staff assignments that change mid-project and need folder access to follow along automatically.

What I Built

A VirtualFolderTemplate defines the standard BCE structure once — Financial, Discipline (Architecture/Structural/Electrical/Mechanical, each split into In/WIP/Out phases), and Administrative — and every new project gets that whole tree auto-created from the template. Each VirtualFolder is polymorphic, attaching to either a Project or a Client, and carries its own JSON-defined role_access_rules per folder type. Underneath that: a BulkPermissionChecker that preloads assignment data instead of querying per-file, a Celery task pipeline for hashing and folder moves that never blocks the request, and signals that keep folder access in sync the moment a staff assignment changes.

Process

How it works.

01

Seed from template

A new project's entire folder tree — Financial, Discipline (4 sub-disciplines × 3 phases), Administrative — is created automatically from the standard BCE template, not built by hand each time.

02

Attach polymorphically

Each folder links to either a Project or a Client through a generic relation, so the same folder model serves both without duplicating logic.

03

Gate by folder type

Every folder type carries its own JSON role-access rules — Financial folders are locked to CEO/Senior/Accountant, Discipline folders stay open to whoever's actually assigned to that work.

04

Version, don't overwrite

Every file upload creates a new version linked to a single root file with an incrementing version number — nothing is ever silently replaced, and SHA-256 hashing runs in the background so it doesn't block the upload.

At Scale

What happens past a few hundred files.

The parts that only matter once a project has real volume behind it — which, for a firm running since 1970, happens fast.

01

Adaptive ZIP downloads

Folders under 100 files zip straight into memory. Past that, it switches to a temp file on disk automatically — so a big discipline folder download doesn't try to hold everything in RAM at once.

02

Chunked, resumable hashing

SHA-256 hashing reads large files in 1MB chunks with progress checkpoints every 10MB, a 25-minute soft limit, and exponential-backoff retries on I/O errors — a huge upload can't silently hang a worker.

03

Permission checks, preloaded

A BulkPermissionChecker loads every relevant assignment in one query before checking access on a whole folder tree — instead of one query per file, which is what actually falls over at scale.

Staying Correct

Access follows the assignment, automatically.

Folder permissions aren't set once and forgotten — a set of signals keeps them honest every time the underlying reality changes.

New assignment createdqueue folder permission sync for that project
Assignment status changesre-sync permissions, invalidate that user's cache
Assignment reassignedinvalidate cache for both the old and new assignee
Project status changesre-sync permissions if the project already has folders
User's role changesinvalidate their permission cache system-wide
Outcome
3
TOP-LEVEL FOLDER TYPES
FINANCIAL · DISCIPLINE · ADMIN
12
SUB-FOLDERS AUTO-CREATED
4 DISCIPLINES × 3 PHASES
1
QUERY TO PRELOAD PERMISSIONS
NOT ONE PER FILE
100
FILE THRESHOLD
WHERE ZIP STRATEGY SWITCHES
Why it matters

The moment a firm has more than a handful of projects, "just organize it sensibly" stops being a plan. Seeding the same structure every time — with the same access rules baked in — means a Team Lead on project #40 finds things exactly where they were on project #4, and nobody has to remember to lock down the financial folder by hand.