A full-stack, real-time ride-hailing platform built with FastAPI, WebSockets, and TailwindCSS. This project simulates an open mobility network (similar to Namma Yatri or ONDC) featuring live ride matching, dynamic pricing, pooling logic, and a geospatial admin command center.
- Instant Booking: Real-time ride requests broadcasted instantly to drivers via WebSockets.
- Dynamic Pricing: Algorithmic pricing based on distance and ride mode:
- Solo: Standard pricing for faster travel.
- Pool: ~30% cost reduction to incentivize shared mobility.
- Smart Scheduling: "Plan Your Commute" feature allows users to book rides in advance. The system automatically triggers these as Gold Priority requests at the scheduled time.
- Live Feedback: Visual status updates for "Driver Assigned," "Arrived," and "Trip Started."
- Split-Queue UI: A reactive interface featuring a dedicated Priority Section for high-value/scheduled rides (Gold Cards) and a standard feed for immediate requests.
- Real-Time Interaction: Accept or decline rides instantly without page reloads.
- Trip Lifecycle: Full workflow management: Accept -> Arrive -> Start Trip -> Complete.
- Earnings Visibility: Upfront fare display for every ride card.
- Live Heatmap: Real-time visualization of demand across 101 zones in Bangalore.
- Fleet Monitoring: Track active trips and waiting queue load in real-time.
- Data Logs: Comprehensive history of completed trips and revenue generation.
- Backend: Python 3.10+, FastAPI
- Real-Time Communication: Python
websockets(Bi-directional) - Database: SQLAlchemy (SQLite/PostgreSQL)
- Frontend: HTML5, Jinja2 Templates, JavaScript (ES6+)
- Styling: Tailwind CSS (CDN)
- Maps & Geospatial: Leaflet.js, OpenStreetMap
- Task Scheduling: Python
asynciobackground tasks
-
Clone the repository
git clone [https://github.com/yourusername/Rider.git](https://github.com/yourusername/Rider.git) cd Rider -
Create a virtual environment
# Windows python -m venv .venv .\.venv\Scripts\activate # Mac/Linux python3 -m venv .venv source .venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Run the Server This command starts the API server, the WebSocket manager, and the background scheduler.
uvicorn main:app --reload
Note: The application is configured to reset the database (
drop_all) on every startup for clean simulation testing. To persist data, comment out thedrop_allline inmain.py.
Access the portals via your browser at http://127.0.0.1:8000:
| Portal | URL Path | Description |
|---|---|---|
| Login / Home | / |
Main entry point for Riders and Drivers. |
| Admin Dashboard | /dashboard |
Monitoring tool for fleet managers. |
| API Docs | /docs |
Swagger UI for testing API endpoints manually. |
To test the full loop locally:
- Open Login in one tab and register as a Driver (e.g., ID 1). Keep this tab open.
- Open Login in a new tab (Incognito) and register as a Rider (e.g., ID 1).
- Rider Tab: Select Start/Drop locations and click Confirm Booking.
- Driver Tab: You will see the ride card appear instantly. Click Accept.
- Driver Tab: Click Arrived -> Start Trip -> Complete.
- Admin Tab: Watch the stats update live during this process.
Rider/
├── main.py # Application entry point, WebSocket logic, & Scheduler
├── requirements.txt # Python dependencies
├── templates/ # Frontend UI
│ ├── login.html # Authentication landing page
│ ├── register.html # User registration (Rider/Driver)
│ ├── rider.html # Rider booking interface
│ ├── driver.html # Driver dashboard with split queue
│ └── admin.html # Admin heatmap and monitoring
└── server/ # Backend Modules
├── database.py # Database connection setup
├── models.py # SQLAlchemy database models
├── schemas.py # Pydantic data validation schemas
└── connection_manager.py # WebSocket connection handler