Restaurant Platform
Role: Solo developer. I designed and built both apps, the database schema, the tests, and the CI for both repos.
Code: restaurant-pos (Spring Boot POS and kitchen display) and waitlisted (Next.js guest kiosk and staff dashboard).
Design docs: kitchen latency measurement, payment plan (original draft; cash since built), kiosk implementation plan.
A POS and a guest kiosk sharing one database. Guests pre-order while they wait. When staff fire the order, it reaches the kitchen screen through a transactional outbox, Kafka, and a WebSocket push.
Problem
This started as a question. I work at a restaurant that runs Clover, and I wanted to know how hard it would be to build a replacement. restaurant-pos is the answer so far: orders, tables, PIN login, a kitchen display, and cash payments.
The second app came later. For a web development course (CPRG 306D), I built waitlisted, a host-stand kiosk where guests join the waitlist and build a pre-order from their phone while they wait. I wanted to try the pre-order idea, and the POS already had the menu, tables, and staff, so the kiosk is built on the POS database instead of its own.
That left the real design problem: two separate apps share one database, but only one of them should be allowed to change an order or a table.
Role
I built all of it alone, with no teammates. AI coding agents (Claude) wrote much of the code under my direction. I made the design decisions and decided what to build and what to merge. How that worked is below.
- restaurant-pos: the Spring Boot back end (orders and their status rules, tables, PIN login, menu, cash payments, order cancel), Flyway migrations, the transactional outbox and its Kafka relay, the Kafka consumer that drives the kitchen display, and the React POS and kitchen display.
- waitlisted: the Next.js kiosk and staff dashboard, the waitlist and pre-order flow, PIN login, and the POS client.
- Tests and CI: both repos run their tests on every pull request, and a passing run is required to merge.
How I worked with AI
AI makes plausible code and plausible docs cheap. So the part I own is the direction and the checks.
- Agents with roles and a contract. restaurant-pos defines agent roles in the repo: a planner, a back-end and a front-end developer, and two QA roles. Each role has its own files it may change, and all of them work from one shared API contract. See
agents/. - The decisions stay mine. For each design question I had Claude lay out the options with their pros and cons, sent it back for deeper research where the answer was not clear, and made the call myself. For the payment design, Claude interviewed me, and the plan records 19 of my decisions. See the payment plan (original draft; cash since built).
- Checking the docs against the code. A fact-check of both repos found that the READMEs described things the code did not have. waitlisted described a Kafka-to-WebSocket pipeline, but the kitchen push bypassed Kafka and the only consumer just logged. restaurant-pos claimed offline mode. I turned the findings into a phased plan and fixed the code, not just the words, in restaurant-pos PRs #27 to #36 and waitlisted PRs #8 to #15.
- Tests before code. The first PR of that plan only added tests of the fire path as it should behave (#27). Scenarios that failed on the code at the time were written and seen failing, then landed as the first commit of the fix that turned them green (#28). Later feature phases were built test-first, mostly one behavior per commit (#30).
- Checks outside the code the agents write. CI must pass to merge, a required check on both repos since November 2026. Several later PRs got a separate AI code review (Claude Code
/code-review) before merge, and the fixes landed in the same PR (waitlisted #12, #14, #15). Before trusting “fast”, I measured it. The rewritten README was fact-checked against the code by an independent agent (#36), and so was this page.
Architecture
Two apps share one PostgreSQL database. The Spring Boot POS owns the schema (Flyway) and the order state machine. The Next.js app reads the shared tables through Prisma and owns three tables of its own: waitlist_entries, pre_orders, and pre_order_items.
When staff fire a pre-order, the Next.js route asks the POS to create the order and then fire it. In the same database transaction as the fire, the POS writes an OrderFired row to its outbox. A relay publishes the row to Kafka. The KDS bridge, a Kafka consumer in the same Spring Boot app, reloads the order and pushes it over a STOMP topic on a WebSocket to the kitchen display. A browser cannot speak the Kafka protocol directly, so something server-side has to bridge the two.
Key Decisions
1. One database, one writer
- Context: The kiosk needs the menu, tables, and staff. The POS already has them.
- Options: Give the kiosk its own database and sync it. Have the kiosk call the POS API for everything. Share the database.
- Choice: Share the database, with a rule. The kiosk reads through Prisma. Seating, table status, and order create and fire go through the Spring Boot API. If the POS is unreachable, those routes return 503 and change nothing. There is no local fallback. A test in waitlisted fails the build if any source file writes to a POS-owned table through Prisma.
- Why: Reads stay simple and need no endpoints. Every write passes through the POS state machine, so every fire produces the outbox event and the kitchen push. Nothing changes an order or a table behind the POS’s back. See
spring-boot-client.ts.
2. A transactional outbox and Kafka in front of the kitchen display
- Context: The first version wrote to the database, published to Kafka, and pushed to the kitchen as three separate steps. A Kafka hiccup could fail a fire, and the only Kafka consumer just logged.
- Options: Push to the kitchen directly and drop Kafka. Publish to Kafka inside the request. Write events to an outbox table and publish them afterwards.
- Choice: The outbox. Fire and item status write an event row, and so does cancelling an order the kitchen already has, each in the same transaction as the change. A single relay thread publishes the rows to Kafka in order, oldest first, with an idempotent producer. The kitchen display’s Kafka consumer is now the only path to the screen. It reloads the current order and pushes it, so a duplicate or replayed event is harmless.
- Why: A fire never waits on Kafka and never fails because of it. If Kafka is down, orders wait in the outbox and reach the kitchen when it returns. I measured the cost before keeping it: fire to card on screen went from 16 ms (with the direct push already moved after the commit) to 22.5 ms at the median (worst 24 ms to 35 ms, 20 orders each, method and raw data). See
OutboxRelay.javaandKitchenDisplayService.java. - Limits: It assumes one backend instance. A row that keeps failing blocks every row after it, because later events must not overtake it. There is no failed state or backoff yet.
3. WebSocket push to an authenticated kitchen screen
- Context: A ticket has to appear without anyone refreshing a page, and only signed-in staff should see the feed.
- Options: Poll the API, server-sent events, or WebSockets.
- Choice: STOMP over WebSocket, with SockJS as the fallback transport. The kitchen display logs in with a kitchen user’s PIN and sends its token on the STOMP CONNECT frame. The server rejects a connection without a valid token and a subscription without a user.
- Why: Polling adds delay and load for a screen that is mostly idle. The waitlist side does poll, and that is fine for a host stand. The kitchen is different. See
WebSocketConfig.javaandKitchenDisplay.jsx.
4. Seating and firing are separate, and firing needs the user’s PIN again
- Context: A wrong ticket in the kitchen wastes food and time.
- Options: Fire a pre-order automatically when the guest is seated. Fire on one tap.
- Choice: Seating never fires. Firing is its own action, and the staff member re-enters their own PIN. The server checks it against the signed-in user only, so another staff member’s PIN is rejected. A guest who is not seated cannot be fired. The POS order id is saved as soon as the order is created, so a retry after a failed fire reuses that order instead of creating a second one.
- Why: A server gets a chance to confirm the order with the guest, and every fired ticket has a named person behind it. See
from-preorder/route.ts.
Results
- Fire to card on the kitchen screen: 22.5 ms median, 35 ms worst over 20 orders on my local Docker stack, warm. The first order after a backend restart took 84 ms. The numbers cover the POS side only, not the kiosk’s request to the POS.
- With Kafka stopped, a fire still succeeds and no ticket appears. When Kafka comes back, the ticket arrives. I checked this by hand on the Docker stack.
- restaurant-pos: 49 unit tests and 128 integration tests that run the app against a real PostgreSQL (Testcontainers) and an embedded Kafka, plus 36 frontend tests. waitlisted: 65 tests. CI runs all of them, and a green run is required to merge in both repos.
- Order status rules are enforced on the server: an order completes only through payment, and a cancel needs a reason and is refused while a payment is captured. Cash payments and cancel exist in the API only. The POS screens do not have buttons for them yet.
- Both apps run together locally:
docker compose upfor the POS stack, a one-timenpm run db:setup, thennpm run devfor the kiosk. The kiosk README walks through the full path: join the waitlist, pre-order, seat, fire, ticket on the kitchen display.
What is not done
- No POS in the cloud. Running Kafka and the POS around the clock costs more than I want to spend on a demo, and a public POS with PIN login would invite abuse while there is no PIN throttling. The kiosk can run without it, with seating and firing disabled. The recording above shows the full path on my local stack.
- One backend instance. The outbox relay and the WebSocket broker both assume it.
- Seating and firing are not atomic. Two staff firing the same pre-order at the same moment could create two POS orders. Seating takes two steps, and if the second one fails I fix the entry by hand.
- No PIN throttling. It has to come before any public deploy with a live POS.
Links
- Code: restaurant-pos, waitlisted
- Design docs: kitchen latency measurement, payment plan (original draft; cash since built), kiosk implementation plan, kiosk project description