Skip to content

πŸš— RidePool-STRPS – a smart πŸš€ ride-pooling system ✨ with πŸ“ real-time GPS tracking, 🀝 intelligent ride matching & pooling, πŸ‘₯ multi-role dashboards (Rider/Driver/Admin πŸ“Š), ⚑ Socket.IO live updates πŸ”„, πŸ” JWT authentication, and πŸ“ˆ admin analytics for efficient transportation management 🧩.

License

Notifications You must be signed in to change notification settings

H0NEYP0T-466/RidePool-STRPS

RidePool-STRPS

Smart Transportation & Ride-Pooling System (STRPS) β€” A comprehensive platform enabling efficient ride-sharing through real-time matching, live GPS tracking, and multi-role management.

GitHub License
GitHub Stars
GitHub Forks
GitHub Issues
GitHub Pull Requests
Contributions Welcome

Last Commit
Commit Activity
Repo Size
Code Size

Top Language
Languages Count

Discussions
Documentation
Open Source Love


πŸ“„ Abstract

RidePool-STRPS is a full-stack ride-pooling platform designed to optimize transportation through intelligent ride matching, real-time GPS tracking, and comprehensive multi-role management. The system caters to three primary user types: Riders (users requesting rides), Drivers (service providers), and Admins (platform managers).

Built with modern web technologies including React, TypeScript, FastAPI, and MongoDB, RidePool-STRPS leverages WebSocket connections for real-time updates and Leaflet maps for live location tracking. The platform implements secure JWT-based authentication, intelligent ride-matching algorithms, and dynamic fare calculation to provide an efficient, scalable solution for urban transportation needs.

Key Capabilities

  • πŸš— Intelligent Ride Matching β€” Automatically matches riders with nearby drivers based on location, route compatibility, and pooling preferences
  • πŸ“ Live GPS Tracking β€” Real-time driver location updates and route visualization using Leaflet maps
  • πŸ‘₯ Multi-Role Architecture β€” Separate interfaces for riders, drivers, and administrators with role-based access control
  • πŸ” Secure Authentication β€” JWT-based auth system with protected routes and token management
  • ⚑ Real-Time Updates β€” WebSocket-powered instant notifications for ride status changes, driver locations, and booking confirmations
  • πŸ“Š Admin Dashboard β€” Comprehensive analytics, user management, and operational oversight tools
  • πŸ’° Dynamic Pricing β€” Distance-based fare calculation with pooling discounts and surge pricing support
  • 🚦 Trip Management β€” Complete ride lifecycle management from booking to completion with status tracking

πŸ”— Quick Links

Live Demo Documentation

πŸ“‘ Table of Contents

✨ Key Highlights

  • πŸš— Real-Time Ride Matching & Pooling β€” Advanced algorithms match riders with compatible routes for efficient carpooling
  • πŸ“ Live GPS Tracking β€” Real-time driver location updates with interactive Leaflet map visualization
  • πŸ‘₯ Three User Roles β€” Dedicated interfaces for Riders, Drivers, and Admins with role-based permissions
  • πŸ” JWT Authentication & Security β€” Secure token-based authentication with protected API routes
  • ⚑ WebSocket Real-Time Updates β€” Instant notifications for ride status changes, driver locations, and bookings
  • πŸ“Š Admin Analytics Dashboard β€” Comprehensive platform metrics, user management, and revenue tracking
  • πŸ’° Dynamic Fare Calculation β€” Distance-based pricing with pooling discounts and surge pricing
  • πŸ—ΊοΈ Route Optimization β€” Intelligent routing for pooled rides with minimal detours
  • πŸ“± Responsive Design β€” Mobile-first UI that works seamlessly across all devices
  • πŸ”„ Automatic Ride Matching β€” Background service continuously matches available drivers with ride requests

πŸ— Architecture

System Overview

