A machine learning-powered ride-hailing platform backend with intelligent demand forecasting and surge pricing capabilities.
NoCapRide provides a robust backend API for ride-hailing platforms, focusing on:
- Machine learning-powered demand prediction
- Dynamic surge pricing
- Real-time data processing
- Spatial demand analysis
The system helps both riders and drivers by balancing supply and demand through intelligent forecasting.
NoCapRide/
├── cache/ # Cached forecasts and API responses (auto-generated)
│ └── forecasts/ # Stored forecast data
├── server/ # Backend server modules
│ ├── api.py # API endpoints
│ ├── cache_manager.py # Cache management logic
│ ├── custom_logger.py # Custom logging setup
│ ├── data_manager.py # Data management logic
│ └── forecaster.py # Forecasting logic
├── archive/ # Development history
│ ├── attempt-1/ # Initial implementation
│ ├── attempt-2/ # Second iteration with fetch module
│ ├── attempt-3/ # Third iteration
│ ├── data/ # Archive data files
│ └── static-data/ # Static reference data
├── client/ # Frontend client application
│ ├── app/ # Next.js app directory
│ ├── components/ # React components
│ ├── lib/ # Shared utilities
│ ├── public/ # Static assets
│ ├── README.md # Frontend documentation
│ ├── package.json # Frontend dependencies
│ ├── next.config.ts # Next.js configuration
│ └── components.json # Component configurations
├── logs/ # Application logs
│ ├── api_log.txt # API service logs
│ ├── forecast_log.txt # Forecasting engine logs
│ └── forecast_output.log # Forecast results
├── ... other default files
- Time-series forecasting for ride requests by region
- Historical trend analysis
- Feature engineering for temporal patterns
- Random Forest regression model for prediction
- Dynamic pricing based on supply-demand ratio
- Configurable pricing parameters
- Region-specific pricing adjustments
- Real-time price calculation API
- Nearby high-demand area recommendations
- Region-based demand visualization
- Geographic demand patterns detection
GET /api/forecast
- Get demand forecast for specified region and time windowGET /api/forecast/all
- Get forecasts for all regionsGET /api/regions
- Get available regions for forecasting
POST /api/surge_pricing
- Calculate surge pricing for a specific tripPOST /api/demand_forecast_ratio
- Get the ratio between forecasted demand and active drivers
GET /api/nearby_high_demand
- Get high-demand locations near a specified region
GET /api/health
- Health check endpoint
-
Install Python dependencies:
pip install -r requirements.txt
-
Start the FastAPI server:
uvicorn api:app --host 127.0.0.1 --port 8888 --reload
-
Access the API documentation:
http://127.0.0.1:8888/docs
The system is configured to:
- Refresh data from endpoints automatically
- Cache forecast results for performance
- Train/update models on a schedule
- Generate visualizations of forecasts
The system uses:
- FastAPI: Modern, high-performance web framework
- pandas: Data manipulation and analysis
- scikit-learn: Machine learning model implementation
- matplotlib: Data visualization
- Threading: Parallel processing for forecasts
This project is licensed under the MPL v2 License.