GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - sarwar-uddin/workshop: Inventory and order management for small workshops: React + Express + PostgreSQL, built slice by slice with written design decisions.

BranchesTags
Open more actions menu

Latest commit

 

History

31 Commits
31 Commits

Folders and files

NameName
Last commit message
Last commit date
apps
apps
 
 
docs
docs
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
docker-compose.yml
docker-compose.yml
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
pnpm-workspace.yaml
pnpm-workspace.yaml
 
 

Repository files navigation

Workshop

A small-business inventory and order management system: products, customers, orders and stock, with every stock change recorded. Demo data uses a leather workshop, but nothing in the code is specific to leather.

Status: in development, milestone M4 (database + domain). Products and categories run on PostgreSQL end to end. Customers, orders, inventory, auth and deployment are still to come. See docs/progress.md.

About

Small workshops and shops tend to track stock in a notebook or a spreadsheet, so the numbers drift: nobody can say why a count changed, or which order used up the last of something. Workshop is a full-stack app built to keep those numbers honest.

The design choices that matter:

  • Stock is backed by a ledger. stockQuantity can't be written through the product API. From the inventory milestone on, every change also records a stock movement in the same transaction, so each count can be explained.
  • Money is never a float. Prices are numeric(12,2) in PostgreSQL and strings end to end.
  • Rules live on the server, with the database as backstop. Zod rejects bad or unknown input, and PostgreSQL constraints (case-insensitive unique SKUs, restricted foreign keys) catch anything that slips through.
  • Archive, don't delete. Products keep their history; IDs are UUIDv7.
  • Every decision is written down. The reasoning lives in docs/decisions.md.

It's being built one vertical slice at a time, each on its own branch with conventional commits.

Stack

Layer Tools
Frontend React, TypeScript, Vite, React Router, TanStack Query
Backend Node.js, Express 5, TypeScript, Zod
Database PostgreSQL 18, Drizzle ORM + drizzle-kit migrations
Dev pnpm workspaces, Docker Compose

Architecture

Browser → React (apps/web) ──/api──→ Express (apps/api) → service → repository → Drizzle → PostgreSQL
           Vite dev server proxies /api to :3000

Inside the API, each layer has one job:

Layer File pattern Responsibility
Routes *.routes.ts HTTP only: parse the request, call the service, choose the status code
Schemas *.schemas.ts Zod rules for untrusted input; unknown fields are rejected
Service *.service.ts Business rules; translates DB errors (unique/FK violations) into API errors
Repository *.repository.ts The only place with SQL/Drizzle queries

Rules are enforced on the server, and PostgreSQL constraints back them up. See docs/database.md and docs/decisions.md.

Project layout

apps/
  api/
    drizzle/              generated SQL migrations (committed)
    src/
      app.ts              builds the Express app (routes, error handler)
      index.ts            starts it: app.listen()
      config/env.ts       validated environment variables
      db/                 schema, client (pool), seed, pg error helpers
      errors/             AppError, error contract, error handler
      validation/         parseInput(): Zod → 400 with field details
      products/           routes, schemas, service, repository, types
      categories/         read-only category list
    test/                 Vitest + Supertest API tests, setup, factories
  web/
    src/
      app/                App, QueryClient
      layouts/            AppLayout
      features/           dashboard/, products/
      lib/api.ts          typed API client + ApiError
docs/                     database, decisions, progress

Development

Requires Node 22.9+ (uses --env-file-if-exists; developed on Node 26), pnpm, and Docker.

cp .env.example .env          # local config (never committed)
docker compose up -d db       # PostgreSQL 18 on :5432
pnpm install
pnpm --filter @workshop/api db:migrate   # apply migrations in apps/api/drizzle/
pnpm --filter @workshop/api db:seed      # demo data (safe to re-run)
pnpm --filter @workshop/api dev          # API on :3000
pnpm --filter @workshop/web dev          # web on :5173

Typecheck: pnpm --filter @workshop/api typecheck (includes tests) and pnpm --filter @workshop/web exec tsc -b.

Tests

pnpm --filter @workshop/api test          # run once
pnpm --filter @workshop/api test:watch    # re-run on save

API tests use Vitest + Supertest and run against a real PostgreSQL database, workshop_test (TEST_DATABASE_URL in .env), never the dev one:

  • Before the run, the database is created if it's missing, and the real migrations are applied to it.
  • Every table is truncated before each test. Each test inserts the rows it needs, then calls the API over HTTP.
  • Test files run one at a time, because they share the database.
  • Tests refuse to start if the database name doesn't end in _test.

The Postgres container must be running (docker compose up -d db).

Database workflow

The schema lives in apps/api/src/db/schema.ts. After changing it:

pnpm --filter @workshop/api db:generate --name <what_changed>   # writes a SQL migration
# read the generated SQL before applying it
pnpm --filter @workshop/api db:migrate
pnpm --filter @workshop/api db:studio                           # optional: browse the DB

Commit the schema change and its migration together. Never edit a migration that has already been applied anywhere; add a new one instead.

API

GET /health returns { "status": "ok" } (liveness only, no DB check).

All responses are JSON. Errors share one shape:

{ "error": { "code": "SKU_TAKEN", "message": "Another product already uses this SKU",
             "details": [{ "path": "sku", "message": "SKU must be unique (case-insensitive)" }] } }

details is only present for field-level problems.

Method Path Description Success
GET /api/products All products, with their category 200 { products }
GET /api/products/:id One product 200 { product }
POST /api/products Create: sku, name, price, optional description, categoryId 201 { product } + Location
PATCH /api/products/:id Partial update of the fields above, plus status (active/archived) 200 { product }
GET /api/categories All categories 200 { categories }

Notes:

  • price is a string ("1850.00"), both in requests and in responses. Money never passes through a float.

  • stockQuantity is read-only. Stock will change only through inventory adjustments, each of which records a movement.

  • Error codes:

    Code Status When
    VALIDATION_ERROR 400 A field is missing, invalid, or unknown
    INVALID_JSON 400 The request body is not valid JSON
    CATEGORY_NOT_FOUND 400 categoryId doesn't match a category
    PRODUCT_NOT_FOUND 404 No product with that id (a malformed id also gets 404)
    SKU_TAKEN 409 Another product already has that SKU, in any letter case
    INTERNAL_SERVER_ERROR 500 Anything unexpected; the real error is logged on the server

License

Copyright © 2026 Sarwar Uddin

Workshop is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. If you run a modified version on a server, the AGPL requires you to offer its source code to the users who interact with it.

About

Inventory and order management for small workshops: React + Express + PostgreSQL, built slice by slice with written design decisions.

Topics

drizzle-ormexpressfull-stackinventory-managementpostgresqlreacttypescriptzod

Resources

Readme
AGPL-3.0 license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.