Skip to content
Rushikesh Panchal

All selected work

Stockroom: Inventory & Purchase Order ERP

An inventory and purchase-order ERP where receiving is atomic and stock history is append-only, enforced by the database.

The problem

A small shop or café sits between two mistakes: order too much and cash sits on shelves, order too little and sales are lost. Stockroom tracks stock, suppliers and orders and suggests what to reorder. The stock count must never drift, even when two people receive the same delivery at once.

Architecture

How Stockroom handles a request

  1. Browser

    • React 18 and TypeScript
  2. Express 5 API

    • Bearer JWT
    • Zod validation
  3. RBAC policy (rbac.js)

    • Route permissions
    • Row scope
    • Per-record policy
    • Field masking
  4. Services

    • Inventory
    • Purchase orders
    • Dashboard
  5. SQLite (node:sqlite)

    • BEGIN IMMEDIATE … COMMIT
    • Triggers: stock history, order state machine
The React app sends JSON with a bearer token to the Express 5 API, which validates it with Zod and checks the RBAC policy before calling a service. Services write to SQLite inside BEGIN IMMEDIATE and COMMIT, and database triggers maintain stock history and the purchase-order state machine.

Key decisions

Receiving is atomic.
Receiving sets the status only where it is still ordered; zero rows matched means it was already received, so the request returns 409 and rolls back. A double click or two receivers cannot add stock twice.
Stock only changes through history.
A trigger rejects direct edits to a product’s stock, history rows cannot be edited or deleted, and a CHECK constraint aborts anything that would take stock below zero.
The order lifecycle lives in the database.
Draft, awaiting approval, ordered, received and cancelled transitions are enforced by a trigger, not just by the app, and received or cancelled orders are frozen.
Four layers of access control on the server.
Route permissions, row-level scope, per-record policy with separation of duties (a manager cannot approve their own order) and field masking that strips costs from staff responses. The browser only hides buttons and is never trusted.

Proof

Every number opens its source. Every claim links to the code.
permissions across 3 roles
cumulative layout shift
undersized tap targets fixed

What it doesn’t do yet

  • The demo runs on a free plan: after it has been idle the first visit takes about 30 seconds, and its data resets whenever the service restarts.
  • It is one Node process with SQLite running in-process, with no separate database server.