Design a Cab Service for Office Employees
Problem Statement
Design a Cab Service System for Office Employees that allows employees of an organization to book cabs for office commute (home-to-office and office-to-home) while optimizing routes, costs, and utilization.
The system should efficiently manage ride scheduling, cab allocation, route optimization, and employee safety, while ensuring punctual pickups and real-time tracking.
🎯 Core Requirements
Functional Requirements
⚙️ Non-Functional Requirements
Attribute with Goal
Scalability
Handle 10,000+ employees across multiple offices
Latency
Real-time cab tracking with <100ms updates
Availability
99.9% uptime
Reliability
Ensure accurate and timely cab assignment
Security
Secure employee and location data
Cost Optimization
Optimize routes to minimize fleet cost
🧩 Core Components
Component with Description
User Service
Manages employee profiles, preferences, and authentication
Cab & Driver Service
Manages cabs, drivers, and capacity
Ride Management Service
Core logic for booking, scheduling, and routing
Routing/Optimization Engine
Calculates optimal routes using mapping APIs
Notification Service
Sends SMS/Email/App notifications
Tracking Service
Tracks real-time cab GPS data
Admin Dashboard
Allows administrators to monitor and manage operations
Database Layer
Stores user, ride, route, and vehicle data
Analytics Service
Provides insights on performance, costs, and utilization
🧱 High-Level Architecture
1
2 +-------------------------+
3 | Employee Portal |
4 +-----------+-------------+
5 |
6 +-----------v-------------+
7 | API Gateway |
8 +-----------+-------------+
9 |
10 +---------------------------------------------------+
11 | Application Layer |
12 +---------------------------------------------------+
13 | User Svc | Ride Svc | Cab Svc | Tracking Svc|
14 +---------------------------------------------------+
15 |
16 +-----------v-------------+
17 | Routing/Optimization |
18 | Engine (Maps API) |
19 +-----------+-------------+
20 |
21 +---------------------------------------------------+
22 | Data Layer |
23 +---------------------------------------------------+
24 | Employee DB | Ride DB | Vehicle DB | Route Cache |
25 | (SQL/NoSQL) | (NoSQL) | (SQL) | (Redis) |
26 +---------------------------------------------------+
27 |
28 +-----------v-------------+
29 | Notification / Alert Svc|
30 +-----------+-------------+
31 |
32 +-----------v-------------+
33 | Admin Dashboard / Ops |
34 +-------------------------+🧠 Key Flows
🕗 1. Ride Scheduling Flow
🚖 2. Real-time Tracking Flow
⚙️ 3. Route Optimization Flow
🧱 Data Model (Simplified)
Employee
1
2{
3 "employee_id": "E1234",
4 "name": "Sahil Batra",
5 "home_location": "12.93,77.59",
6 "office_location": "12.97,77.64",
7 "shift_time": "09:00 AM",
8 "preferred_pickup_time": "08:15 AM"
9}Cab
1
2{
3 "cab_id": "C101",
4 "driver_id": "D45",
5 "capacity": 4,
6 "current_location": "12.95,77.61",
7 "status": "AVAILABLE"
8}Ride
1
2{
3 "ride_id": "R567",
4 "cab_id": "C101",
5 "employee_ids": ["E1234", "E5678"],
6 "pickup_points": ["12.93,77.59", "12.94,77.60"],
7 "status": "SCHEDULED",
8 "route": "List of coordinates"
9}⚡ Scalability Considerations
| Feature | Design Choice |
| ----------------- | ------------------------------------------------- |
| **Routing** | Use distributed job workers for route computation |
| **Tracking** | Use Redis or Kafka for real-time location stream |
| **Scheduling** | Batch scheduling jobs per shift |
| **Data Storage** | SQL for users, NoSQL for rides |
| **Load Handling** | Horizontal scaling via microservices |
| **Async Updates** | Event-driven using Kafka or RabbitMQ |
🔒 Security & Safety
📊 Admin Dashboard Features
🧩 Tech Stack (Example)
| Layer | Technology |
| ----------------- | ---------------------------------- |
| **Frontend** | React / Angular |
| **Backend** | Node.js / Java Spring Boot / Go |
| **Database** | PostgreSQL + MongoDB + Redis |
| **Message Queue** | Kafka / RabbitMQ |
| **Tracking** | WebSocket + GPS device integration |
| **Maps API** | Google Maps / OpenStreetMap |
| **Deployment** | Kubernetes + Docker + Azure/AWS |
🚀 Key Challenges
Challenge with Solution
Route Optimization (NP-hard)
Use clustering (K-Means) + heuristics
Concurrent Shift Scheduling
Partition jobs by shift and zone
Location Accuracy
GPS smoothing + caching
Cab Utilization vs. Employee Comfort
Weighted algorithm for optimal grouping
Scalability during Shift Peaks
Autoscaling + async job queues
✅ Goal:
Design a secure, reliable, and cost-optimized cab service system that provides timely office commute, real-time tracking, and smart route optimization for thousands of employees.