RidePool-STRPS follows a modern client-server architecture with real-time communication capabilities:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         CLIENT LAYER                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚  Rider App   β”‚  β”‚  Driver App  β”‚  β”‚  Admin Panel β”‚          β”‚
β”‚  β”‚  (React)     β”‚  β”‚  (React)     β”‚  β”‚  (React)     β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚         β”‚                  β”‚                  β”‚                  β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚
β”‚                            β”‚                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚   HTTP/WebSocket      β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       SERVER LAYER                               β”‚
β”‚                            β”‚                                     β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
β”‚         β”‚      FastAPI + Socket.IO            β”‚                 β”‚
β”‚         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚                 β”‚
β”‚         β”‚  β”‚   Authentication Middleware β”‚    β”‚                 β”‚
β”‚         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚                 β”‚
β”‚         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”        β”‚                 β”‚
β”‚         β”‚  β”‚ Auth β”‚ β”‚ Ride β”‚ β”‚Admin β”‚        β”‚                 β”‚
β”‚         β”‚  β”‚ APIs β”‚ β”‚ APIs β”‚ β”‚ APIs β”‚        β”‚                 β”‚
β”‚         β”‚  β””β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”€β”˜        β”‚                 β”‚
β”‚         β”‚     β”‚        β”‚        β”‚             β”‚                 β”‚
β”‚         β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚                 β”‚
β”‚         β”‚              β”‚                      β”‚                 β”‚
β”‚         β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚                 β”‚
β”‚         β”‚     β”‚  Business Logic β”‚             β”‚                 β”‚
β”‚         β”‚     β”‚   - Matching    β”‚             β”‚                 β”‚
β”‚         β”‚     β”‚   - Pricing     β”‚             β”‚                 β”‚
β”‚         β”‚     β”‚   - Routing     β”‚             β”‚                 β”‚
β”‚         β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚                 β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚                        β”‚                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚   MongoDB     β”‚
                 β”‚   Database    β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Frontend-Backend Communication

  1. HTTP REST APIs β€” CRUD operations for users, rides, bookings, and admin functions
  2. WebSocket (Socket.IO) β€” Real-time bidirectional communication for:
    • Driver location updates
    • Ride status notifications
    • Live ride matching alerts
    • Chat/messaging features

Authentication Flow

User Login Request
      β”‚
      β”œβ”€> POST /api/auth/login
      β”‚
      β”œβ”€> Validate credentials (bcrypt)
      β”‚
      β”œβ”€> Generate JWT token (python-jose)
      β”‚
      β”œβ”€> Return token + user data
      β”‚
      └─> Client stores token (localStorage)

Protected Request
      β”‚
      β”œβ”€> Include token in Authorization header
      β”‚
      β”œβ”€> Middleware validates token
      β”‚
      β”œβ”€> Decode user from token
      β”‚
      β”œβ”€> Check role permissions
      β”‚
      └─> Execute request or return 401/403

Database Schema

Collections:

  • users β€” User accounts (riders, drivers, admins)
  • drivers β€” Driver-specific profiles (vehicle info, availability, ratings)
  • bookings β€” Ride requests from riders
  • rides β€” Accepted/active ride sessions (can have multiple passengers for pooling)
  • feedback β€” Ratings and reviews

Key Relationships:

  • User ↔ Bookings (1:N)
  • Driver ↔ Rides (1:N)
  • Ride ↔ Bookings (1:N for pooled rides)

πŸš€ Quick Start

Prerequisites

Before you begin, ensure you have the following installed:

  • βœ… Node.js 18+ (Download)
  • βœ… npm or yarn package manager
  • βœ… Python 3.10+ (Download)
  • βœ… MongoDB (Local or Atlas)
  • βœ… Git for version control

Installation Steps

1. Clone the Repository

git clone https://github.com/H0NEYP0T-466/RidePool-STRPS.git
cd RidePool-STRPS

2. Frontend Setup

# Install dependencies
npm install

# Create .env file for frontend
cp .env.example .env  # Or create manually

# Start development server
npm run dev

The frontend will run at http://localhost:5173

3. Backend Setup

# Navigate to backend directory
cd backend

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Create .env file for backend
# Add your MongoDB URI and JWT secret (see Environment Configuration section)

# Start the FastAPI server
uvicorn app.main:socket_app --host 0.0.0.0 --port 8888 --reload

The backend API will run at http://localhost:8888

4. Database Setup

# (Optional) Seed sample data
cd backend
python seed_data/seed.py

5. Verification

βœ… Frontend: Open http://localhost:5173 β€” You should see the landing page
βœ… Backend: Visit http://localhost:8888/docs β€” FastAPI interactive documentation
βœ… Database: Check MongoDB connection β€” Verify collections are created

Common Gotchas

