Skip to content

ancypatel-21/fleetmatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FleetMatch

Real-time ride matching and dispatch system with priority-based assignment, dynamic reallocation, and latency-aware processing.


Overview

FleetMatch is a simulation of a real-time ride-hailing dispatch system that matches riders with nearby drivers under latency constraints. The system models how modern ride-sharing platforms (e.g., Uber, Lyft) handle incoming ride requests, optimize driver assignment, and maintain system performance under load.

It implements a priority-based matching engine, supports dynamic re-assignment for cancellations, and tracks system-level performance metrics such as latency and throughput.


Key Capabilities

  • Real-time rider-driver matching using distance-based scoring
  • Priority queue–based dispatch for optimal assignment
  • Dynamic re-assignment on cancellation or driver unavailability
  • Low-latency matching workflow with performance tracking
  • System observability through structured logging and metrics
  • Modular backend design for scalability and extensibility

System Architecture

Rider Requests → Matching Engine → Priority Queue → Driver Assignment
                         ↓
                Reassignment Logic
                         ↓
                Metrics + Monitoring

Core Components

1. Matching Engine

Implements a scoring function using:

  • distance between rider and driver
  • estimated time of arrival (ETA)

A priority queue is used to select the optimal driver efficiently.


2. Dispatch & Reassignment

  • Assigns drivers to incoming ride requests
  • Handles ride cancellations
  • Reassigns riders to the next best available driver in real time

3. Data Models

  • Driver: location, availability state
  • Rider: location and request metadata

4. Metrics & Observability

Tracks:

  • total ride requests
  • successful matches
  • average matching latency
  • system throughput (requests/sec)

Logging provides visibility into:

  • assignment decisions
  • matching latency
  • system behavior under load

How It Works

  1. Riders submit ride requests.
  2. The system evaluates all available drivers.
  3. A scoring function computes priority based on distance and ETA.
  4. A priority queue selects the best driver.
  5. The driver is assigned and marked unavailable.
  6. If a cancellation occurs, reassignment logic triggers.
  7. Metrics and logs capture system performance.

Run the Project

python3 main.py

Sample Output

[12:45:10] Starting FleetMatch dispatch...
[12:45:10] Matched Rider R1 with Driver D3 (distance=1.41, time=0.0012s)
[12:45:10] Matched Rider R2 with Driver D2 (distance=0.00, time=0.0010s)

=== FleetMatch Metrics ===
Total requests: 4
Successful matches: 4
Average match time: 0.0011s
System throughput: 1200.50 req/sec

[12:45:10] Dispatch complete.

Tech Stack

  • Python
  • Data Structures (Heaps / Priority Queues)
  • REST-style architecture concepts
  • Basic system design and simulation

Design Considerations

  • Latency Optimization: Matching logic minimizes decision time per request
  • Scalability: Priority queue enables efficient selection at scale
  • Fault Handling: Reassignment logic ensures system resilience
  • Observability: Metrics and logs enable performance monitoring

Future Improvements

  • Introduce real-time request queues (Kafka / Redis Streams)
  • Add geospatial indexing for faster proximity search
  • Implement batching and pooling strategies
  • Integrate real-time traffic data into ETA estimation
  • Deploy as microservices with API endpoints

Author

Ancy Patel

About

Real-time ride matching and dispatch system with priority-based assignment and latency tracking

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages