Case study 11 · Full stack · AI decision support

Four sign-offs,one paper trail

A procurement approval system. A project head raises a Bill of Materials, and it moves through budget, technical and final review. Every action is written to an audit trail that cannot be edited, and Claude gives each request a cost-risk rating to help reviewers decide.

In progress · phase 2 of 7Next.js 15 · SQLite · Drizzle

My roleDRAFT Team project. Confirm which parts were yours before sending this page out.

4Roles
10Workflow states
5Tables
0Editable audit rows
Data flow · how a record moves

One BOM, four sign-offs

This is the documented flow; the app is still being built (phase 2 of 7). A reject stops the dot; a send-back returns it to draft. Click a stage to read what happens there.

01 · Workflow

Walk a BOM through it

Act as each reviewer in turn. Approve moves it on, reject stops it, and send back returns it to draft for revision. Every click lands in the audit trail below.

    Simulation of the documented flow. Status codes shown are the ones named in the README.

    RBACEach role can only act on the stage it owns. Permissions live in lib/rbac.ts, transitions in constants/workflow.ts.

    02 · AI support

    A second opinion on cost

    Claude Sonnet reads the BOM and returns a risk level with cost-optimisation suggestions. It advises; a human still approves.

    LowLOWCosts in line, approve as normal.
    MediumMEDIUMSome lines worth a closer look.
    HighHIGHFlag for detailed review.

    Illustration · the three levels are from the README; the cycling demo is not a real analysis

    Endpoint/api/ai/analyze calls the Claude API from lib/ai.ts.

    03 · Data

    Five tables

    ApprovalsThe approvals table is the audit trail. Rows are only ever inserted.

    04 · Build

    Typed end to end

    01AuthSession-based login with better-auth.
    02TypesTypeScript strict mode, Zod validation at runtime.
    03FilesPDF and Excel attachments, up to 50MB.
    →StatusIN PROGRESSDatabase and migrations are done; UI phases are still being built.
    Next.js 15React 19TypeScriptDrizzleSQLitebetter-authZustandZodClaude API

    Queries13 typed CRUD helpers in lib/db/queries.ts.