⚠️ Port Conflicts: If ports 5173 or 8888 are in use, modify vite.config.ts or use --port flag
⚠️ MongoDB Connection: Ensure MongoDB is running locally or your Atlas cluster is accessible
⚠️ CORS Errors: Verify CORS_ORIGINS in backend .env includes your frontend URL
⚠️ WebSocket Issues: Check that both HTTP and WS URLs are correctly configured in frontend .env


βš™οΈ Environment Configuration

Frontend Environment Variables

Create a .env file in the project root:

# API Configuration
VITE_API_URL=http://localhost:8888
VITE_WS_URL=ws://localhost:8888

# Optional: Map Configuration
VITE_MAP_CENTER_LAT=28.6139
VITE_MAP_CENTER_LNG=77.2090
VITE_MAP_ZOOM=12

Backend Environment Variables

Create a .env file in the backend/ directory:

# Database Configuration
MONGODB_URI=mongodb://localhost:27017/ridepool
# For MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/ridepool?retryWrites=true&w=majority

# JWT Configuration
JWT_SECRET=09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

# CORS Configuration
CORS_ORIGINS=http://localhost:5173,https://ride-pool-strps.vercel.app

# Server Configuration
HOST=0.0.0.0
PORT=8888

# Optional: Redis (for production caching)
# REDIS_URL=redis://localhost:6379

Security Note: Never commit .env files to version control. Use .env.example as a template.


⚑ Usage

For Riders (Users)

  1. Register/Login β€” Create an account or log in with existing credentials
  2. Request a Ride
    • Enter pickup and dropoff locations on the map
    • Choose whether to enable ride pooling (for discounted fares)
    • View estimated fare
    • Confirm booking
  3. Track Your Ride
    • View real-time driver location on the map
    • See estimated arrival time
    • Receive notifications when driver is nearby
  4. Complete Ride
    • Pay fare (cash or integrated payment)
    • Rate your driver
    • View ride history

For Drivers

  1. Register as Driver β€” Create account with driver role
  2. Set Up Profile
    • Add vehicle information (type, number, license)
    • Upload required documents
    • Toggle availability status
  3. Accept Rides
    • View available ride requests nearby
    • Accept rides that match your route
    • View passenger details and destinations
  4. Complete Trip
    • Update ride status (accepted β†’ in-progress β†’ completed)
    • Share real-time location via WebSocket
    • Collect payment
    • View earnings and trip history

For Admins

  1. Login with Admin Credentials
  2. Dashboard Overview
    • View total users, drivers, and rides
    • Monitor active rides in real-time
    • Track revenue and platform metrics
  3. User Management
    • View all users and drivers
    • Approve/suspend accounts
    • Handle support requests
  4. Analytics
    • Generate reports on rides, revenue, and user activity
    • Identify peak hours and popular routes
    • Monitor driver ratings and performance

πŸ“‘ API Documentation

Authentication Endpoints

Method Endpoint Description Auth Required
POST /api/auth/register Register new user ❌
POST /api/auth/login User login ❌
GET /api/auth/me Get current user profile βœ…
PUT /api/auth/profile Update user profile βœ…

Example: Register User

curl -X POST http://localhost:8888/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "+1234567890",
    "password": "securepassword",
    "role": "user"
  }'

User/Rider Endpoints

Method Endpoint Description Auth Required
GET /api/user/profile Get user profile βœ…
PUT /api/user/profile Update user profile βœ…
POST /api/user/ride/request Create new ride request βœ…
GET /api/user/bookings Get user's booking history βœ…
PUT /api/user/bookings/:id/cancel Cancel a booking βœ…

Example: Request Ride

curl -X POST http://localhost:8888/api/user/ride/request \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "pickupLocation": {"lat": 28.6139, "lng": 77.2090, "address": "Connaught Place"},
    "dropoffLocation": {"lat": 28.5355, "lng": 77.3910, "address": "Noida Sector 62"},
    "wantPooling": true
  }'

Driver Endpoints

Method Endpoint Description Auth Required
GET /api/driver/profile Get driver profile βœ… (Driver)
PUT /api/driver/profile Update driver profile βœ… (Driver)
PUT /api/driver/location Update current location βœ… (Driver)
PUT /api/driver/availability Toggle availability βœ… (Driver)
GET /api/driver/rides Get driver's ride history βœ… (Driver)
PUT /api/driver/rides/:id/accept Accept a ride request βœ… (Driver)
PUT /api/driver/rides/:id/complete Mark ride as completed βœ… (Driver)

