Skip to content

Navigation Menu

Sign in
Sign up

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ELD Route Planner ๐Ÿš›โ›ฝ

A full-stack route planning and fuel optimization application built with React + Vite on the frontend and Django REST Framework on the backend.

The application helps commercial drivers plan trips by calculating routes and generating optimized fuel stop recommendations while considering vehicle constraints such as fuel efficiency and driving range.


๐ŸŒ Live Demo

Frontend (React + Vite + Vercel)

https://eld-route-planner-murex.vercel.app/

Backend API (Django REST Framework + PythonAnywhere)

https://samavi96.pythonanywhere.com/api/


๐Ÿ“Œ Project Overview

The ELD Route Planner simulates an Electronic Logging Device (ELD) workflow for commercial transportation.

Users provide:

  • Current location
  • Pickup location
  • Dropoff location
  • Current driving cycle usage

The system processes the trip and returns an optimized route plan with fuel stop recommendations.

The optimization logic focuses on:

  • Keeping the vehicle within its maximum driving range
  • Selecting suitable fuel stops
  • Minimizing fuel expenses
  • Providing a practical trip plan for drivers

๐Ÿ—๏ธ Application Architecture

 User
 |
 |
 v
 React Frontend (Vite)
 Hosted on Vercel
 |
 |
 REST API Calls
 |
 |
 v
 Django REST Framework Backend
 Hosted on PythonAnywhere
 |
 |
 ------------------
 | |
 v v
 Trip Management Fuel Optimization
 API Logic
 |
 v
 Database

โœจ Features

๐Ÿš› Trip Planning

Users can submit:

  • Current location
  • Pickup location
  • Dropoff location
  • Current cycle usage

The backend creates and processes the trip request.


โ›ฝ Fuel Optimization

The application determines suitable fuel stops based on:

  • Route distance
  • Vehicle fuel economy
  • Fuel requirements
  • Available fuel stations
  • Fuel prices

The goal is to produce a cost-efficient and feasible trip plan.


๐Ÿ—บ๏ธ Route Visualization

The frontend provides an interactive interface for viewing trip information and optimized results.


๐ŸŒ Full-Stack Deployment

The application is deployed using:

Frontend:

  • React
  • Vite
  • Vercel

Backend:

  • Django
  • Django REST Framework
  • PythonAnywhere

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React 19
  • Vite
  • JavaScript
  • Leaflet
  • React Leaflet
  • Tailwind CSS
  • Framer Motion

Backend

  • Python
  • Django 6
  • Django REST Framework
  • SQLite
  • django-cors-headers

Deployment

Component Platform
Frontend Vercel
Backend PythonAnywhere
Database SQLite

๐Ÿ“‚ Project Structure

eld-app/
โ”œโ”€โ”€ eld_backend/
โ”‚
โ”‚ โ”œโ”€โ”€ manage.py
โ”‚ โ”œโ”€โ”€ requirements.txt
โ”‚ โ”œโ”€โ”€ db.sqlite3
โ”‚ โ”‚
โ”‚ โ”œโ”€โ”€ eld_backend/
โ”‚ โ”‚ โ”œโ”€โ”€ settings.py
โ”‚ โ”‚ โ”œโ”€โ”€ urls.py
โ”‚ โ”‚ โ””โ”€โ”€ wsgi.py
โ”‚ โ”‚
โ”‚ โ””โ”€โ”€ trips/
โ”‚ โ”œโ”€โ”€ models.py
โ”‚ โ”œโ”€โ”€ serializers.py
โ”‚ โ”œโ”€โ”€ views.py
โ”‚ โ””โ”€โ”€ urls.py
โ”‚
โ”‚
โ””โ”€โ”€ frontend/
 โ”‚
 โ”œโ”€โ”€ package.json
 โ”œโ”€โ”€ vite.config.js
 โ”‚
 โ””โ”€โ”€ src/
 โ”œโ”€โ”€ api.js
 โ”œโ”€โ”€ App.jsx
 โ””โ”€โ”€ components/

๐Ÿš€ Local Development Setup

Backend Setup

Clone the repository:

git clone https://github.com/samavinasir/eld-route-planner.git

Navigate to backend:

cd eld_backend

Create virtual environment:

