Order Case Management
Play 2 · Backend Modernization Order operations Native RBAC

A governed order operations backend

Every order is a case that moves through an enforced state machine. Role checks at the API layer decide who can advance or hold it, and every transition is written to an audit trail with the actor and the reason.

7 tables · 11 endpoints · 3 API groups

Order detail on exception hold: the rule that fired, the short line item, the role-gated actions, and the full audit trail
An order held on the insufficient-stock exception, with the reason, the short line, and the audit trail.

What it demonstrates

API surface

EndpointWhat it enforces
POST /api:auth/loginMints a token. Same 401 on a bad email or a bad password.
POST /api:orders/createOps or supervisor only. Requires a real customer. Totals the lines on the server.
POST /api:orders/validatereceived to validated. Needs at least one line item.
POST /api:orders/allocatevalidated to allocated. Reserves and decrements stock, or holds on exception.
POST /api:orders/fulfillallocated to fulfilled.
POST /api:orders/exceptionPuts an active order on exception hold with a reason.
POST /api:orders/resolveSupervisor only. Returns the order to its pre-exception state.
POST /api:orders/cancelSupervisor only. Cancels an open order.
GET /api:orders/listAny signed-in role. Orders, customers, and stock on hand.
GET /api:orders/get/{order_id}Any signed-in role. One order with lines, allocations, timeline, and stock.
POST /api:seed/runPublic. Resets the demo data.

Frontend screens

Sign in

One account per role, with a quick sign-in chip for each, so you can feel the role gates.

Orders board

Status badges, customers, totals, and a stock-on-hand panel. Ops and supervisors can open a new order.

Order detail

The state rail, role-gated actions, the exception banner with a Resolve action, line items against stock, and the audit trail.

The action buttons show for the current state. A lock marks one your role cannot run, and clicking it returns the real 403 from the API, so you can see the check is server-side, not on the screen.

Use this template

Point your AI coding agent at this repo and adapt it to your domain:

Use the XanoTS template at
https://github.com/xano-scratch/order-case-management-backend
as the starting point for my backend. Clone it, run npm install, then
npx xanots login and npm run xano:deploy to get a live environment that
self-seeds. Then adapt the tables, endpoints, and roles to my domain.

Or clone and deploy it yourself:

git clone https://github.com/xano-scratch/order-case-management-backend
cd order-case-management-backend
npm install
npx xanots login
npm run xano:deploy

The links in the build notes point at a temporary environment that expires. The durable artifact is this repo. Anyone can re-deploy it with npm run xano:deploy for fresh links, and it self-seeds so the demo is browsable right away (sign in with ops@demo.test / demo1234).