LLD of booking application
Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2022-11-13
Problem Statement
Design a Booking Application that allows users to search, book, and manage reservations for resources such as hotels, events, or appointments. The focus is on object-oriented design, modularity, and handling availability and booking constraints.
✅ Functional Requirements
1.Resource Management
•Maintain a catalog of bookable resources (e.g., rooms, events, or slots).
•Each resource has attributes like id, name, type, capacity, and availability.
•Admins can add, remove, or update resources.
2.User Management
•Users can register, login, and manage profiles.
•Users can search resources based on type, date/time, location, or capacity.
3.Booking Management
•Users can book a resource for a specific time slot.
•System ensures resource availability before confirming a booking.
•Users can cancel or modify bookings.
•Track booking status: Active, Completed, Cancelled.
4.Payment (Optional)
•Payment can be associated with bookings.
•Track payment status (Paid / Pending).
🔐 Constraints & Assumptions
•Time slots represented as start and end timestamps.
•Thread-safety optional unless multiple users access the system concurrently.
•Focus is on LLD and OOP design, not UI or external payment integrations.
•System should prevent double-booking for the same resource and time slot.
🧱 Key Components & Classes
1.Resource Class
1
2class Resource {
3private:
4 int resourceId;
5 string name;
6 string type;
7 int capacity;
8 vector<TimeSlot> availability;
9public:
10 bool isAvailable(TimeSlot slot);
11 void updateAvailability(TimeSlot slot, bool status);
12};1.User Class
1
2class User {
3private:
4 int userId;
5 string name;
6 string email;
7public:
8 vector<Resource> searchResources(string type, TimeSlot slot);
9 Booking bookResource(Resource resource, TimeSlot slot);
10};1.Booking Class
1
2class Booking {
3private:
4 int bookingId;
5 User user;
6 Resource resource;
7 TimeSlot slot;
8 string status; // Active, Completed, Cancelled
9public:
10 void cancelBooking();
11 void modifyBooking(TimeSlot newSlot);
12};1.BookingSystem / Controller Class
1
2class BookingSystem {
3private:
4 vector<Resource> resources;
5 vector<Booking> bookings;
6public:
7 vector<Resource> searchAvailableResources(string type, TimeSlot slot);
8 Booking createBooking(User user, Resource resource, TimeSlot slot);
9 void cancelBooking(int bookingId);
10};1.TimeSlot Class
1
2class TimeSlot {
3private:
4 DateTime start;
5 DateTime end;
6public:
7 bool overlaps(TimeSlot other);
8};🔄 Example Workflow
1.User searches for available resources for a given date/time.
2.System returns resources that are available.
3.User books a resource → system verifies availability → booking confirmed.
4.User can cancel or modify the booking.
5.Admin can add or update resource details and availability.
🧪 Expected Deliverables
•Class diagram showing Resource, User, Booking, BookingSystem, and TimeSlot.
•Implementation of methods for searching, booking, cancellation, and availability checking.
•Test cases:
•Booking a resource successfully
•Preventing double booking
•Searching available resources for a given time slot
•Canceling and modifying bookings
💡 Discussion Points
•Trade-offs: array/list vs database storage for resources and bookings.
•Handling concurrent bookings to avoid conflicts.
•Extensibility: support multiple locations, recurring bookings, or dynamic pricing.
•Optional: integrating payment and notifications.