Objective
Run a studio's stock and sales, counter and wholesale, from one system.
Covers a catalog with variants, stock by lot and serial number, receiving, a point-of-sale counter, wholesale orders, price lists and sterilization batches. Business rules live in Postgres as constraints, triggers and RPCs.
Challenges
- 01Computed stock left no row to lock, so concurrent sales could double-sell
- 02Several businesses share one database without seeing each other's data
- 03A piece that has not been sterilized must never reach a customer
How it was solved
- 01Append-only inventory ledger with materialized balances that each sale locks
- 02Row-level tenancy enforced by Postgres RLS
- 03Sterilization batches recorded on the ledger; selling an unsterilized piece is blocked
Results
- Catalog, stock engine, receiving, counter, wholesale orders and branding built
- End-to-end tests on desktop, tablet and mobile, with axe accessibility checks
- Ten architecture decision records documenting the main trade-offs
Overview
Built first for piercing and tattoo studios, which sell jewelry and supplies to the public and to other studios and use some of them in their own work. Vertical presets adapt it to other retailers.
Technical Implementation
Data
Stock is an append-only ledger with materialized balances, and money is stored in cents. Constraints, triggers and RPCs keep the rules in the database, where pgTAP tests them.
Tenancy
Each business runs on its own subdomain with its own logo, accent color and title font. RLS separates tenants, and roles set what owners, admins, staff and viewers can do.
Delivery
Decisions are recorded as ADRs. CI runs unit, integration and end-to-end tests and deploys production in order.
Features
- Catalog with variants, vertical presets and CSV import
- Stock by location, lot and serial number, with expiry alerts
- Counter with public and studio price lists
- Wholesale orders and customer price lists
- Dashboard with low stock and suggested reorders grouped by supplier
- Branding settings with a live preview and a contrast check
Technologies
- Next.js 16
- React 19
- TypeScript
- Supabase (Postgres, Auth, Storage, Edge Functions)
- TanStack Query
- TanStack Table
- React Hook Form
- Zod
- shadcn/ui
- Tailwind CSS 4
- Vitest
- Playwright
- pgTAP
- Vercel
