Skip to content

Commit feb2b81

Browse files
SH20RAJclaude
andcommitted
feat: TableTap M0 prototype and plan
QR-at-the-table ordering for Indian restaurants: PLAN.md (users, features, data model, order state machine, realtime, multi-tenancy, payments, milestones, risks, pricing hypothesis) and a working Next.js prototype. - src/domain: menu, cart, order state machine, table state, bill with GST, tip and exact paise split, UPI intent link, day report (Vitest) - in-memory store seeded with demo restaurant Juniper Kitchen, 6 tables - guest, staff, kitchen and owner screens polling the API every 2.5 s - CI: typecheck, lint, test, build Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0 parents  commit feb2b81

64 files changed

Lines changed: 9973 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Checks on every push to main and every pull request: install, typecheck, lint, test, build.
2+
# Never deploys.
3+
name: CI
4+
5+
on:
6+
push:
7+
branches: [main]
8+
pull_request:
9+
branches: [main]
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: ci-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
check:
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 20
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v7
25+
26+
- name: Set up pnpm
27+
# Version comes from the packageManager field in package.json.
28+
uses: pnpm/action-setup@v6
29+
30+
- name: Set up Node.js
31+
uses: actions/setup-node@v7
32+
with:
33+
node-version: 22
34+
cache: pnpm
35+
36+
- name: Install dependencies
37+
run: pnpm install --frozen-lockfile
38+
39+
- name: Typecheck
40+
run: pnpm typecheck
41+
42+
- name: Lint
43+
run: pnpm lint
44+
45+
- name: Test
46+
run: pnpm test
47+
48+
- name: Build
49+
# Webpack for parity with local builds (some dev machines cannot load native SWC/Turbopack).
50+
run: pnpm build
51+
env:
52+
NEXT_TELEMETRY_DISABLED: 1

‎.gitignore‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
42+
43+
# local env
44+
.env*
45+
!.env.example

‎AGENTS.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# AGENTS.md
2+
3+
Rules for anyone (people or coding agents) changing this repository.
4+
5+
## What this is
6+
7+
TableTap, a QR table-ordering prototype for Indian restaurants. Read [README.md](README.md) for how to run it and [PLAN.md](PLAN.md) for the product plan and milestones. Current milestone: M0 done, M1 next.
8+
9+
## Ground rules
10+
11+
- Use pnpm. Pin exact versions for new dependencies, and only versions released more than a day ago (pnpm enforces a minimum release age here).
12+
- `dev` and `build` must keep `--webpack`; some machines cannot load native SWC/Turbopack.
13+
- This is Next.js 16 (App Router). Route handler and page `params` are Promises. When unsure about an API, read the docs shipped in `node_modules/next/dist/docs/` rather than relying on memory.
14+
- Before you push: `pnpm typecheck && pnpm lint && pnpm test && pnpm build` must pass. CI runs the same steps.
15+
- Push to `main` only through normal commits. Never force-push. No hosting or paid services without the owner's approval.
16+
- Never commit secrets, API keys or `.env` files. Payment keys (M2) come from environment variables only.
17+
18+
## Code rules
19+
20+
- Business rules live in `src/domain/` as pure functions with Vitest tests next to them (`*.test.ts`). No React, Next.js or I/O imports there.
21+
- Money is integer paise everywhere. Use `src/domain/money.ts`; never use floating rupees for totals.
22+
- Order status changes go through `transitionOrder` in `src/domain/order.ts`. Add new states or transitions there first, with tests.
23+
- Table state is derived (`deriveTableState`), never stored.
24+
- Route handlers stay thin: parse and validate input (`src/server/http.ts`), call the store, return JSON. Errors that the user should see are `StoreError` with an HTTP status.
25+
- The guest is untrusted. Prices, totals and amounts are always computed on the server from the menu and orders, never taken from the request.
26+
- UI: plain CSS in `src/app/globals.css`, mobile first, brand colours ink `#101828`, accent `#465FFF`, light accent `#8A99FF`, canvas `#F7F8F5`. Every control needs an accessible name; keep touch targets at least 36 px.
27+
- Be honest in copy and docs: no invented customers, metrics or market numbers. Demo data must be labelled as demo.
28+
29+
## Commits
30+
31+
- Conventional-style subjects (`feat:`, `fix:`, `docs:`, `test:`, `chore:`).
32+
- Commits made by an agent end with the line `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`.

‎PLAN.md‎

Lines changed: 194 additions & 0 deletions
Large diffs are not rendered by default.

‎README.md‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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.

‎eslint.config.mjs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
import nextVitals from "eslint-config-next/core-web-vitals";
3+
import nextTs from "eslint-config-next/typescript";
4+
5+
const eslintConfig = defineConfig([
6+
...nextVitals,
7+
...nextTs,
8+
globalIgnores([".next/**", "out/**", "build/**", "next-env.d.ts"]),
9+
]);
10+
11+
export default eslintConfig;

‎next.config.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
reactStrictMode: true,
5+
poweredByHeader: false,
6+
};
7+
8+
export default nextConfig;

‎package.json‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "tabletap",
3+
"version": "0.1.0",
4+
"private": true,
5+
"description": "QR-at-the-table ordering, kitchen display and pay-at-table for Indian restaurants and cafes. Prototype.",
6+
"scripts": {
7+
"dev": "next dev --webpack",
8+
"build": "next build --webpack",
9+
"start": "next start",
10+
"lint": "eslint",
11+
"typecheck": "next typegen && tsc --noEmit",
12+
"test": "vitest run"
13+
},
14+
"dependencies": {
15+
"next": "16.4.6",
16+
"react": "19.3.0",
17+
"react-dom": "19.3.0"
18+
},
19+
"devDependencies": {
20+
"@types/node": "^20",
21+
"@types/react": "^19",
22+
"@types/react-dom": "^19",
23+
"eslint": "^9",
24+
"eslint-config-next": "16.4.6",
25+
"typescript": "^5",
26+
"vitest": "^5.1.0"
27+
},
28+
"packageManager": "pnpm@11.28.6",
29+
"engines": {
30+
"node": ">=20.9"
31+
}
32+
}

0 commit comments

Comments
 (0)