Ride Management

Method Endpoint Description Auth Required
GET /api/rides/available-pools Get available pooling rides βœ…
GET /api/rides/:id Get ride details βœ…
PUT /api/rides/:id/status Update ride status βœ…
POST /api/rides/:id/join Join a pooled ride βœ…

Admin Endpoints

Method Endpoint Description Auth Required
GET /api/admin/dashboard Get dashboard statistics βœ… (Admin)
GET /api/admin/users Get all users βœ… (Admin)
GET /api/admin/drivers Get all drivers βœ… (Admin)
GET /api/admin/rides Get all rides βœ… (Admin)
PUT /api/admin/users/:id Update user status βœ… (Admin)
DELETE /api/admin/users/:id Delete user βœ… (Admin)

Example: Get Admin Dashboard

curl -X GET http://localhost:8888/api/admin/dashboard \
  -H "Authorization: Bearer <admin-token>"

WebSocket Events

Client β†’ Server Events:

Event Payload Description
connect { userId, role } Establish WebSocket connection
driver:location { driverId, lat, lng } Driver location update
driver:availability { driverId, isAvailable } Driver availability toggle

Server β†’ Client Events:

Event Payload Description
ride:matched { rideId, driverId, pickupETA } Ride matched with driver
ride:status { rideId, status, message } Ride status update
driver:location:update { driverId, lat, lng, timestamp } Real-time driver location
booking:confirmed { bookingId, rideId, fare } Booking confirmation

Example: WebSocket Client (JavaScript)

import io from 'socket.io-client';

const socket = io('http://localhost:8888', {
  auth: { token: 'your-jwt-token' }
});

// Listen for ride status updates
socket.on('ride:status', (data) => {
  console.log('Ride status:', data.status);
});

// Send driver location update
socket.emit('driver:location', {
  driverId: 'driver123',
  lat: 28.6139,
  lng: 77.2090
});

API Response Format

All API responses follow this standard format:

Success Response:

{
  "success": true,
  "message": "Operation successful",
  "data": { /* response data */ }
}

Error Response:

{
  "success": false,
  "error": "Error message",
  "details": { /* optional error details */ }
}

Rate Limiting

  • Default: 100 requests per minute per IP
  • Authenticated: 500 requests per minute per user
  • Admin: Unlimited

For complete API documentation with interactive examples, visit: http://localhost:8888/docs (FastAPI Swagger UI)


✨ Features

πŸš— For Riders

  • Easy Booking β€” Simple interface to request rides with pickup/dropoff selection
  • Ride Pooling β€” Share rides with others heading in the same direction for reduced fares
  • Live Tracking β€” Real-time driver location on interactive maps
  • Fare Estimates β€” Transparent pricing before booking
  • Ride History β€” Complete record of all past trips
  • Driver Ratings β€” Rate drivers after each trip
  • Instant Notifications β€” Real-time alerts for ride status updates

πŸš™ For Drivers

  • Flexible Availability β€” Toggle online/offline status anytime
  • Smart Ride Matching β€” Receive ride requests based on your location and route
  • Route Optimization β€” Efficient routing for pooled rides with minimal detours
  • Earnings Tracking β€” Monitor your income and trip statistics
  • Rating System β€” Build reputation through customer feedback
  • Profile Management β€” Update vehicle details and documentation
  • Real-Time Communication β€” Instant updates on ride status and passenger information

πŸ‘¨β€πŸ’Ό For Admins

  • Comprehensive Dashboard β€” Real-time metrics on platform activity
  • User Management β€” View, edit, and manage rider and driver accounts
  • Ride Monitoring β€” Track all active and completed rides
  • Revenue Analytics β€” Detailed financial reports and insights
  • Driver Verification β€” Approve/reject driver registrations
  • Support Tools β€” Handle disputes and customer support requests
  • Platform Analytics β€” Insights into peak hours, popular routes, and user behavior

πŸ”§ Technical Features

  • JWT Authentication β€” Secure token-based user authentication
  • Role-Based Access Control β€” Different permissions for riders, drivers, and admins
  • WebSocket Integration β€” Real-time bidirectional communication
  • Responsive Design β€” Mobile-first approach that works on all devices
  • RESTful API β€” Clean, well-documented API endpoints
  • MongoDB Database β€” Scalable NoSQL database for flexible data modeling
  • Leaflet Maps β€” Interactive map visualization with markers and routing
  • Type-Safe Frontend β€” TypeScript for enhanced code quality and developer experience

