Architecture
How bookingio is built
One Next.js codebase on Vercel. The pages are React; the backend is a set of route handlers under /api that run as serverless functions. Domain logic lives in /server and never ships to the browser.
- 1
Search
Travellers describe a trip in plain words. Claude turns the request into a typed query; if no key is set or the answer is unusable, a rule parser does it instead.
POST /api/search · JSON-schema output · validation
- 2
Availability
Trip pages ask every supplier in parallel: a bedbank for hotels, a channel manager for the ryokan, the operator's own coaches. Each call has its own timeout, so one slow supplier never blocks the page.
Promise.all · per-supplier timeout · latency per row
- 3
Pricing
The browser sends choices, never prices. The server prices the tour, supplements, extras and signed fare offers, applies the deposit rule, and converts currency only for display and payment.
POST /api/quote · HMAC-signed fares · AUD base
- 4
Booking
Checkout holds seats as a signed token valid for 15 minutes, so any serverless instance can verify it. Pay runs a saga that streams each step and undoes earlier steps if a later one fails.
Stripe test mode or mock · Amadeus or mock GDS · NDJSON stream
- 5
Day of travel
A door camera counts guests at every stop and the server compares the count with scans and the manifest. Guest messages are read for intent, such as skipping a day and rejoining later.
Edge device + MQTT in production · deterministic simulation here
- 6
Settlement
A confirmed change becomes a priced change set, with supplier cancellation rules stored as data. Supplier calls stream back with idempotency keys, and messages are drafted in each reader's language.
Rules as data · streamed supplier calls · drafted messages
The booking saga
What runs when a traveller presses Pay. Try the “make a supplier step fail” option at checkout to watch the undo steps.
// server/saga.ts (simplified)
const steps: Step[] = [
{ name: 'payment', run: () => pay.authorize(due, currency, ref), undo: id => pay.cancel(id) },
{ name: 'seats', run: () => inventory.confirm(hold), undo: () => inventory.release(hold) },
{ name: 'hotels', run: () => bedbank.book(rooms, { idempotencyKey }), undo: r => bedbank.cancel(r) },
{ name: 'stays', run: () => channelManager.book(stays), undo: r => channelManager.cancel(r) },
{ name: 'flights', run: () => gds.createPnr(itinerary, travellers), undo: r => gds.cancelPnr(r) },
];
for (const step of steps) {
emit({ type: 'step', name: step.name, status: 'run' });
try {
done.push(await step.run());
} catch (err) {
for (const d of done.reverse()) await d.undo(); // compensate in reverse
return emit({ type: 'error', message: err.message });
}
}
await pay.capture(paymentId);
emit({ type: 'done', booking });This deployment
Read live from /api/health. Add keys in Vercel's environment variables to switch any of these from simulation to the real service.
Checking the API…
Why count with a camera
- Scans show who was checked, not who stayed. On the Day of travel page, 36 passes were scanned and 35 people were on board.
- Groups lose people at rest stops, where nobody scans. The camera recounts every time the door opens.
- It works without faces. Body tracks stay on the device for ten minutes, long enough to match someone who steps off and back on, then they are dropped.
API
Every page above is built on these endpoints. GET links open the raw JSON.
| Method | Path | What it does |
|---|---|---|
| GET | /api/health | Which integrations this deployment runs with |
| POST | /api/search | Sentence or filters in, ranked trips out (Claude or rule parser) |
| GET | /api/trips | Every trip with priced departures |
| GET | /api/trips/JP-GR | Trip detail, itinerary and departures |
| GET | /api/trips/JP-GR/availability | Parallel supplier check with per-supplier timeouts |
| GET | /api/fares?trip=JP-GR&dep=1&origin=SYD&pax=2 | Signed fare offers from Amadeus or the mock GDS |
| POST | /api/quote | Server-side price for a set of choices |
| POST | /api/holds | Holds seats for 15 minutes as a signed token |
| POST | /api/bookings | Runs the booking saga, streamed as NDJSON |
| GET | /api/fleet?elapsed=5 | Door-camera headcount across six coaches |
| GET | /api/ops/boarding | Day-of-travel scenario with the guest message read for intent |
| GET | /api/ops/changeset | Priced change set and drafted messages |
| POST | /api/ops/changeset | Sends supplier calls, streamed as NDJSON |
| POST | /api/intent | Guest message to structured intent |
| POST | /api/assistant | Trip assistant answer with sources, or a hand-off |
| POST | /api/email | Supplier confirmation to checked fields and a reply |
| GET | /api/crowd | Crowd forecast by hour with a suggested slot |
| GET | /api/forecast?trip=JP-GR | Demand forecast and price recommendation per departure |
A change set, as the API returns it
Computed by server/ops.ts from supplier rules stored as data.
{
"id": "cs_7Q2M",
"booking": "KJ-4471",
"rate": 0.0101,
"lockedAt": "07:52",
"lines": [
{
"item": "Lake Ashi cruise ×2",
"supplier": "Sightseeing cruise · e-voucher",
"action": "Keep tickets",
"rule": "No refund inside 24 h",
"jpy": 0,
"call": null
},
{
"item": "Lunch at Sōun-tei ×2",
"supplier": "Restaurant · direct API",
"action": "Release 2 covers",
"rule": "Free release until 10:30",
"jpy": 7600,
"call": {
"method": "PATCH",
"path": "/adapters/restaurant/sountei/reservations/R-7781"
}
},
{
"item": "Ryokan Kiri no Yu, twin ×1",
"supplier": "Channel manager",
"action": "Cancel tonight",
"rule": "50% fee if cancelled before 15:00",
"jpy": 31000,
"call": {
"method": "POST",
"path": "/adapters/chanmgr/kirinoyu/bookings/KNY-20611/cancel"
}
},
{
"item": "Sora Kyoto Hotel, +1 night",
"supplier": "Bedbank",
"action": "Extend stay",
"rule": "Live rate, free cancel to 18:00",
"jpy": -24000,
"call": {
"method": "POST",
"path": "/adapters/bedbank/bookings/BB-88213/extend"
}
},
{
"item": "Nozomi Kyoto → Tokyo ×2, 4 Nov",
"supplier": "Rail aggregator",
"action": "Book 2 seats",
"rule": "Reserved, ¥14,170 each",
"jpy": -28340,
"call": {
"method": "POST",
"path": "/adapters/rail/orders"
}
}
],
"net": {
"jpy": -13740,
"aud": 138.77
},
"payer": "guest"
}