Repository navigation
Installation
Getting a development stack running on your own machine. Standing one up on a real host is Deployment.
- Python 3.13+
- Node 24+
- Docker
Docker is required to run the backend tests, not only to run the app: the suite runs
against real PostgreSQL and fails rather than skipping when none is reachable
(ADR-0021). docker compose up -d postgres is enough.
run_web.batBrings up database, API, workers and the storefront on :5173. run_console.bat adds
the farm console on :5174, reusing anything already running. run_design.bat serves
the static design kit on :4180. Each script checks what is already up, so running two
of them does not start a second API or collide on a port.
1. Infrastructure.
docker compose up -dPostgres runs on 5433 and Redis on 6380 — deliberately off the default ports so a locally installed Postgres does not shadow the project's.
2. Backend virtualenv.
cd backend && python -m venv .venv && .venv/Scripts/python -m pip install -e ".[dev]" -c constraints.txt-c constraints.txt matters. pyproject.toml declares floors (>=); the constraints
file says which versions the image, CI and your machine all actually install. Without it,
three people can pass the same gates against three different dependency sets.
Regenerating it is a deliberate act — the file's own header says how.
3. Migrations.
cd backend && .venv/Scripts/python -m alembic upgrade head4. Frontend.
cd frontend && npm install5. An owner account. Made with the same tool a real farm uses — it prompts for the password rather than taking it as an argument, and outside production it does not object to the documentation domain:
cd backend && ./.venv/Scripts/python.exe tools/provision_owner.py --email boss@printorian.exampleThe operator account is then made through the console, by the owner, like every other staff account.
6. Seed data, if you want a populated catalogue, materials and journal:
backend/scripts/seed_*.py, each idempotent.
The development database carries two accounts. Their passwords are published, and that
is safe only because a farm can no longer be served with them: the API refuses to
start in production while any account sits in a domain reserved for documentation
(contexts/identity/reserved.py). Restoring a developer dump into a real farm is now a
container that will not come up, rather than a published owner password.
| Account | Password | Role |
|---|---|---|
boss@printorian.example |
owner-pass-12345 |
owner — every screen |
floor@printorian.example |
shop-floor-pass-1 |
operator — production screens only |
Two roles rather than one on purpose: most authorization bugs only show up when somebody who should not see a screen opens it, and that needs an account that cannot.
Known drift. The stored hash for
floor@does not match the password above, and that account isengineerin the database rather thanoperator. A role is an authorization decision, so it was left alone rather than silently changed. Recorded in HANDOFF.md §5.
Two terminals. The API:
cd backend && .venv/Scripts/python -m uvicorn printorian.api.app:create_app --factory --reloadThe workers:
cd backend && .venv/Scripts/python -m printorian.workersSeparate on purpose. A sweep holding a database session should not compete with request handling for the same event loop, and a deployment running several API workers behind a proxy would otherwise run one copy of every clock per worker — each recomputing the same credits and publishing the same events.
The frontends:
cd frontend && npm run dev --workspace @printorian/webcd frontend && npm run dev --workspace @printorian/consolePRINTORIAN_API_URL points the dev proxy at a different backend (default
http://localhost:8000); PRINTORIAN_CONSOLE_PORT moves the console's dev server.
cd backend && .venv/Scripts/python -m pytest -qcd frontend && npx vitest run| Path | Purpose |
|---|---|
tests/unit/ |
Context logic — money, permissions, identity, rollups |
tests/api/ |
HTTP behaviour, especially the authorization boundary |
tests/contract/ |
The contract every printer driver must satisfy |
tests/virtualfarm/ |
End-to-end farm runs against mock printers |
tests/test_migrations.py |
Real Alembic against real PostgreSQL |
The virtual farm is deterministic: it advances a FixedClock rather than sleeping,
so a farm-day of printing runs in milliseconds and never flakes.
tests/contract/test_bambu_hardware.py needs a real printer and a git-ignored
printers.local.toml. Without that file every one of its cases skips, so CI is
untouched and nobody needs a printer to work on the rest of the system.
The TypeScript client is generated from the backend's OpenAPI schema and is never hand-edited (ADR-0005). After changing any route or DTO:
cd backend && .venv/Scripts/python tools/export_openapi.py --out openapi.jsoncd frontend && npm run generate:apiIn CI the client is generated from the schema the backend job exported and never committed. That is what makes a breaking backend change fail the build at the commit that caused it, rather than in somebody's editor a week later.
Run the six gates locally. Each encodes a specific way this kind of system rots, so a failure is a design signal rather than a formality — see Development and Governance.
cd backend && .venv/Scripts/python -m ruff check . && .venv/Scripts/python -m ruff format --check .cd backend && .venv/Scripts/python -m mypycd backend && .venv/Scripts/lint-importscd backend && .venv/Scripts/python tools/check_context_isolation.pycd backend && .venv/Scripts/python tools/check_file_length.pyNever pipe a gate into
tail.cmd | tailreturns tail's exit code.npm ci | tailonce reported success while the install had failed, and every check after it ran against a stalenode_modules. Usecmd > /tmp/out.log 2>&1; echo "exit=$?".
If Git's bundled ssh cannot find your key, a Cyrillic home directory is the likely
cause. Keep keys on an ASCII path and point core.sshCommand at it.
Printorian wiki · the code is the source of truth · open work lives in issues · current state in HANDOFF.md
Concepts
Workflow
Lifecycles
- Order Lifecycle
- Job Lifecycle
- Scheduling and Dispatch
- Materials and Inventory
- Fleet and Drivers
- Post-Production and Packing
Money
Running it
- Installation
- Configuration
- Deployment
- Operations
- Backup and Restore
- Database Maintenance
- Troubleshooting
Building it