πŸ“‚ Folder Structure

Comprehensive overview of the project structure:

RidePool-STRPS/
β”œβ”€β”€ backend/                          # Backend API (FastAPI + Socket.IO)
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ main.py                   # FastAPI entry point with Socket.IO integration
β”‚   β”‚   β”œβ”€β”€ config.py                 # Configuration management
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ models/                   # Pydantic models & DB schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”œβ”€β”€ user.py               # User model (UserCreate, UserLogin, UserUpdate)
β”‚   β”‚   β”‚   β”œβ”€β”€ driver.py             # Driver model (DriverCreate, DriverUpdate)
β”‚   β”‚   β”‚   β”œβ”€β”€ booking.py            # Booking model (BookingCreate)
β”‚   β”‚   β”‚   β”œβ”€β”€ ride.py               # Ride model (RideCreate, RideUpdate)
β”‚   β”‚   β”‚   └── feedback.py           # Feedback model (FeedbackCreate)
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ routes/                   # API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.py               # Authentication routes (/api/auth/*)
β”‚   β”‚   β”‚   β”œβ”€β”€ user.py               # User/Rider routes (/api/user/*)
β”‚   β”‚   β”‚   β”œβ”€β”€ driver.py             # Driver routes (/api/driver/*)
β”‚   β”‚   β”‚   β”œβ”€β”€ ride.py               # Ride management routes (/api/rides/*)
β”‚   β”‚   β”‚   └── admin.py              # Admin routes (/api/admin/*)
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ services/                 # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ auth_service.py       # User registration, login, profile updates
β”‚   β”‚   β”‚   β”œβ”€β”€ ride_matching.py      # Ride matching algorithms
β”‚   β”‚   β”‚   └── payment_service.py    # Fare calculation and payment logic
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ utils/                    # Helper functions
β”‚   β”‚   β”‚   β”œβ”€β”€ database.py           # MongoDB connection and helpers
β”‚   β”‚   β”‚   └── jwt_handler.py        # JWT token generation and validation
β”‚   β”‚   β”‚
β”‚   β”‚   └── websocket/                # WebSocket handlers
β”‚   β”‚       β”œβ”€β”€ __init__.py
β”‚   β”‚       └── socket_handler.py     # Socket.IO event handlers
β”‚   β”‚
β”‚   β”œβ”€β”€ seed_data/                    # Sample data loaders
β”‚   β”‚   └── seed.py                   # MongoDB seeding script
β”‚   β”‚
β”‚   β”œβ”€β”€ .env                          # Environment variables (not committed)
β”‚   β”œβ”€β”€ requirements.txt              # Python dependencies
β”‚   └── run_commands.txt              # Quick reference commands
β”‚
β”œβ”€β”€ src/                              # Frontend React application
β”‚   β”œβ”€β”€ assets/                       # Images, icons, styles
β”‚   β”‚   β”œβ”€β”€ images/                   # Image assets
β”‚   β”‚   └── styles/                   # Global CSS/SCSS files
β”‚   β”‚
β”‚   β”œβ”€β”€ components/                   # React components
β”‚   β”‚   β”œβ”€β”€ common/                   # Shared/reusable components
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.tsx            # Navigation bar
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.tsx            # Footer component
β”‚   β”‚   β”‚   β”œβ”€β”€ Map.tsx               # Leaflet map wrapper
β”‚   β”‚   β”‚   └── LoadingSpinner.tsx    # Loading indicator
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ user/                     # Rider-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ BookingForm.tsx       # Ride booking form
β”‚   β”‚   β”‚   β”œβ”€β”€ RideTracker.tsx       # Live ride tracking
β”‚   β”‚   β”‚   └── RideHistory.tsx       # Past rides list
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ driver/                   # Driver-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ DriverDashboard.tsx   # Driver main dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ RideRequests.tsx      # Available ride requests
β”‚   β”‚   β”‚   └── ActiveRides.tsx       # Ongoing rides
β”‚   β”‚   β”‚
β”‚   β”‚   └── admin/                    # Admin dashboard components
β”‚   β”‚       β”œβ”€β”€ AdminDashboard.tsx    # Admin overview
β”‚   β”‚       β”œβ”€β”€ UserManagement.tsx    # User management panel
β”‚   β”‚       β”œβ”€β”€ DriverManagement.tsx  # Driver management panel
β”‚   β”‚       └── Analytics.tsx         # Platform analytics
β”‚   β”‚
β”‚   β”œβ”€β”€ context/                      # React Context providers
β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx           # Authentication state management
β”‚   β”‚   └── RideContext.tsx           # Ride/booking state management
β”‚   β”‚
β”‚   β”œβ”€β”€ pages/                        # Route-level pages
β”‚   β”‚   β”œβ”€β”€ Landing/
β”‚   β”‚   β”‚   └── LandingPage.tsx       # Landing page
β”‚   β”‚   β”œβ”€β”€ Login/
β”‚   β”‚   β”‚   └── Login.tsx             # Login page
β”‚   β”‚   β”œβ”€β”€ Register/
β”‚   β”‚   β”‚   └── Register.tsx          # Registration page
β”‚   β”‚   β”œβ”€β”€ user/                     # Rider pages (not shown in detail)
β”‚   β”‚   β”œβ”€β”€ driver/                   # Driver pages (not shown in detail)
β”‚   β”‚   └── admin/                    # Admin pages (not shown in detail)
β”‚   β”‚
β”‚   β”œβ”€β”€ services/                     # API clients
β”‚   β”‚   β”œβ”€β”€ api.ts                    # Axios instance configuration
β”‚   β”‚   └── socket.ts                 # Socket.IO client setup
β”‚   β”‚
β”‚   β”œβ”€β”€ types/                        # TypeScript definitions
β”‚   β”‚   β”œβ”€β”€ user.ts                   # User-related types
β”‚   β”‚   β”œβ”€β”€ ride.ts                   # Ride-related types
β”‚   β”‚   └── booking.ts                # Booking-related types
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/                        # Utility functions
β”‚   β”‚   β”œβ”€β”€ formatters.ts             # Data formatting helpers
β”‚   β”‚   └── validators.ts             # Form validation utilities
β”‚   β”‚
β”‚   β”œβ”€β”€ data/                         # Static data/constants
β”‚   β”œβ”€β”€ App.tsx                       # Main App component with routing
β”‚   β”œβ”€β”€ App.css                       # App-level styles
β”‚   β”œβ”€β”€ main.tsx                      # React entry point
β”‚   └── index.css                     # Global styles
β”‚
β”œβ”€β”€ public/                           # Static assets served by Vite
β”‚   β”œβ”€β”€ favicon.ico
β”‚   └── vite.svg
β”‚
β”œβ”€β”€ docs/                             # Documentation
β”‚   β”œβ”€β”€ API.md                        # API documentation
β”‚   β”œβ”€β”€ SETUP.md                      # Setup instructions
β”‚   └── DEPLOYMENT.md                 # Deployment guide
β”‚
β”œβ”€β”€ .github/                          # GitHub workflows and templates
β”‚   β”œβ”€β”€ workflows/                    # GitHub Actions
β”‚   └── ISSUE_TEMPLATE/               # Issue templates
β”‚
β”œβ”€β”€ .env                              # Frontend environment variables (not committed)
β”œβ”€β”€ .env.example                      # Example environment file
β”œβ”€β”€ .gitignore                        # Git ignore rules
β”œβ”€β”€ package.json                      # Node.js dependencies
β”œβ”€β”€ package-lock.json                 # Locked dependency versions
β”œβ”€β”€ vite.config.ts                    # Vite configuration
β”œβ”€β”€ tsconfig.json                     # TypeScript configuration (base)
β”œβ”€β”€ tsconfig.app.json                 # TypeScript config for app
β”œβ”€β”€ tsconfig.node.json                # TypeScript config for Node.js
β”œβ”€β”€ eslint.config.js                  # ESLint configuration
β”œβ”€β”€ index.html                        # HTML entry point
β”‚
β”œβ”€β”€ README.md                         # This file
β”œβ”€β”€ CONTRIBUTING.md                   # Contribution guidelines
β”œβ”€β”€ CODE_OF_CONDUCT.md                # Community standards
β”œβ”€β”€ SECURITY.md                       # Security policies
└── LICENSE                           # MIT License

