This project, Uber Low-Level System Design in Cpp, aims to simulate a simplified version of the ride-hailing service Uber using modern C++ features.
The primary objective behind this project is to deepen the understanding of low-level system design in C++, encompassing Object-Oriented Programming (OOP) principles, threading concepts, and modern C++ features such as Smart Pointers and the Standard Template Library (STL).
In this design, we have focused on creating a robust and maintainable codebase by incorporating two key design patterns: Singleton and Strategy. The Singleton pattern is employed to ensure that there is only one instance of crucial manager classes such as DriverMgr
, RiderMgr
, TripMgr
, and StrategyMgr
. This guarantees centralized management of drivers, riders, trips, and strategies, ensuring thread-safe access and preventing resource conflicts. The Strategy pattern is leveraged to encapsulate algorithms for pricing and driver matching. By defining a family of algorithms and making them interchangeable, the system can dynamically change its behavior without altering the client code. Classes such as DefaultPricingStrategy
, RatingBasedPricingStrategy
, and LeastTimeBasedMatchingStrategy
demonstrate the use of this pattern, providing flexibility and scalability to the system.
- Singleton Pattern: Ensures a single instance of crucial manager classes such as
DriverMgr
,RiderMgr
,TripMgr
, andStrategyMgr
for centralized management. - Strategy Pattern: Encapsulates algorithms for pricing and driver matching, providing flexibility and scalability.
- Modern C++17 Features: Utilizes smart pointers (though introduced in C++11), STL containers, and thread-safe operations to build an efficient and maintainable system.
- C++17 Compiler: Ensure you have a C++17 compatible compiler installed (e.g., g++, clang++).
- CMake: Ensure you have CMake installed on your system.
Note: Click on image below to render it with better view.
-
Clone the Repository
git clone https://github.com/piyush26c/Uber-Low-Level-Design.git cd Uber-Low-Level-Design
-
Create a Build Directory
mkdir build cd build
-
Generate the Build System using CMake
cmake ..
-
Build the Project
make
-
Run the Executable
./UberSystem
├── CMakeLists.txt
├── common.hpp
├── defaultPricingStrategy.hpp
├── driver.hpp
├── driverMatchingStrategy.hpp
├── driverMgr.cpp
├── driverMgr.hpp
├── leastTimeBasedMatchingStrategy.hpp
├── location.hpp
├── main.cpp
├── pricingStrategy.hpp
├── ratingBasedPricingStrategy.hpp
├── rider.hpp
├── riderMgr.cpp
├── riderMgr.hpp
├── strategyMgr.cpp
├── strategyMgr.hpp
├── trip.hpp
├── tripMetaData.hpp
├── tripMgr.cpp
├── tripMgr.hpp