Skip to content
crow50Public

About

No description, website, or topics provided.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

D.O.O.M.

Don't Organize Only Move - a self-hosted inventory system for people with more sites, shelves and bins than memory.

Label a container once. Scan it forever.


What it does

Build a tree of physical places and record items anywhere in it:

Kind What it is Examples
Site A geographic place, usually with an address North Yard, Workshop
Zone A building or open yard within a site Bay 1, Back Room
Shelf Fixed storage: shelving, racking, a cabinet Rack A, Cabinet 2
Bin Something you can carry Tote A1, Crate 12

Any location can hold items directly, and the tiers need not nest in order - a shelf can stand straight in a zone, which is how flammables end up racked in an open yard.

Attach photographs, documents and links to manuals. Print QR labels or write NFC tags, then scan a bin to see what is inside without opening it.

Capture takes one action. Photograph a thing and you are done - naming, filing and counting are all optional and all later. That is the point of the name: Didn't Organize, Only Moved is the ADHD term for the pile that migrates from table to chair to floor because deciding where each item belongs is expensive. Requiring a decision at capture time is how you get a pile.

Scan barcodes to find what you already have. An optional, off-by-default lookup can suggest a product name; nothing leaves your machine unless you turn it on.

Sign things out to a person or a crew and check them back in - custody is tracked without moving the item, so it still knows where it lives.

Every add, removal, move and checkout is written to a ledger, which is where the name comes from. Each item and location shows one merged history: movements, custody, edits, uploads, sharing changes, and every time a shared link was opened - or a plausible one was refused.


Quick start

cp .env.example .env
make init      # generates strong secrets with openssl
make up        # builds and starts caddy, web, db, cache
make upgrade   # applies database migrations
make seed      # optional: a demo account and a small site

Then open https://localhost:8443 - the certificate is self-signed by Caddy's internal CA, so expect a browser warning on first visit.

Demo account: demo. make seed generates its password and prints it once - there is no default credential to forget to change (ASVS 5.0.0-6.3.2). It refuses to run against a database that already holds other accounts.

Serving this on a real domain, or behind the reverse proxy that already holds your certificates? caddy/conf.d/README.md covers the three ways to get a publicly trusted certificate without rebuilding the image, and make verify-cert checks that the one you are serving is the one you think you are.

Set PUBLIC_BASE_URL in .env before printing labels. It is encoded into every QR code and NFC tag, and a label printed against the wrong address is permanently useless.

make help lists everything else.


Architecture

[browser / phone] ──HTTPS──▶ caddy ──TLS──▶ web (gunicorn + flask)
                                            │
                                            ├──TLS───▶ db      (postgres)
                                            ├──TLS───▶ cache   (redis)
                                            ├─plain──▶ clamav  (clamd)
                                            └───────▶ uploads volume

Only Caddy publishes a port. db, cache and clamav sit on an internal Docker network with no route off the host - clamav alone has one narrow, permanent exception to reach database.clamav.net for signature updates. caddy→web, web→db and web→cache all require TLS, verified against an internal CA; clamd's INSTREAM protocol has none to offer, so that one hop stays plaintext behind the network boundary (see SECURITY.md §4).

TLS is a functional requirement rather than polish: Web NFC only runs in a secure context, and a phone reaching this host by LAN IP is not one.

Stack: Python 3.14, Flask, SQLAlchemy, PostgreSQL 18, Redis 8, Caddy 2, Docker Compose. Exact pins live in app/Dockerfile and docker-compose.yml; app/requirements.txt is a hash-pinned pip-compile lockfile.


Security

This was built as a secure-coding coursework project, so the reasoning is documented as carefully as the code.

Document What it answers
THREAT-MODEL.md What is being defended, from whom, and what is explicitly not defended
SECURITY.md Which control answers which threat, and where it lives
DECISIONS.md Why each limit, algorithm and tradeoff is what it is
PIPELINE-NOTES.md DevSecOps tooling roadmap
DEMO.md Run-of-show for presenting it
security/ The ASVS 5.0 ledger, the documented policies it requires, the open findings, and how to verify any of it yourself
INSPIRATION.md What Sortly, Grocy, Homebox, Snipe-IT and real warehouse systems do differently, and what to borrow

The threat model was written before the code, and every control traces back to a threat named in it.

The idea the design rests on

