A Python ride-hailing simulation that combines JSON data ingestion, validation, SQLite persistence, graph-based driver matching, payment simulation, and analytics.
This project simulates a ride-hailing system similar to Uber or Lyft. It demonstrates how structured data can be loaded from JSON, validated, persisted in a relational database, and used to perform graph-based driver matching and payment processing.
The system models real-world components including riders, drivers, rides, matching logic, and payments, providing a complete end-to-end data pipeline.
- Python
- SQLite
- NetworkX (graph-based routing)
- JSON (data ingestion)
- Load riders, drivers, and rides from JSON files
- Validate incoming data before use
- Persist riders, drivers, rides, and matching logs in SQLite
- Match riders to drivers using graph-based shortest path algorithms:
- Unweighted shortest path (fewest hops)
- Weighted shortest path (lowest cost)
- Simulate ride creation and payment processing
- Generate a simple analytics summary
The matching system uses graph algorithms to simulate real-world routing, enabling both efficiency-based and cost-based driver selection.
simulation.py # Main entry point database_manager.py # SQLite connection and query helper repositories.py # Persistence functions for domain objects data_loader.py # JSON loading and ingestion validators.py # JSON validation helpers graph_model.py # Graph creation and edge weighting matching.py # Driver matching algorithms
rider.py driver.py ride.py car.py payment.py billing_info.py # Domain logic
schema.sql # Database schema data/ # Seed JSON files
- Modular architecture (data loading, validation, persistence, matching)
- Separation of concerns using a repository pattern
- Input validation layer to prevent malformed or inconsistent data
- Extensible design for adding new features (payments, analytics, preferences)
Database and tables created successfully.
Loaded 10 drivers into DB
Loaded 10 riders into DB
Loaded 10 rides into DB
--- Real matching test ---
UNWEIGHTED MATCH
Driver: Bob
Hops: 4
Path: [12, 72, 7, 92, 5]
WEIGHTED MATCH
Driver: Bob
Cost: 17
Path: [12, 72, 7, 92, 5]
Saved matching log ID: 1
Saved matched ride ID: 11
Loaded matched ride: Aisha has requested a ride from 12 to 25.
--- Payment Simulation ---
Charging rider Aisha $42.5...
Charging $42.50 to pm_1 for Aisha.
Payment successful ✅
Charge result: True
--- Analytics Summary ---
Total rides: 11
Completed rides: 10
Average fare: $24.73
Most active driver: Bob (1 rides)- Make sure Python 3 is installed
- Install dependencies:
- pip install networkx
- Run the simulation:
- rm rides.db
- python3 simulation.py
- Preference-aware matching (language, distance, ratings)
- Store payment transactions in the database
- Simulate concurrent ride requests
- Expand analytics (driver utilization, ride distribution, etc.)
This project demonstrates a complete data-driven workflow: JSON → validation → objects → database → matching → payment → analytics