Design a Hotel Reservation System with Search, Booking and Notifications
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Other
Design a hotel reservation system similar to Airbnb or Booking.com. The system should allow users to search, create, manage, and retrieve hotel reservations.
Functional requirements:
1. Hotel and room management: add and remove hotels and room types, and update room-type pricing and inventory.
2. Search and reservation: filter by location, beds, price range, and dates, and create or cancel reservations.
3. Reservation history: view past reservations with details like dates, hotel, room type, and price paid.
4. Notifications: send confirmations and cancellation alerts via in-app, email, or push.
Define the non-functional requirements yourself. Example starting points are listed under the constraints below.
```hint What a booking consumes
Decide whether a booking takes a specific physical room or one unit of a room type on each night of the stay. That choice determines which rows two competing bookings fight over.
```
```hint Two paths
Compare how often users search with how often they book, and ask which of the two can tolerate results that are a few seconds old.
```
```hint Retries
A client that times out on the booking request will send it again. Work out how the server recognizes the second request as the same booking.
```
### Constraints & Assumptions
- Example non-functional targets: availability favored over consistency, page loads under 300 ms, and 99.9% uptime. The list is open-ended, so add the targets your design needs.
- Scale is not specified. State your assumptions for peak search and booking rates before sizing anything.
### Clarifying Questions to Ask
- Does a guest book a room type, with the hotel assigning the physical room at check-in, or a specific room?
- Is payment in scope, and must a room be held while the guest pays?
- What peak search and booking rates, and how many regions, should the design handle?
- Is overbooking ever allowed, or must a room-night never be sold twice?
- Does a cancellation return the room to inventory immediately, and do cancellation policies or refunds matter here?
### What a Strong Answer Covers
- Requirements and targets, including which operations can trade consistency for availability and which cannot.
- A data model that represents availability and pricing per date and records what each guest paid.
- An API covering hotel management, search, booking and cancellation, including safe retries of a booking request.
- A high-level architecture that shows how search and booking are served and scaled differently.
- How double booking is prevented under concurrent requests, and how the asynchronous parts (onboarding, indexing, notifications) recover from failures.
### Follow-up Questions
- How would you hold a room while the guest completes payment, and release it if they abandon checkout?
- The search results say a room is available but the booking fails. How do you keep the search index in sync, and what does the user see?
- Thousands of guests try to book the same hotel for the same weekend within a minute. Where does the design bottleneck, and how do you relieve it?
- How would you change the dates on an existing reservation without losing the original booking if the new dates are full?
Overview: Design a hotel reservation system where managers list hotels and room types and guests search by location, dates and price, then book or cancel rooms. It tests per-night inventory modeling, preventing double bookings under concurrent requests, idempotent booking APIs, and keeping a search index in sync with the database.