Skip to content
miito.devThe Workshop · File 0176
Back to the register

Pho Kam Long — POS and kitchen display

An iPad point of sale and kitchen display for the restaurant, with its own server and a table-call device.

Directive
R-002
Class
Client
Role
Design and build
Client
Pho Kam Long
Period
Apr 2026 – Jun 2026
Status
In development
The POS on an iPad: the floor plan, a table's check, the kitchen display, takeaway and bookings.

The account§ 01

I'm building an iPad app in Expo and React Native for the restaurant's floor. It takes orders at the table and runs checks, takeaway and reservations. A kitchen display times every ticket from the moment it's fired.

Behind it is a Fastify server with PIN sign-in, roles and an audit log, plus a sync layer so the iPads can keep working when the Wi-Fi drops. A small gateway written in C lets a table call for service. The call shows on the floor plan until someone answers it.

Outcomes

  • Floor plan, checks, takeaway, reservations and waitlist on the iPad.
  • Kitchen display with live ticket times.
  • PIN sign-in with roles, lockout and an audit log.
  • Offline-first sync between the iPads and the server.
  • Table-call alerts from a firmware gateway, relayed over MQTT and WebSocket.

Timeline

  1. POS app begun
  2. Staff sign-in and roles
  3. Kitchen display timing
  4. Offline sync
  5. Table-call alerts

In figures§ 02

  • 5staff roles, from owner to kitchen
  • 3languages on the iPad
  • 200+commits on the POS app
  • Offlinefirst: orders are kept on the iPad and synced after

Why§ 03

I started working with Pho Kam Long around December 2024. The restaurant had no website and little brand recognition, and the goal was to bring it up to date. Print came first, then the website, and in April 2026 the system it runs service on.

That began as a reservations app for the front desk. Within two weeks it was clear that the bookings, the floor and the checks are one thing. A reserved table is a table that will be seated, ordered on and paid. So I retired the reservations app and built the POS in its place, with the floor plan at the centre and everything else reached from a table.

The menu it sells from is the one the website shows, read from the restaurant's Sanity studio, so a price is changed in one place. And a restaurant's Wi-Fi drops in the middle of service. So the first rule was that the iPad keeps working when it can't reach the server, and catches up when it can.

What it does§ 04

  1. Floor plan

    Every table by area, dining, bar and patio, marked seated, open, to clean or reserved, with its guests, time and running total.

  2. Checks

    Orders taken by seat and by course, fired to the kitchen, split, and paid.

  3. Kitchen display

    Tickets by station, timed from the moment they are fired, marked done from the line.

  4. Takeaway

    Pickup and delivery orders on a board from pending through preparing to ready.

  5. Bookings

    The day's reservations on a timeline, with a waitlist that counts the wait live.

  6. Staff sign-in

    A PIN per person, roles that decide what they can do, lockout after failed tries and an audit log.

  7. Table call

    A button at the table that calls for service; the call shows on the floor plan until someone answers it.

  8. Floor editor

    The room laid out by hand in an edit mode: tables placed, selected together or removed, and the layout saved when the editor closes.

  9. Three languages

    English, French and Vietnamese, chosen in settings and kept on the iPad, with prices formatted for each.

Where it got hard§ 05

  1. Working offline
    Problem
    A till that needs the server for every tap stops the whole floor when the Wi-Fi drops. My first version was worse than that. Its stores reseeded from fixtures, so a reload lost the order.
    Solution
    First I persisted the stores on the iPad and resynced their sequence numbers after hydration, so a reload loses nothing. Then I built the server half of a sync layer. It has a transactional outbox and a sync_log table filled by triggers on orders and reservations. Pulls read from a cursor scoped to the restaurant. Pushes are idempotent, with tombstones and a clock-drift guard. Tests prove it end to end. I kept the contract narrow on purpose: status changes and soft deletes only. The iPad half is planned but not built yet. It's a SQLite store with its own outbox, so a change queues locally and goes up when the link returns. Creating an order offline comes after that.
  2. Ticket times you can trust
    Problem
    The kitchen display colours a ticket by how long it has waited. The floor plan shows how long a table has been seated. Timers that read the clock on every render drift and drain. And there's no way to test what they show at eleven at night without waiting for eleven at night.
    Solution
    Nothing in product code calls Date.now(). There's one injectable clock. A ticket records the moment it was fired, and the display works out the elapsed time from that once a second. The dev HUD can wind the clock forward, so I can check the colours and countdowns without waiting.
  3. A four-digit PIN that's still secure
    Problem
    A PIN pad is the only sign-in staff will accept at a till, and four digits can be guessed in minutes. There was a smaller bug too. The lockout countdown on the iPad drained instantly, because it ticked once per render instead of once per second.
    Solution
    The server hashes PINs with Argon2id. It runs a pure lockout state machine scoped to a persistent device id, hands out opaque session ids in cookies, and writes every override to an audit log. On the iPad, an auth request times out, so a flaky connection can't hang the sign-in screen. The countdown now runs on an interval of its own.
  4. A button on the table
    Problem
    A call for service has to work without an app, on a battery, over a radio link that drops bytes. And it still has to be answered from the floor plan.
    Solution
    The firmware is in C. Each message is a fixed fourteen bytes: type, table, intent (water, server, bill, cancel), sequence, battery and signal strength, with a CRC-8 at the end. Decoding checks only the version, length and CRC, so an unknown value passes through. That keeps it forward compatible. A fixed-capacity alert table holds the calls, with an escalation sweep over it. The gateway relays the calls over MQTT to the server. The server broadcasts them to the iPads over WebSocket and relays the acknowledgement back. I built and tested all of it on the desk with PlatformIO's native test runner. That's where I caught a slot leak, and the fix became a rule: only a press may open a slot.

Screens§ 06

  • Fig. 1The floor plan
  • Fig. 2A table's check
  • Fig. 3Kitchen display
  • Fig. 4Takeaway board
  • Fig. 5Bookings
  • Fig. 6Sign in by PIN

How it fits together§ 07

The iPads keep working when the network drops and catch up when it returns.

  1. Table call deviceFirmware in C, CRC-checked messages
    MQTT
  2. Fastify serverStaff auth, orders, a sync log in Postgres
    WebSocket · sync
  3. iPad POS and KDSExpo and React Native, an offline store

Where it stands§ 08

It's in use on the floor at the restaurant, and I'm still building it. Sign-in, the floor, checks, the kitchen display, takeaway, bookings and the table call all work end to end against the server. The server already verifies Moneris payment webhooks. Next up are the pay sheet on the iPad, kitchen printing and the reports screens.

What I learned§ 09

  1. Keep SQL behind repositories

    On the server, SQL lives only in repositories. That's why the sync pull and push, the auth module and the order domain all have tests that run without a device. The whole REST route table is asserted too, after the route autoloader once silently skipped two files.

  2. Inject the clock

    Banning Date.now() from product code sounded pedantic. Then it made every timer testable and every countdown correct.

  3. Build around the table, not the booking

    The front-desk app was the wrong boundary. The table is the unit. Bookings, seating, ordering and paying are all states of a table.

  4. Test on the real iPad

    toSorted crashed on the device and nowhere else, because Hermes isn't V8. The simulator isn't the iPad either. Nothing is done until it has run on the hardware.