πŸš€ Deployment

Frontend Deployment (Vercel)

  1. Push to GitHub β€” Ensure your code is pushed to GitHub
  2. Connect to Vercel
    # Install Vercel CLI
    npm i -g vercel
    
    # Login and deploy
    vercel login
    vercel --prod
  3. Configure Environment Variables in Vercel dashboard:
    • VITE_API_URL β€” Your production backend URL
    • VITE_WS_URL β€” Your production WebSocket URL
  4. Build Settings:
    • Build Command: npm run build
    • Output Directory: dist
    • Install Command: npm install

Live Demo: https://ride-pool-strps.vercel.app

Backend Deployment (Railway/Render)

Option 1: Railway

  1. Create New Project on Railway
  2. Connect GitHub Repository
  3. Add Environment Variables:
    MONGODB_URI=mongodb+srv://...
    JWT_SECRET=your-production-secret
    CORS_ORIGINS=https://ride-pool-strps.vercel.app
  4. Configure Start Command:
    cd backend && pip install -r requirements.txt && uvicorn app.main:socket_app --host 0.0.0.0 --port $PORT
  5. Deploy β€” Railway will auto-deploy on push

Option 2: Render

  1. Create Web Service on Render
  2. Settings:
    • Environment: Python 3
    • Build Command: cd backend && pip install -r requirements.txt
    • Start Command: cd backend && uvicorn app.main:socket_app --host 0.0.0.0 --port $PORT
  3. Add Environment Variables (same as Railway)
  4. Deploy

