Case 4
End-to-End Booking Flow
Search, hold, pay, confirm — orchestrated with sagas and clear compensation if payment fails.
Step-by-step walkthrough
Read path — search and browse
- ① Browse / filter — Guest runs date, price, and location filters against the Search API.
- ② Query index — Search API queries Elasticsearch inverted index — never scans inventory rows.
- ③ Cache hit — Hot listing cards served from Redis when the same queries repeat.
- ④ GET listing detail — Guest opens a listing page; photos and description from search index or cache.
Write path — hold, pay, confirm
- ⑤ POST /hold — Guest reserves a slot; Booking API starts a short transaction.
- ⑥ Lock slot — Inventory row locked in PostgreSQL (SELECT FOR UPDATE or serializable isolation).
- ⑦ POST /confirm — Guest submits payment with Idempotency-Key to prevent double charge on retry.
- ⑧ Charge card — Booking API calls Stripe; payment success required before confirm.
- ⑨ Confirm → COMMIT — Hold converted to sale in one atomic transaction.
- ⑩ booking.confirmed — Event published to Kafka after commit (outbox pattern).
- ⑪ Async index update — Consumer updates Elasticsearch availability — derived data, not dual-write.
sagaStripeElasticsearchPostgreSQLcompensationKafkaAPI gatewayQPS