GitHunt
MO

mohitjain2306/Bus-Distance-Calculator

A practical tool for predicting how far your bus can travel based on current conditions.

๐ŸšŒ Bus Distance Calculator

ML-Powered Bus Range Prediction & Fleet Efficiency System

A web application that predicts how far a bus can travel based on fuel level, load, speed, temperature, and route type โ€” with efficiency insights for fleet management.

Live Demo: https://bus-distance.streamlit.app/


What It Does

Enter details like:

Fuel: 75%, Load: 1200kg, Speed: 65kmph, Temp: 22ยฐC, Route: Highway

And the system will:

  • Predict the distance the bus can travel
  • Score the fuel efficiency
  • Analyze load and temperature impact
  • Give route optimization recommendations
  • Support bulk fleet analysis via CSV upload

Tech Stack

Layer Technology
App Python, Streamlit
ML Model Scikit-learn, Random Forest
Containerization Docker, Docker Compose
Reverse Proxy Nginx
CI/CD GitHub Actions
Deployment Streamlit Cloud

Project Structure

Bus-Distance-Calculator/
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ docker-build.yml   # CI/CD pipeline
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ bus.py                 # main Streamlit app
โ”‚   โ”œโ”€โ”€ main.py                # ML training logic
โ”‚   โ”œโ”€โ”€ fuel_dataset.csv       # training dataset
โ”‚   โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”‚   โ””โ”€โ”€ Dockerfile             # containerises the app
โ”œโ”€โ”€ frontend/
โ”‚   โ””โ”€โ”€ nginx.conf             # reverse proxy config
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ deploy.sh              # one-command local deploy
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ README.md

Run Locally

Without Docker

git clone https://github.com/mohitjain2306/Bus-Distance-Calculator.git
cd Bus-Distance-Calculator
pip install -r backend/requirements.txt
cd backend
streamlit run bus.py

Then open http://localhost:8501

With Docker

git clone https://github.com/mohitjain2306/Bus-Distance-Calculator.git
cd Bus-Distance-Calculator
docker compose up --build

DevOps Setup

Docker

The backend is containerized using Docker. The frontend is served using Nginx.

docker build -t bus-distance-calculator ./backend
docker run -p 8501:8501 bus-distance-calculator

Docker Compose

Runs both frontend and backend together with one command:

docker compose up

CI/CD Pipeline

Every push to main automatically:

  1. Builds the Docker image
  2. Pushes it to DockerHub

DockerHub image: mohitjain2306/bus-distance-calculator


Input Parameters

Parameter Description Example
Fuel Level Current fuel percentage 75%
Vehicle Load Total load in kilograms 1200 kg
Speed Average speed 65 kmph
Temperature Outside temperature 22ยฐC
Route Type Highway, Urban, or Rural Highway

Features

  • Distance Prediction โ€” ML model predicts range based on current conditions
  • Efficiency Scoring โ€” rates fuel efficiency and highlights issues
  • Load Impact Analysis โ€” shows how weight affects performance
  • Route Comparison โ€” highway vs urban vs rural performance
  • Bulk Fleet Analysis โ€” upload CSV to analyse entire fleet at once

Author

Mohit Jain