Uber/Ola App Design
Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2024-10-11
Problem Statement
Design and implement the core backend system for a ride-hailing application like Uber/Ola. The system should manage users (riders, drivers), rides, payments, and notifications, while supporting scalability, concurrency, and extensibility.
Functional Requirements (FR)
User Management
•Riders can register, login, and manage profile/payment info.
•Drivers can register, login, and update vehicle details, availability, and location.
Ride Management
•Rider requests a ride with pickup & drop location.
•System matches rider with an available driver nearby.
•Driver can accept/reject ride requests.
•Track ride status: Requested → Accepted → In-Progress → Completed → Cancelled.
•Rider and driver can cancel before/during the ride.
Pricing & Payments
•Calculate estimated fare based on distance, time, surge pricing.
•Multiple payment options: cash, wallet, cards, UPI.
•Track payment status (Pending, Success, Failed).
Location & Tracking
•Real-time driver location updates.
•Rider can see driver’s live location.
•ETA calculations.
Ratings & Reviews
•Riders can rate drivers and vice versa after the ride.
•Maintain feedback history.
Notifications
•Push notifications for ride request, driver arrival, ride completion, payment status.
Non-Functional Requirements (NFR)
•Scalability – Handle thousands of concurrent rides and location updates.
•Low Latency – Matching riders to drivers must be near real-time.
•Reliability – No double-booking of drivers.
•Extensibility – Support pooling (UberPool/Ola Share), rentals, subscriptions in future.
•Security – Encrypt user and payment details.
Core Entities & Attributes
User
•userId, name, email, phone, role (Rider/Driver), rating
Driver
•driverId, vehicleDetails, availabilityStatus, currentLocation
Ride
•rideId, riderId, driverId, pickupLocation, dropLocation, fare, status, startTime, endTime
Payment
•paymentId, rideId, userId, amount, method, status, timestamp
Notification
•notificationId, userId, message, type, timestamp
APIs / Operations
Rider APIs
•requestRide(riderId, pickup, drop)
•cancelRide(rideId)
•rateDriver(rideId, rating, feedback)
Driver APIs
•acceptRide(rideId)
•updateLocation(driverId, location)
•updateAvailability(driverId, status)
Ride APIs
•getRideStatus(rideId)
•calculateFare(pickup, drop)
Payment APIs
•initiatePayment(rideId, method)
•getPaymentStatus(paymentId)
Notification APIs
•sendNotification(userId, message)
LLD Design Goals
•Class Diagram → Entities like User, Driver, Rider, RideManager, PaymentManager, NotificationService, LocationService.
•Design Patterns:
•Observer → for notifications (ride status changes).
•Strategy → for fare calculation (normal, surge, pooling).
•Factory → for payment methods (cash, card, wallet, UPI).
•Handle trade-offs: Driver matching strategy (nearest vs. rating-based), location updates frequency, real-time tracking load.