Most web applications treat the database as valuable because it holds account data. Here it is a map to physical property - what someone owns, how much of it, and which building it is in. A breach doesn't merely embarrass the operator; it hands a burglar a shopping list with addresses. Every tradeoff resolves in favour of protecting that.

Five consequences worth knowing before reading the code:

Every field bound lives in one file. app/doom/validation.py is the single source of truth for the limits on user data — text lengths, quantities, password length, tree depth. Forms, ORM columns, database CHECK constraints and HTML attributes all read from it, so a bound cannot be tightened in one place and left loose in another.

Two kinds of limit necessarily sit outside it, and it is worth knowing which: the request body cap exists twice by design (Flask refuses anything over 10 MB on its Content-Length before reading a byte; Caddy's 12 MB cap is the backstop for bodies that declare no length), and pagination and batch caps are hardcoded per view. Those are performance ceilings rather than security bounds — but "every limit in one file" was too strong a claim, and docs/DECISIONS.md D-01 now says which limits D-01 actually covers.

Ownership is a WHERE clause, not an if statement. Fetch-then-check loads the row before deciding; filtering inside the query means it is never loaded. A miss returns 404, never 403 - a 403 confirms the object exists.

History can be added to but not rewritten. The audit trail is hash-chained, and UPDATE and DELETE are revoked on audit_log for the application's database role — so even a complete SQL injection cannot rewrite history, only append to it. make audit-verify proves it.

The scope of that is exactly one table. The application role holds full DML on everything else, so an injection could still alter or delete items and locations; what it cannot do is cover its tracks.

A scanned barcode is hostile input. Anyone can print a barcode, and it arrives wearing the authority of a physical object. Everything hangs off one choke point: eight to fourteen digits, or it is rejected outright.

Shared pages omit rather than hide. A public view is built from a reduced dictionary that has no owner and no ancestor chain in it. A forgotten template guard fails silently; a field that was never passed cannot leak.

Verifying the claims

make test           # the suite that pins every control claimed above
make audit-verify   # walk the audit hash chain, print the head hash
make lint           # autoescape bypasses, and the docs against the ledger
make db-shell-app   # connect as the app's restricted role and try DROP TABLE

Run make test for the count; it is deliberately not written down anywhere, because a number in prose has to be kept in sync by hand and the ledger already names the test behind each control.


Self-hosting notes

Ports. Defaults are 8080/8443 so the stack starts under rootless Docker, which refuses to bind below 1024. On a rootful daemon, set HTTP_PORT=80 and HTTPS_PORT=443 and drop the port from PUBLIC_BASE_URL - before printing labels. The plaintext port only redirects, and it redirects to whatever HTTPS_PORT is.

Upgrading from a version where Caddy ran as root. Caddy now runs as uid 10002 and cannot read the CA that a root Caddy wrote into caddy_data. Once: docker compose rm -sf caddy && docker volume rm doom_caddy_data doom_caddy_config, then make up. A new internal CA is generated, so re-run make trust-cert on any phone that trusted the old one.

Upgrading from a version without internal TLS. make up and make upgrade now bind-mount an internal CA and per-service certificates that an existing deployment's secrets/ does not have yet. Run make init again first - it leaves your existing .env and passwords alone and only adds the CA and certs that are missing - then make up && make upgrade as usual.

A real domain. Point DOOM_DOMAIN at it and set PUBLIC_BASE_URL to match; Caddy switches from its internal CA to Let's Encrypt on its own - there is no setting here to turn that on. caddy/conf.d/README.md covers the ACME contact address, the staging CA (use it for the first issuance), and the two other ways to get a publicly trusted certificate without exposing this host to the internet at all.

Backups. make backup covers the database and the uploads volume. A database dump alone is not a backup - every photo and document lives in the volume. make restore takes both.

Changing anything in db/init/ needs make clean. Those scripts run only when the postgres data directory is empty; on an existing volume the entrypoint skips them silently, so an edit there has no effect until the volume is destroyed. If make seed fails with "password authentication failed for user doom_app", this is almost certainly why - run make verify-db-roles, which reports it as a skipped bootstrap rather than a wrong password.

NFC. Web NFC is Chromium-on-Android only; there is no iOS support. QR codes work everywhere and carry the same URL.


Licence

Personal coursework project. Use it however you like.

Current review: release security assessment, ASVS status, and hosted readiness. No ASVS level or release readiness is implied by scanner success.

About

No description, website, or topics provided.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages