<aside> π§
One catalog drives everything. database/catalog/model.mjs defines every entity once; it generates the SQL schema, the data dictionary, the runtime Zod validation and the frontend Data Register forms.
</aside>
<aside> ποΈ
PostgreSQL 16
63 tables Β· NUMERIC money Β· SQL views for totals
</aside>
<aside> βοΈ
Express 5 API
Zod-validated Β· role-gated Β· audited
</aside>
<aside> π₯οΈ
React 19 SPA
Vite Β· MSAL Β· workshop planner UI
</aside>
flowchart LR
User["Browser (React 19 SPA)"] -->|"HTTPS + Entra token"| App["Express 5 API<br>server/index.mjs"]
App -->|"restricted role / TLS"| PG["PostgreSQL 16"]
App -->|"managed identity"| Blob["Azure Blob<br>(local disk in dev)"]
App -.->|"MYOB_ENABLED only"| MYOB["MYOB AccountRight"]
Catalog["catalog/model.mjs"] --> SQL["001_native.sql"]
Catalog --> Zod["Zod schemas"]
Catalog --> UI["/api/model β Data Register"]
API layers
| Endpoint | Purpose |
|---|---|
/api/entities/:kind |
Generic native CRUD for all 62 non-file collections (paged, max 1,000/request) |
/api/records/:kind |
Workflow view models; PATCH is the normal write path |
/api/actions/:kind/:id/:action |
Guarded lifecycle transitions: quote accept, PO/receipt, delivery sign-off, invoice status |
/api/bootstrap |
Workshop overview: newest 1,000 records per kind + settings, reference names, audit |
/api/config |
Unauthenticated: auth mode, Entra IDs, demo flag |
/api/projects/:id/identifiers |
External aliases; only Admin/Director verify |
/api/integrations/myob/* |
MYOB status, connect, outbox, reconcile, CSV export |
Design rules
quote_totals, invoice_balances, purchase_order_totals)version (409), row locks, idempotency keysMigrations
| # | Adds |
|---|---|
| 001 | Generated catalog schema (63 tables) |
| 002β005 | Integrity triggers, history, allocation limits, commercial history |
| 006β007 | app_settings: GST, currency, timezone |
| 008 | workflow_events |
| 009 | PDF documents, issue-time snapshots |
| 010 | Import rows, exceptions, external aliases |
| 011 | MYOB outbox, OAuth state, events |
<aside> π
Never edit an applied migration. Add a new numbered file. Checksums are verified at startup.
</aside>
Access model
| Role | Typical write access | π² Values |
|---|---|---|
| Admin / Director | All operations | Yes |
| Sales | Customers, enquiries, quotes, estimates, variations | Yes |
| ProjectManager | Enquiries, projects, drawings, workshop, receipts, delivery | No |
| Workshop | Tasks/time, receipts, nests, delivery | No |
| Quality | Quality checks | No |
| Finance | Purchase orders, invoices | Yes |
Proposed policy; validate with owners (task P06).