python -m venv venv

Activate environment:

Windows

venv\Scripts\activate

Linux / Mac

source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Apply migrations:

python manage.py migrate

Start development server:

python manage.py runserver

Backend will run at:

http://localhost:8000

Frontend Setup

Navigate to frontend:

cd frontend

Install dependencies:

npm install

Create environment file:

.env

Add:

VITE_API_URL=http://localhost:8000/api

Start React development server:

npm run dev

Frontend will run at:

http://localhost:5173

๐Ÿ”Œ API Documentation

Create Trip

Creates a new trip and generates an optimized route plan.

Endpoint

POST /api/trips/

Production URL:

https://samavi96.pythonanywhere.com/api/trips/

Request Body

Example:

{
 "current_location": "Los Angeles, CA",
 "pickup_location": "Dallas, TX",
 "dropoff_location": "New York, NY",
 "current_cycle_used": 0
}

Response

Example:

{
 "id": 1,
 "current_location": "Los Angeles, CA",
 "pickup_location": "Dallas, TX",
 "dropoff_location": "New York, NY",
 "fuel_stops": [],
 "total_distance": 2987.5
}

Retrieve Trip

Endpoint

GET /api/trips/<id>/

Example:

https://samavi96.pythonanywhere.com/api/trips/1/

โš™๏ธ Environment Variables

Frontend

File:

frontend/.env

Example:

VITE_API_URL=https://samavi96.pythonanywhere.com/api

Backend

Important Django settings:

SECRET_KEY
DEBUG
ALLOWED_HOSTS
CORS_ALLOWED_ORIGINS

Production example:

ALLOWED_HOSTS = [
 "samavi96.pythonanywhere.com"
]
CORS_ALLOWED_ORIGINS = [
 "https://eld-route-planner-murex.vercel.app"
]

๐Ÿงช Testing

Django System Check

Run:

python manage.py check

Expected:

System check identified no issues.

API Testing

Using Postman:

Method:

POST

URL:

https://samavi96.pythonanywhere.com/api/trips/

Headers:

Content-Type: application/json

Body:

{
 "current_location": "Los Angeles, CA",
 "pickup_location": "Dallas, TX",
 "dropoff_location": "New York, NY",
 "current_cycle_used": 0
}

๐ŸŒ Deployment

Backend Deployment (PythonAnywhere)

Deployment steps:

  1. Upload or clone repository
  2. Create virtual environment
  3. Install requirements
  4. Configure WSGI file
  5. Run migrations
  6. Configure allowed hosts and CORS
  7. Reload web application

Frontend Deployment (Vercel)

Deployment steps:

  1. Connect GitHub repository
  2. Select frontend directory
  3. Choose Vite framework
  4. Add environment variable:
VITE_API_URL=https://samavi96.pythonanywhere.com/api
  1. Deploy

Build command:

npm run build

Output directory:

dist

๐Ÿ“ธ Screenshots

Add application screenshots here:

screenshots/
โ”œโ”€โ”€ homepage.png
โ”œโ”€โ”€ trip-input.png
โ”œโ”€โ”€ route-results.png
โ””โ”€โ”€ map-view.png

๐Ÿ”ฎ Future Improvements

Possible improvements:

  • PostgreSQL production database
  • Authentication and user accounts
  • Driver dashboard
  • Trip history
  • Real-time fuel price updates
  • Improved map visualization
  • Cloud-based background processing
  • More advanced optimization algorithms

๐Ÿ‘จโ€๐Ÿ’ป Author

Samavi Nasir

Full Stack Developer | AI Engineer & Bioinformatics Developer

GitHub:

https://github.com/samavinasir96


๐Ÿ“„ License

This project was developed as a full-stack technical assessment and portfolio project.

About

A full-stack route planning and fuel optimization application built with React + Vite on the frontend and Django REST Framework on the backend. The application helps commercial drivers plan trips by calculating routes and generating optimized fuel stop recommendations while considering vehicle constraints such as fuel efficiency and driving range.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle ใซใ‚ˆใฃใฆๅค‰ๆ›ใ•ใ‚ŒใŸใƒšใƒผใ‚ธ (->ใ‚ชใƒชใ‚ธใƒŠใƒซ) /