|
| 1 | +# TableTap |
| 2 | + |
| 3 | +Scan, order, track and pay at the table. TableTap is a QR-at-the-table ordering system for Indian restaurants and cafes: guests open the menu from a QR code (no app), order from their phone, follow their food, call a waiter, split the bill, tip and pay by UPI, card, cash or bank transfer, then leave a one-tap review. Staff get a live floor map, the kitchen gets a station display with timers, and the owner sees today's numbers. |
| 4 | + |
| 5 | +> **Status: prototype (milestone M0). In-memory, not production.** All data lives in server memory and resets on restart. Payments are simulated: nothing is charged and no email is sent. "Juniper Kitchen" is a made-up demo restaurant. |
| 6 | +
|
| 7 | +The plan, data model, payments approach and milestones are in [PLAN.md](PLAN.md). |
| 8 | + |
| 9 | +## What works in the prototype |
| 10 | + |
| 11 | +- `/` overview with links to every demo view. |
| 12 | +- `/t/t1` … `/t/t6` guest view: menu by category with photo placeholder, price, half/full sizes, allergens, spice level, veg mark, deals and sold-out items; veg-only and allergen filters; cart with notes; place order; order status with progress and estimated time; call waiter; bill with GST, tip presets and even split; pay share by share (UPI deep link, card, cash, bank transfer, simulated); review after paying. |
| 13 | +- `/staff` live floor map (free, ordering, eating, needs help, bill requested), service requests, incoming orders with "Send to kitchen", cancel and "Mark served", reset demo. |
| 14 | +- `/kitchen` orders by station with elapsed timers and late highlighting, start cooking, mark ready. |
| 15 | +- `/owner` tables in use, orders, items sold, money collected, tips, average rating, top dishes and latest reviews since midnight IST. |
| 16 | + |
| 17 | +Screens poll the API every 2.5 seconds (owner every 5). Open a table on your phone or in one tab and `/staff` and `/kitchen` in others to see updates move between them. |
| 18 | + |
| 19 | +## Run it |
| 20 | + |
| 21 | +Requirements: Node.js 20.9 or newer and pnpm (the version is pinned in `package.json` under `packageManager`). |
| 22 | + |
| 23 | +```bash |
| 24 | +pnpm install |
| 25 | +pnpm dev # http://localhost:3000 |
| 26 | +``` |
| 27 | + |
| 28 | +Other commands: |
| 29 | + |
| 30 | +```bash |
| 31 | +pnpm test # Vitest unit tests (domain rules and store flow) |
| 32 | +pnpm typecheck # next typegen, then tsc --noEmit |
| 33 | +pnpm lint # ESLint (next core-web-vitals + typescript) |
| 34 | +pnpm build # production build |
| 35 | +pnpm start # serve the production build |
| 36 | +``` |
| 37 | + |
| 38 | +`dev` and `build` use webpack (`--webpack`) because one of our development machines cannot load the native SWC/Turbopack binaries. |
| 39 | + |
| 40 | +To try it from a phone on the same Wi-Fi, run `pnpm dev -H 0.0.0.0` and open `http://<your-computer-ip>:3000/t/t1`. |
| 41 | + |
| 42 | +## Folder map |
| 43 | + |
| 44 | +``` |
| 45 | +src/ |
| 46 | + domain/ Pure business rules, no framework code. Unit tested. |
| 47 | + money.ts Paise helpers and INR formatting (Indian digit grouping) |
| 48 | + menu.ts Menu, items, variants, allergens, spice, stations, deals |
| 49 | + cart.ts Cart editing and validated order items (price snapshots) |
| 50 | + order.ts Order state machine, status events, estimated ready time |
| 51 | + table.ts Tables, sessions and derived floor-map state |
| 52 | + service.ts Call-waiter / bill requests and reviews |
| 53 | + bill.ts Bill totals, GST, tip, even split with exact paise, share payments |
| 54 | + upi.ts UPI intent link builder |
| 55 | + report.ts Owner's day summary |
| 56 | + time.ts IST start of day |
| 57 | + server/ |
| 58 | + seed.ts Demo restaurant "Juniper Kitchen", 6 tables, menu |
| 59 | + store.ts In-memory store (replaced by Postgres in M1) |
| 60 | + http.ts, parse.ts JSON handling and input validation for route handlers |
| 61 | + app/ |
| 62 | + api/ Route handlers (tables, orders, requests, staff, owner, demo reset) |
| 63 | + t/[tableId]/ Guest page |
| 64 | + staff/ kitchen/ owner/ Restaurant screens |
| 65 | + components/ Client components for each screen |
| 66 | + lib/live.ts Polling hook, clock, POST helper |
| 67 | +PLAN.md Product and technical plan |
| 68 | +AGENTS.md Rules for contributors and coding agents |
| 69 | +``` |
| 70 | + |
| 71 | +## API (prototype) |
| 72 | + |
| 73 | +| Method | Path | Body | |
| 74 | +| --- | --- | --- | |
| 75 | +| POST | `/api/tables/{tableId}/join` | none; returns `{ sessionId }` | |
| 76 | +| GET | `/api/tables/{tableId}?session={sessionId}` | guest view | |
| 77 | +| POST | `/api/tables/{tableId}/orders` | `{ sessionId, cart: [{ itemId, variantId, qty, note? }] }` | |
| 78 | +| POST | `/api/tables/{tableId}/requests` | `{ sessionId, kind: "waiter" \| "bill" }` | |
| 79 | +| POST | `/api/tables/{tableId}/bill` | `{ sessionId, tipPercent, splitCount }` | |
| 80 | +| POST | `/api/tables/{tableId}/bill/pay` | `{ sessionId, partIndex, method, receiptEmail? }` | |
| 81 | +| POST | `/api/tables/{tableId}/review` | `{ sessionId, rating, comment? }` | |
| 82 | +| GET | `/api/staff` | floor, active orders, open requests | |
| 83 | +| POST | `/api/orders/{orderId}/status` | `{ to }` | |
| 84 | +| POST | `/api/requests/{requestId}/resolve` | none | |
| 85 | +| GET | `/api/owner` | today's summary | |
| 86 | +| POST | `/api/demo/reset` | none; re-seeds the demo | |
| 87 | + |
| 88 | +There is no authentication in the prototype. Do not expose it on the public internet with real data. |
0 commit comments