Design a store pickup route system
Problem Statement
Design a Store Pickup Route System that helps delivery drivers or warehouse operators plan and optimize their pickup routes across multiple retail stores or warehouses.
The system should take into account pickup locations, item priorities, store operating hours, distance, and traffic conditions to generate an optimized pickup route that minimizes travel time and maximizes efficiency.
🎯 Objective
To build a route optimization and scheduling platform that:
✅ Functional Requirements
1. Pickup Request Management
2. Route Optimization
3. Assignment & Scheduling
4. Navigation & Tracking
5. Notifications & Alerts
6. Dashboard / Reports
⚙️ Non-Functional Requirements
AttributeGoal
Scalability
Support 10K+ pickups per day
Latency
Route generation within 5 seconds
Availability
99.9% uptime
Accuracy
ETA prediction error < 10%
Reliability
Ensure route persistence even during failures
Extensibility
Add support for multi-day or multi-driver routes
Security
Protect sensitive store and location data
🧩 Core Components
ComponentDescription
Pickup Service
Manages pickup requests and store metadata
Route Optimization Engine
Computes optimal routes based on constraints
Driver Management Service
Handles driver profiles, shifts, and assignments
Tracking Service
Tracks real-time driver locations
Notification Service
Sends alerts and updates to drivers and stores
Map & Traffic Integration
Fetches live traffic and routing data
Admin Dashboard
Visualizes pickups, routes, and driver performance
Storage Layer
Stores route, pickup, and tracking data
🧱 High-Level Architecture
1
2 +-------------------------+
3 | Admin Dashboard |
4 +-----------+-------------+
5 |
6 +-----------v-------------+
7 | API Gateway |
8 +-----------+-------------+
9 |
10 +-------------------------------------------------------+
11 | Application Layer |
12 +-------------------------------------------------------+
13 | Pickup Svc | Route Engine | Driver Svc | Tracking Svc |
14 +-------------------------------------------------------+
15 |
16 +----------v----------+
17 | Map & Traffic APIs |
18 | (Google, OSM, etc.) |
19 +----------+----------+
20 |
21 +----------v----------+
22 | Notification Svc |
23 +----------+----------+
24 |
25 +----------v----------+
26 | Storage Layer |
27 | (SQL + Redis Cache) |
28 +----------+----------+
29 |
30 +----------v----------+
31 | Analytics Svc |
32 +---------------------+🧠 System Flow
1. Pickup Creation
1
2{
3 "pickup_id": "P1001",
4 "store_name": "Reliance Fresh, Koramangala",
5 "coordinates": "12.934,77.615",
6 "time_window": ["09:00", "18:00"],
7 "priority": "HIGH"
8}2. Route Optimization
1
2Route: Store A → Store C → Store D → Store B
3Total Distance: 24.6 km | ETA: 2h 10m3. Assignment
4. Execution & Tracking
5. Completion
🧱 Data Model (Simplified)
Pickup
1
2
3{
4 "pickup_id": "P1001",
5 "store_id": "S543",
6 "address": "Reliance Fresh, Koramangala",
7 "priority": "HIGH",
8 "status": "PENDING",
9 "time_window": ["09:00", "18:00"],
10 "coordinates": [12.934, 77.615]
11}Route
1
2{
3 "route_id": "R567",
4 "driver_id": "D102",
5 "pickup_ids": ["P1001", "P1002", "P1003"],
6 "total_distance_km": 26.4,
7 "estimated_time_min": 145,
8 "status": "IN_PROGRESS"
9}Driver
1
2{
3 "driver_id": "D102",
4 "name": "Ravi Kumar",
5 "current_location": [12.936, 77.620],
6 "vehicle_type": "VAN",
7 "shift": ["08:00", "16:00"]
8}⚡ Scalability & Optimization Considerations
| Feature | Approach |
| ---------------------- | -------------------------------------------------- |
| **Routing at scale** | Use asynchronous job queues + batch processing |
| **Real-time tracking** | Use WebSockets or MQTT for updates |
| **Traffic awareness** | Integrate with live traffic APIs |
| **Performance** | Cache store geocodes and route segments in Redis |
| **Route updates** | Dynamically re-optimize on delays or cancellations |
| **Fault tolerance** | Store last known route state for recovery |
🔒 Security & Compliance
🧩 Tech Stack (Example)
| Layer | Technology |
| -------------- | -------------------------------------- |
| **Frontend** | React / Angular for admin dashboard |
| **Backend** | Java / Go / Node.js microservices |
| **Database** | PostgreSQL + Redis (for caching) |
| **Queue** | Kafka / RabbitMQ |
| **Maps API** | Google Maps / Here API / OpenStreetMap |
| **Tracking** | WebSocket / MQTT |
| **Deployment** | Docker + Kubernetes |
| **Monitoring** | Prometheus + Grafana |
🚀 Key Challenges
| Challenge | Solution |
| ----------------------------------- | ---------------------------------------------------------- |
| **Dynamic routing (TSP)** | Use heuristic algorithms (Nearest Neighbor, Clarke-Wright) |
| **Real-time traffic updates** | Recalculate ETA every few minutes |
| **Multi-driver scheduling** | Partition requests geographically |
| **Offline connectivity** | Local cache + sync on reconnection |
| **Large-scale route recomputation** | Asynchronous background jobs with prioritization |
✅ Goal:
Design a smart, scalable, and traffic-aware store pickup routing system that ensures timely pickups, optimal travel distance, and real-time visibility for drivers and operations teams.