03Case study

Mobile ordering system

From QR ordering to the kitchen pass to admin reports: the full flow for a restaurant.

Role
Solo: data model, API, front end, deployment
Year
2026
Type
Full-stack MVP
Deploy
Docker Compose: PostgreSQL + app + Nginx
CustomerScan table QRMenu / cartMy ordersPlace order
Kitchen board#A12 · 2Cooking#A13 · 4Ready#A14 · 1New
AdminRBAC
  • 3role-specific interfaces
  • 11Prisma data models
  • 16API routes
  • 4Vitest test suites

The problem

Ordering in a small restaurant involves three groups at once: customers want to order from their table and see progress, the kitchen needs new orders immediately, and the owner manages menus, tables and staff permissions while watching the numbers. All three look at the same data, so totals and statuses must agree and no side should be able to tamper with them.

Features

Customers

Scan the table's QR code (or type the table number if the camera is unavailable), browse the menu, pick options, check out, and watch "My orders" update on its own.

Kitchen

A live board that polls every 5 seconds, lists orders by status and moves them along.

Admin

Categories, products, option groups, tables and users, plus an operations dashboard and report charts.

Architecture

Mobile ordering system architecture DOCKER COMPOSECustomer phonescan · order · trackKitchen boardpolls every 5 sAdmin consolemenu · reportsNginxreverse proxyMiddlewareJWT (jose) authRBAC guardNext.js 14 App Routerpages + 16 API routesService layer + Zodserver-side pricing · option rulesorder state machinePrisma ORM11 data modelsPostgreSQL16
Every request passes identity and permission checks in middleware; business rules live in the service layer behind Zod validation.

Key design decisions

01

Only the server sets prices

Orders are priced from product and option prices read from the database at creation time; totals sent by the client are ignored, and products must belong to the store and be on sale.

02

Option rules enforced on the back end

Each option group has min/max selections and a required flag; violations return structured errors with codes such as OPTION_RULE_VIOLATION.

03

An order state machine

NEW → PREPARING → COMPLETED, cancellable before completion; COMPLETED and CANCELLED are terminal and illegal transitions are rejected.

04

RBAC

7 permissions and 3 preset roles: ADMIN has everything; MANAGER runs menu, tables, orders and reports; STAFF handles orders only.

05

A reproducible environment

Docker Compose waits for a healthy database, then runs generate → migrate deploy → seed → start; the seed rebuilds demo data and is safe to re-run.

06

Tested on real phones

An Nginx reverse proxy lets phones on the same Wi-Fi connect directly and walk through the QR ordering flow.

Quality

TypeScript type checks, ESLint, and four Vitest + Testing Library suites covering the auth guard, order service, orders API and report service.

Stack

  • Next.js 14
  • React 18
  • TypeScript
  • Prisma 5
  • PostgreSQL 16
  • Zod
  • jose (JWT)
  • bcryptjs
  • Tailwind CSS
  • Recharts
  • html5-qrcode
  • Vitest
  • Docker Compose
  • Nginx