A full-stack ride-hailing platform built as a Database Systems course project. RideFlow demonstrates professional-grade database design across the complete stack: a normalized MySQL schema with stored procedures, triggers, views, and events; a Node.js/Express backend with role-based access control; and real-time communication via Socket.io.
Inspired by Uber, Careem, and InDrive.
| Layer | Technology |
|---|---|
| Backend | Node.js, Express.js |
| Database | MySQL 8.0+ (Stored Procedures, Triggers, Views, Events) |
| Real-time | Socket.io |
| Frontend | EJS, Bootstrap 5, Leaflet.js |
| Auth | bcryptjs, express-session |
- Node.js v16+
- MySQL Server 8.0+
git clone <repo-url>
cd rideflow
npm installcp .env.example .envOpen .env and fill in your MySQL password and any other values.
The seed script creates the schema, fare rules, and demo accounts in one step:
npm run seedAlternatively, import the SQL file manually:
mysql -u root -p < schema.sqlnpm start # production
npm run dev # development (nodemon, auto-restart)Open http://localhost:5000 in your browser.
| Role | Password | Access | |
|---|---|---|---|
| Admin | admin@rideflow.com |
admin123 |
Reports, Driver verification, Fare config |
| Rider | rider@rideflow.com |
rider123 |
Book rides, Wallet, Promo codes |
| Driver | ahmed@email.com |
driver123 |
Accept rides, Earnings dashboard |
9 core entities across 5 modules: Users, Drivers, Vehicles, Rides, Payments, Ratings, PromoCodes, Complaints, Locations
| Constraint | Count | Constraint | Count |
|---|---|---|---|
| PRIMARY KEY | 9 | CHECK | 35+ |
| FOREIGN KEY | 13 | UNIQUE | 19+ |
All foreign keys use ON DELETE RESTRICT to preserve referential integrity.
| View | Purpose |
|---|---|
vw_active_rides |
Live trips with driver and rider details |
vw_top_drivers |
Drivers with average rating > 4.5 |
vw_low_rated_drivers |
Drivers with average rating < 3.5 |
vw_revenue_summary |
Revenue breakdown by city and payment method |
| Procedure | Description |
|---|---|
sp_calculate_fare |
Computes fare from distance, duration, and surge multiplier |
sp_find_nearest_driver |
Returns available verified drivers filtered by vehicle type |
sp_complete_ride |
Finalizes ride, deducts platform fee, updates driver status |
| Trigger | Fires On | Action |
|---|---|---|
trg_payment_paid |
Payment marked Paid | Sets ride status to Completed |
trg_low_driver_rating |
Rating inserted | Flags driver and notifies admin if avg < 3.5 |
trg_promo_usage_count |
Promo applied to ride | Increments promo usage counter |
| Event | Schedule | Action |
|---|---|---|
evt_expire_promocodes |
Daily at midnight | Marks expired promo codes inactive |
Strategic indexes on rider_id, driver_id, ride_status, and city for performance on frequent WHERE and JOIN operations.
| Role | Permissions |
|---|---|
| Rider | SELECT/INSERT on Rides, Payments, Ratings |
| Driver | SELECT/UPDATE on Rides, Earnings |
| Admin | Full system access |
RideFlow uses a flat-fee platform model rather than a percentage commission:
- Rider side: +25 PKR platform fee added to every fare
- Driver side: −25 PKR platform fee deducted from earnings
- Platform profit: 50 PKR per completed ride, tracked automatically in Admin Reports
Fare formula: Base + (Distance × Per-KM rate) + (Duration × Per-Min rate) × Surge multiplier
rideflow/
├── config/
│ └── database.js # MySQL connection pool
├── middleware/
│ └── auth.js # Session auth & role guards
├── routes/
│ ├── auth.js # Login, register, logout
│ ├── rider.js # Ride booking, history, wallet
│ ├── driver.js # Availability, trip acceptance, earnings
│ └── admin.js # User management, reports, fare config
├── views/
│ ├── rider/ # Rider dashboards (EJS)
│ ├── driver/ # Driver dashboards (EJS)
│ └── admin/ # Admin dashboards (EJS)
├── scripts/
│ ├── seed.js # DB init + demo data
│ └── start-cluster.js # Cluster mode launcher
├── static/
│ └── uploads/ # Runtime file uploads (git-ignored)
├── schema.sql # Full DDL + DML + DCL
├── server.js # Express app entry point + Socket.io
├── package.json
├── .env.example # Environment variable template
└── .gitignore
Requested → Accepted → En Route → In Progress → Completed
Driver matching is based on availability, vehicle type, and location. Scheduled advance booking is supported.
Pending → Verified → Rejected — controlled by Admin. Unverified drivers cannot be matched to rides.
Cash, Wallet, and Card. Wallet balance tracked per rider. Promo codes with usage limits and expiry dates.
Mutual 1–5 star rating after ride completion. Drivers falling below 3.5 average are auto-flagged.
npm start # Start server
npm run dev # Start with nodemon (auto-restart on changes)
npm run seed # Initialize DB schema + insert demo data
npm run test-cluster # Run in cluster mode- Course: Database Systems Lab (AI & DS) — Spring 2026
- Institution: FAST NUCES Islamabad
- Imtishal Haq
- Harram Javed
- Miss Sidra Fayyaz
- Miss Ayesha Kamran