HLD - Booking System
- Published on
- -2 mins read
- Authors
- Name
- Krishankant
Functional Requirement -
- Users should be able to see hotels / flights lists and their details
- Users should be able to search for hotels based on parameters like location, name etc
- Users should be able to book tickets for selected hotel
Not considered (less important)
- Notification/Payments/ etc. are separate service that is ready to use
- Admin side of the system
- AI/ML based search or recommendation services
Non-Functional Requirements -
- System should have low latency specially the search service ( < 500ms )
- System should focus on
- high availability for services like search, event/flight/movie details
- high consistency for booking service
Database Entites -
- Events ( / Hotels / Movies )
- Users
- Venues
- Seats ( id, venue_id, seat_number, seat_type_id, )
- SeatType
- Performers
- Bookings
- Tickets
API Schema -
- GET:
/events/:eventId
Response : - eventId
- venue
- performer
- seatMap
- GET:
/events/search?keyword={keyword}&start={startDate}&end={endDate}&pageSize={page_size}&pageNumber={page_number}
Response:
-
List
[ events ]
-
POST:
/bookings/:eventId
-
list
<seatId>
-
paymentConfirmationDetails
💡 Note:
If a system doesn't have compliance for handling credit card info then it should not take customers CC details, rather it should generate url for payment gateway which takes payemen.
High Level Architecture Diagram
✳️ open image in new tab to view in large
Deep Dive
-
How to ensure double booking ?
Answer
: We will use isolation_level = REPEATABLE_READ while running booking query -
How to ensure other user doesn't books the seat while a user is in process of booking it ?
Answer
: There are two ways - user "RESERVED" as status and a expireAt columns in seat table to make it unavailable for sometimes. Other ways is to use distributed locks through caching servers like - Redis. -
How to improve search ?
Answer
: Use elastic search -
How payment will work ?
Answer
: We request to generate a url for payment-gateway, and the payment gateway handles the payment. Once payment is done, the payment gateway hits the webhook which updates the status of payment of booking system.