SuryanandHome

Restaurant Reservation (OpenTable–class)

Problem statement

Search restaurants, available tables by time party size, hold slot, confirm with payment hold, waitlist, no double booking across POS integration.

How it works

  • Inventory = discrete slots (table combinations) or capacity buckets per time window.
  • Hold with TTL similar to ticketing; sync to in-house POS for ground truth tables.

Analogy: Airline seats but tables turn every 90 minutes and party size changes which “seat map” fits.

High-level design

Rendering diagram…

Components explained — this design

ComponentWhat it isWhy we use it here
Booking APIValidates party size, time, restaurant rules.Encapsulates policy (max party, blackout dates).
PostgreSQL inventoryTables/slots and booking rows.Unique constraints prevent double booking at commit time.
Redis hold TTLTemporary soft lock on slot.Improves UX with hold without keeping SQL transactions open during user payment typing.
Stripe auth holdReserve funds / card check.Reduces no-shows and card testing fraud.
POS webhookInforms online system of table merges/breaks.Ground truth for physical restaurant chaos.

Shared definitions: 00-glossary-common-services.md

Low-level design

Modeling tables

  • Table entities with min_party, max_party, combinable_with for joinable tables.
  • Time slots materialized or generated — index (restaurant_id, slot_start).

Concurrency

  • Transaction: UPDATE slots SET booked=true WHERE id=? AND booked=false — single row hot; partition by restaurant acceptable.

Walk-ins vs reservations

  • Overbooking model statistical risk — explicit business rule with compensation policy.

Notifications

  • SNS SMS reminders 24h; ICS calendar email attachment.

E2E: book 7pm party of 4

Rendering diagram…

Tricky parts

ProblemSolution
POS says table brokenWebhook cancels slot; notify user + reoffer alternatives
Google Maps busy integrationPopularity signal not authoritative inventory
Fraud bookingsCard auth + device fingerprint

Caveats

  • No-show fees — legal disclosure + local consumer laws.
  • Accessibility requests — metadata not just party size.

Azure

  • Azure Communication Services SMS; SQL elastic pools per city shard.