← Portfolio · Case · SaaS for coffee shops
UNNA: a system for take-away coffee shops
A take-away coffee shop needs to sell fast at the counter, take QR payments, invoice and keep register and stock under control, without paying for a system built for large restaurants. UNNA is that system, built with hexagonal architecture and more than 1,400 tests.
01The problem
Existing hospitality systems are built for large dining rooms: slow at the counter, awkward for a simple payment, overpriced for a coffee shop that mostly sells to go. Building something custom without architecture ends in a fragile POS where money depends on fragile code.
UNNA covers the full take-away cycle: catalog, counter POS, register and stock, Mercado Pago QR payments, electronic invoicing and pre-order with online payment.
02The architecture
A monorepo with the domain in its own package
A monorepo with NestJS, Prisma and PostgreSQL for the API and a Next.js web app. Business rules (pricing, orders, payments, stock) live in a dedicated domain package with hexagonal architecture: controllers are thin adapters and every money decision is tested first. More than 1,400 tests across domain, API and web, with CI on GitHub Actions on every PR.
Sessions and concurrency
Sessions use rotating single-use tokens: a reused token kills the session. Where two writers can collide —payments, stock, business settings— there are PostgreSQL row locks, not JavaScript promises.
03Mercado Pago payments
Each coffee shop charges through its own Mercado Pago account. A mistake here is not a bug: it is money landing in the wrong account, or a payment recorded twice.
Each shop connects its account through OAuth; tokens are stored encrypted. The Mercado Pago webhook signs each notification with HMAC, the signature is verified before touching the database, and every payment is recorded exactly once: retries, duplicates and out-of-order notifications converge to the same final state.
04Invoicing and stock
Electronic invoicing with ARCA requires gap-free, duplicate-free sequential numbering: the invoice number is issued behind a row lock, so two registers charging at the same time never produce the same number.
Pre-orders let customers pay online before picking up; peak-hour mode and the public order screen cover the counter stretch where the queue cannot stop.
05What it left
Result
Public demo running on Vercel, Render and Supabase. More than 1,400 tests and CI on GitHub Actions. The project's ODD document, with the literal request and logged decisions, is public: odd/tasks/unna-platform.md .
More of the work: Congreso Abierto (next) → · zk-secrets → · Algorithms I used and why →