Here’s an updated version of the README to reflect the latest API structure and changes:
This project simulates the routing of electric vehicles (EVs) from one point to another, considering key factors like battery consumption, charging stations, and road networks. The frontend uses Leaflet.js for map visualization, and the backend is powered by Python (Flask) to handle routing algorithms, battery simulation, charging station management, and more.
The project is being developed iteratively, starting with simple point-to-point navigation and expanding to include dynamic routing, charging station management, and real-time EV data.
Demo Link: (URL to go here)
Screenshots:
(Insert demo screenshots here)
ev-routing/
│
├── /app/ # Python backend application
│ ├── __init__.py # Initializes Flask app and imports routes
│ ├── api.py # Defines the HTTP API endpoints
│ ├── /services # Contains business logic for route planning
│ │ └── route_service.py # Logic for battery management and routing
│ ├── /models # Data models
│ │ └── route.py # Charging station data
│ ├── /utils # Utility functions
│ │ └── math_utils.py # Distance calculations and battery usage
│ └── requirements.txt # Backend dependencies
│
├── frontend/ # Frontend code (Leaflet.js, HTML, CSS)
│ ├── index.html # Main UI with Leaflet.js
│ ├── map.js # JavaScript logic for frontend
│ └── styles.css # Frontend styling
│
└── README.md # Project documentation
Clone the repository and navigate to the app
directory.
git clone <repo-url>
cd ev-routing/app
Create a virtual environment and install dependencies.
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Run the Flask server.
python app.py
The backend will run on http://127.0.0.1:5000
.
Navigate to the frontend
directory.
cd ../frontend
Open the index.html
file in your browser or run a local server.
python -m http.server 8000
The frontend will be available at http://localhost:8000
.
The project will be developed iteratively, with the following planned features:
If you'd like to contribute to this project, feel free to submit issues or pull requests! We welcome ideas for new features, improvements to the routing algorithms, and code optimizations.
This project is licensed under the MIT License. See the LICENSE file for details.
The backend provides several endpoints for interacting with the EV routing system:
/route
GET
/route?start=<latitude,longitude>&end=<latitude,longitude>&battery_range=<battery_range>
start
: The starting point of the route, represented as latitude,longitude
.end
: The destination point, represented as latitude,longitude
.battery_range
: Optional parameter, representing the EV's battery range in miles (default: 100 miles).GET /route?start=37.7749,-122.4194&end=34.0522,-118.2437&battery_range=100
{
"start": [37.7749, -122.4194],
"end": [34.0522, -118.2437],
"route": [
{
"location": [37.7749, -122.4194],
"action": "Drive",
"distance_to_next": 100.0,
"speed": 60,
"travel_time_hours": 1.6667
},
{
"location": [36.16, -115.15],
"action": "Charge",
"type": "Regular Charger",
"distance_to_next": 50.0,
"charging_time_hours": 1.0
},
{
"location": [34.0522, -118.2437],
"action": "Drive",
"distance_to_next": 150.0,
"speed": 60,
"travel_time_hours": 2.5
}
]
}