If you were the system architect of Airbnb, how would you design the system?

First, you must understand the functional and non-functional requirements of the nature of the business. Airbnb is an online platform that connects individuals looking to rent out their homes with people looking for short-term accommodation and rooms.

functional requirements

1. Landlord

Hotel managers on the platform enter data into the system about hotels and their availability, as well as customers who want to book hotel rooms. Hotel managers here refer to landlords who wish to rent out rooms on a short-term basis.

• Ability to register hotels on the platform • Add/update/delete room types for hotels • Add/update/delete rooms for a given room type • Define price and inventory of room types on a daily basis

2. User/Customer

1. Ability to search available hotels by city, check-in date and check-out date 2. Ability to select a hotel and see all available hotel types and their prices 3. Ability to select the desired room type and proceed with the booking 4. Receive information about the booking after the booking is completed Notification of details

non-functional requirements

1. The system that handles the operations related to hotel managers and booking process must be highly consistent 2. The discovery platform for displaying hotels to customers should be highly available 3. The system should have low latency 4. The system should be highly scalable to handle the number of hotels and increase in the number of new customers 5. The system should be able to handle concurrent requests to ensure that no two customers can book the same room on the same day

We can prepare a high-level diagram and database schema or entity design.

8ac0b0052523d8f81bc9224bea170ae1.png
 
99551fb7c66214cdcfbc81bf3bbf229c.png
54f6d8ee7a66df606a5519d95da85ecb.png
 
01d44960c2557cd6f62c88bbd0075d74.png
 
2ed387be11ca92368d00ff4b6dc80814.png
 
56a51e42baf6881d19bccec04247e7cf.jpeg
 
9c3b8e704b48a73f54060d2956ad6861.jpeg
 
cea99d4e56aa0ec6d65f0020c0f300fc.png
 
1250b0f2fb399c533637c1a234038195.png
 

Let’s identify the core REST API that will be used for this system

1. Register the hotel POST /hotel/Register 2. Add the room type to the hotel POST /hotel/{hotel_id}/room-type 3. Add the room to the hotel POST /hotel/{hotel_id}/room-type/{room_type_id} /room 4. Return a list of nearby hotels GET /hotels/location/{location_id} 5. Return its detailed information according to the hotel GET /hotel/{hotel_id} 6. Book a hotel room POST /booking 7. Return the user's reservation GET /user /{user_id}/bookings 8. Return to hotel reservation GET /hotel/{hotel_id}/bookings 9. Check-in PUT /booking/{booking_id}/check-in 10. Check-out PUT /booking/{booking_id} /check-out

API 1, 2, and 3 will be part of the hotel management service .

APIs 4 and 5 will be part of the discovery platform .

API 6, 9, and 10 will be part of the booking service .

API 7 and 8 will be part of the booking history service .

Hotel Manager API

•The hotel manager will manage the details about the hotel, room types and prices. • The hotel manager will post the details and update the system to get the hotel's availability, which will send an event to an asynchronous queue which will then be consumed by the AWS Lambda function for search purposes. •Users/customers can search for hotels and select preferred room types. •Users can check their booking history through this account.

More exciting~

Guess you like

Origin blog.csdn.net/weixin_37604985/article/details/132614079