Design Fleet Management System

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2022-02-03

Problem Statement

Designing a fleet management system that manages vehicles, drivers, routes, and maintenance schedules for a company. The focus is on object-oriented design, modularity, scheduling, and tracking.


✅ Functional Requirements


1.Vehicle Management
•Add, update, and remove vehicles.
•Track vehicle details: vehicleId, type (truck, van, car), capacity, currentLocation, status (available, in-use, under-maintenance).
•Support vehicle assignments to drivers and routes.
2.Driver Management
•Add, update, and remove drivers.
•Track driver details: driverId, name, licenseType, availabilityStatus.
3.Route & Assignment Management
•Assign vehicles and drivers to specific routes.
•Routes have metadata: routeId, startLocation, endLocation, distance, estimatedTime.
•Track trips and progress in real-time.
4.Maintenance Scheduling
•Schedule regular maintenance based on mileage or time.
•Track maintenance history for each vehicle.
5.Alerts & Notifications
•Notify admin/drivers about maintenance due, route delays, or vehicle issues.
6.Reporting & Analytics
•Generate reports on fleet usage, driver performance, maintenance costs.


🔐 Constraints & Assumptions


•Focus is on LLD, class design, and scheduling logic, not on GPS integration.
•Assume the system is used by fleet managers and drivers only.
•Real-time tracking can be simplified to updating current location and status.


🧱 Key Components & Classes


1.Vehicle Class
1 2class Vehicle { 3private: 4 string vehicleId; 5 string type; // Truck, Van, Car 6 int capacity; 7 string status; // AVAILABLE, IN_USE, UNDER_MAINTENANCE 8 string currentLocation; 9 vector<MaintenanceRecord*> maintenanceHistory; 10public: 11 void updateLocation(string location); 12 void updateStatus(string status); 13};
1.Driver Class
1 2class Driver { 3private: 4 string driverId; 5 string name; 6 string licenseType; 7 string availabilityStatus; // AVAILABLE, ON_TRIP 8public: 9 void updateAvailability(string status); 10};
1.Route Class
1 2class Route { 3private: 4 string routeId; 5 string startLocation; 6 string endLocation; 7 double distance; 8 double estimatedTime; 9public: 10 void assignVehicle(Vehicle* vehicle); 11 void assignDriver(Driver* driver); 12};
1.Trip Class
1 2class Trip { 3private: 4 string tripId; 5 Vehicle* vehicle; 6 Driver* driver; 7 Route* route; 8 string status; // SCHEDULED, IN_PROGRESS, COMPLETED 9public: 10 void startTrip(); 11 void completeTrip(); 12};
1.MaintenanceRecord Class
1 2class MaintenanceRecord { 3private: 4 string maintenanceId; 5 Vehicle* vehicle; 6 DateTime date; 7 string details; 8public: 9 void markCompleted(); 10};
1.FleetManager Class
•Central manager for vehicles, drivers, routes, and trips.
1 2class FleetManager { 3public: 4 void addVehicle(Vehicle* vehicle); 5 void addDriver(Driver* driver); 6 void scheduleTrip(Trip* trip); 7 vector<Vehicle*> getAvailableVehicles(); 8 vector<Driver*> getAvailableDrivers(); 9};


🔄 Example Workflow


1.Admin adds vehicles and drivers → FleetManager.addVehicle(), addDriver().
2.Admin schedules a trip → FleetManager.scheduleTrip() assigns available vehicle and driver.
3.Vehicle updates location and status → Vehicle.updateLocation().
4.Trip starts → Trip.startTrip(); completes → Trip.completeTrip().
5.Maintenance due → MaintenanceRecord tracks service, admin notified.


🧪 Expected Deliverables


•Class diagram showing Vehicle, Driver, Route, Trip, MaintenanceRecord, FleetManager.
•Implementation of vehicle/driver management, trip scheduling, status tracking, and maintenance logging.
•Test cases:
•Assign vehicle and driver to a trip
•Update trip status and vehicle location
•Schedule and track maintenance
•Retrieve available vehicles and drivers


💡 Discussion Points


•Concurrency: handling multiple trips and vehicle assignments simultaneously.
•Extensibility: adding GPS tracking or real-time analytics.
•Scalability: supporting hundreds of vehicles and drivers efficiently.
•Alerting: notification system for maintenance and delays.


Solution

Comments