Design: Availability Checking System
Design covers availability checking, booking, cancellation, and notification. Out of scope: payment processing, user authentication, and detailed UI design.
Functional Requirements
Non-Functional Requirements
Jump into concepts and practice - no test required
+-------------+ +----------------+
| Clients | <------> | API Gateway / |
+-------------+ | Load Balancer |
+-------+--------+
|
+----------------------+--------------------+
| |
+---------v---------+ +---------v---------+
| Availability | | Booking Service |
| Service (Cache + | | (Handles booking, |
| DB) | | cancellation) |
+---------+---------+ +---------+---------+
| |
| |
+---------v---------+ +---------v---------+
| Cache (Redis) | | Database (SQL or |
| for fast reads | | NoSQL with strong |
+-------------------+ | consistency) |
+---------+---------+
|
+---------v---------+
| Message Queue |
| (Notifications) |
+---------+---------+
|
+---------v---------+
| Notification |
| Service |
+-------------------+booked_rooms = [101, 102, 103] and a requested room requested_room = 104?booked_slots = {"9AM": True, "10AM": False}
requested_slot = "10AM"
if not booked_slots.get(requested_slot, False):
print("Slot Available")
else:
print("Slot Booked")def is_available(stock, requested):
if requested > stock:
return True
else:
return False
print(is_available(5, 10))