Objective
Replace a spreadsheet and sell online without a second inventory.
Covers green coffee intake, roasting, packaging, sales, shipping and reporting. Business rules live in PostgreSQL constraints and triggers, so stock, lots and costs stay consistent whichever app writes them.
Challenges
- 01Stock must never go negative
- 02Cost per kilo depends on the weight lost in each roast
- 03Sales reps share data with administration but must not see costs or margins
How it was solved
- 01Database constraints and triggers reject invalid writes
- 02Shrinkage is recorded per roast and cost per kilo derived from it
- 03Row Level Security on every table
Results
- One database and one inventory for the panel and the store
- Integration tests against a database rebuilt from scratch in CI
- Versioned migrations with an automated drift check against production
Overview
Administration and sales reps work in the panel; customers buy in the store.
Technical Implementation
Data Model
Every sale points to a lot, and a blend deducts from its source lots through a single path. Supplies are costed FIFO, so new purchases do not rewrite past margins.
Online Store
Each order becomes a panel sale, and each payment is recorded once even if it arrives late or twice. Customers pay by bank transfer or Mercado Pago and sign in with an emailed code.
Roast Log
Each roast records a target, a curve and a sensory evaluation. The curve is captured on a phone or imported from Artisan, then compared against a reference profile.
Features
- Sales: retail and wholesale pricing, partial payments, printable ticket.
- Store: checkout, customer account, coupons, reviews.
- Inventory: packaged and bulk stock by lot, with freshness.
- Production: roasts, shrinkage, blends.
- Cupping: blind multi-coffee sessions across tasters.
- Shipping: tracking and printable label.
- Finance: commissions, expenses, period results.
- Reports: by channel, product, customer and profitability.
Technologies
- Next.js 16
- React 19
- TypeScript
- Supabase
- PostgreSQL
- Row Level Security
- Mercado Pago
- React Query
- Tailwind CSS 4
- shadcn/ui
- Zod
- Vitest
- Vercel