Database Deployment (MongoDB Atlas)

  1. Create Cluster on MongoDB Atlas
  2. Whitelist IPs or allow access from anywhere (0.0.0.0/0)
  3. Create Database User
  4. Get Connection String:
    mongodb+srv://username:password@cluster.mongodb.net/ridepool?retryWrites=true&w=majority
    
  5. Update MONGODB_URI in backend environment variables
  6. (Optional) Seed Data:
    # Update MONGODB_URI in backend/.env to Atlas URI
    python backend/seed_data/seed.py

Post-Deployment Checklist

  • βœ… Test authentication flow (register, login)
  • βœ… Verify WebSocket connection (check browser console)
  • βœ… Test ride booking and matching
  • βœ… Check CORS settings (ensure frontend can access backend)
  • βœ… Monitor logs for errors
  • βœ… Set up domain (optional)
  • βœ… Enable HTTPS for secure WebSocket connections

πŸ”§ Development Workflow

Setting Up Development Environment

  1. Clone and Install (see Quick Start)
  2. Run Both Servers Concurrently:
    # Terminal 1 - Frontend
    npm run dev
    
    # Terminal 2 - Backend
    cd backend
    source venv/bin/activate  # or venv\Scripts\activate on Windows
    uvicorn app.main:socket_app --reload --port 8888
  3. Hot Reload β€” Both Vite and Uvicorn support hot reloading

Code Formatting and Linting

Frontend:

# Run ESLint
npm run lint

# Fix auto-fixable issues
npm run lint -- --fix

# Type checking
npx tsc --noEmit

Backend:

# Format with Black (if configured)
black backend/app

# Type checking with mypy (if configured)
mypy backend/app

Git Workflow

  1. Create Feature Branch
    git checkout -b feature/your-feature-name
  2. Make Changes β€” Keep commits small and focused
  3. Commit with Meaningful Messages
    git add .
    git commit -m "feat: add ride pooling algorithm"
  4. Push to Remote
    git push origin feature/your-feature-name
  5. Create Pull Request on GitHub

Pull Request Process

  1. Ensure Code Quality:
    • βœ… All linting passes
    • βœ… TypeScript compiles without errors
    • βœ… No console errors in browser
  2. Write Clear PR Description:
    • What does this PR do?
    • Why is this change needed?
    • How to test?
  3. Link Related Issues: Use Fixes #123 or Closes #456
  4. Request Review from maintainers
  5. Address Feedback and update PR
  6. Merge after approval

Testing (if configured)

# Frontend tests
npm run test

# Backend tests
cd backend
pytest

πŸ›  Troubleshooting

MongoDB Connection Errors

Problem: MongoServerError: connect ECONNREFUSED

Solutions:

  • βœ… Ensure MongoDB is running: mongod or start MongoDB service
  • βœ… Check MONGODB_URI in backend .env file
  • βœ… Verify MongoDB is listening on correct port (default: 27017)
  • βœ… For Atlas: Check network access whitelist and credentials

