Design a Delivery Partner Assignment System
Problem Statement
Design the Low-Level Design (LLD) for a Delivery Partner Assignment System, similar to what platforms like Swiggy, Zomato, Uber Eats, or Dunzo use.
The system’s goal is to efficiently assign the best available delivery partner to a new delivery request based on multiple factors such as location, availability, proximity, and delivery load.
Focus is on object-oriented class design, data models, and interactions, not on scalability or distributed coordination (that would be HLD).
🎯 Functional Requirements
Delivery Partner Management
Order / Delivery Request
Assignment Logic
Status Updates
Partner Tracking
Notifications
🚫 Non-Functional Requirements
🧱 Suggested Classes
ClassResponsibility
DeliveryPartner
Represents a delivery agent with attributes like id, name, location, status, and active order count.
Location
Represents a geographic coordinate (latitude, longitude).
OrderRequest
Represents a new delivery request with pickup, drop, and priority.
AssignmentService
Main service responsible for finding and assigning the best partner.
PartnerRepository
Stores and retrieves partner data; supports searching nearby partners.
DistanceCalculator
Utility to calculate distance between two Locations.
AssignmentStrategy (Interface)
Defines the algorithm for selecting the best delivery partner.
NearestPartnerStrategy, LoadBalancedStrategy
Concrete implementations of partner-selection strategies.
NotificationService
Sends assignment notifications to delivery partners.
AssignmentResult
Represents the outcome of an assignment attempt (success/failure, assignedPartnerId, etc.).
🔄 Example Flow
1
2OrderRequest(id=101, pickup=Koramangala, drop=BTM)1
2→ PartnerRepository.getAvailablePartnersWithinRadius(pickupLocation, 3 km)
3→ DistanceCalculator.calculateDistance()
4→ AssignmentStrategy.selectBestPartner()1
2Partner: Rajesh (1.2 km away)
3→ Notify partner via NotificationService1
2Partner status = BUSY
3Order assigned successfully1
2Partner status = AVAILABLE again
3Location updated⚙️ Example Entities (Simplified)
1
2DeliveryPartner
3 ├── id
4 ├── name
5 ├── currentLocation: Location
6 ├── status: PartnerStatus
7 ├── activeOrdersCount
8
9OrderRequest
10 ├── id
11 ├── pickupLocation: Location
12 ├── dropLocation: Location
13 ├── priority
14
15AssignmentService
16 ├── partnerRepository
17 ├── strategy: AssignmentStrategy
18 ├── assignOrder(orderRequest)🧪 Example Input / Output
Input:
1
2OrderRequest: pickup=(12.91, 77.63), drop=(12.93, 77.60)
3Available Partners:
4 P1: (12.90, 77.62), AVAILABLE
5 P2: (12.92, 77.64), BUSY
6 P3: (12.91, 77.65), AVAILABLEOutput:
1
2Assigned Partner: P1 (nearest available partner)📏 Constraints
🧠 Extension Ideas
✅ In short:
Design a Delivery Partner Assignment System that manages delivery partners, handles live locations, and efficiently assigns the nearest and most suitable partner to each delivery request, using clean OOP and strategy-based design.