CORS Issues

Problem: Access to XMLHttpRequest blocked by CORS policy

Solutions:

  • βœ… Add frontend URL to CORS_ORIGINS in backend .env:
    CORS_ORIGINS=http://localhost:5173,http://localhost:3000
  • βœ… Restart backend server after changing .env
  • βœ… Check that backend is running on expected port (8888)

WebSocket Connection Problems

Problem: WebSocket not connecting or disconnecting frequently

Solutions:

  • βœ… Verify VITE_WS_URL in frontend .env matches backend URL
  • βœ… Check browser console for WebSocket errors
  • βœ… Ensure backend Socket.IO is properly configured in app/main.py
  • βœ… For production: Use wss:// (secure WebSocket) instead of ws://
  • βœ… Check firewall/proxy settings blocking WebSocket connections

Port Conflicts

Problem: Error: listen EADDRINUSE: address already in use

Solutions:

  • βœ… Frontend (5173):
    # Use different port
    npm run dev -- --port 3000
  • βœ… Backend (8888):
    # Use different port
    uvicorn app.main:socket_app --port 8889
  • βœ… Kill existing process:
    # On macOS/Linux
    lsof -ti:5173 | xargs kill -9
    
    # On Windows
    netstat -ano | findstr :5173
    taskkill /PID <PID> /F

JWT Token Issues

Problem: 401 Unauthorized or Invalid token

Solutions:

  • βœ… Clear browser localStorage and login again
  • βœ… Check token expiration time (ACCESS_TOKEN_EXPIRE_MINUTES)
  • βœ… Verify JWT_SECRET is set in backend .env
  • βœ… Ensure Authorization: Bearer <token> header is sent correctly

Build Failures

Problem: npm run build fails

Solutions:

  • βœ… Delete node_modules and reinstall:
    rm -rf node_modules package-lock.json
    npm install
  • βœ… Check for TypeScript errors: npx tsc --noEmit
  • βœ… Ensure all environment variables are set (even for build)

Python Virtual Environment Issues

Problem: command not found: uvicorn or import errors

Solutions:

  • βœ… Activate virtual environment:
    source venv/bin/activate  # macOS/Linux
    venv\Scripts\activate     # Windows
  • βœ… Reinstall dependencies:
    pip install -r requirements.txt
  • βœ… Verify Python version: python --version (should be 3.10+)

Map Not Displaying

Problem: Leaflet map not rendering

Solutions:

  • βœ… Include Leaflet CSS in index.html or import in component:
    import 'leaflet/dist/leaflet.css';
  • βœ… Check browser console for Leaflet errors
  • βœ… Verify map container has defined height in CSS

Still Having Issues?


🀝 Contributing

See CONTRIBUTING.md for setup, coding standards, and pull request guidance.

πŸ“œ License

Distributed under the MIT License.

πŸ›‘ Security

Security guidelines and reporting instructions are available in SECURITY.md.

πŸ“ Code of Conduct

Participation in this project is governed by the CODE_OF_CONDUCT.md.

πŸ›  Tech Stack

Languages

TypeScript JavaScript Python

Frameworks & Libraries

React Vite FastAPI Leaflet Socket.IO Axios

Databases

MongoDB

DevOps / CI / Tools

ESLint TypeScript GitHub Actions npm Vite

Cloud / Hosting

Self Hosted

πŸ“¦ Dependencies & Packages

Runtime Dependencies

Frontend

react react-dom react-router-dom axios leaflet socket.io-client

Backend

fastapi uvicorn pymongo python-jose bcrypt python-multipart python-socketio python-dotenv pydantic email-validator

Dev / Build / Test Dependencies

typescript vite eslint @typescript-eslint @vitejs/plugin-react @eslint/js eslint-plugin-react-hooks eslint-plugin-react-refresh globals @types/node @types/react @types/react-dom @types/leaflet

No peer or optional dependencies detected.

Made with ❀ by H0NEYP0T-466

About

πŸš— RidePool-STRPS – a smart πŸš€ ride-pooling system ✨ with πŸ“ real-time GPS tracking, 🀝 intelligent ride matching & pooling, πŸ‘₯ multi-role dashboards (Rider/Driver/Admin πŸ“Š), ⚑ Socket.IO live updates πŸ”„, πŸ” JWT authentication, and πŸ“ˆ admin analytics for efficient transportation management 🧩.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published