An AI-powered Electric Vehicle (EV) Trip Optimization System that helps drivers maximize efficiency and range.
The system simulates real-world EV driving conditions, optimizes trip strategy, and visualizes energy usage through interactive charts.
✅ Intuitive Web UI for trip planning
✅ FastAPI backend for serving optimization logic & ML predictions
✅ Input form with real-world trip parameters:
- Distance to travel
- Current Battery %
- Outside & Battery Temperature
- Traffic condition (Light / Medium / Heavy)
- Driving condition (Highway / Intracity / Uphill / Downhill)
- Mode preference (Eco / Normal / Sport / Custom)
- Payload (passengers & luggage)
✅ Output includes:
- ⚙️ Recommended driving settings (Speed, AC %, Regen braking, Acceleration limit)
- 🔋 Predicted range & estimated battery left after trip
- 📊 Optimization summary cards
- 📈 Interactive Visualizations:
- Battery % vs Distance (Line Chart)
- Speed vs Consumption (Scatter/Line Chart)
- Mode Comparison (Bar Chart)
- Energy Breakdown (Pie Chart)
- Projected Range (Gauge Chart)
✅ Future-ready:
- Integrate ML model (Regression + Optimization algorithms)
- Support live telemetry and map-based simulation
- Frontend: HTML, JavaScript, Plotly.js (charts), Axios (API calls)
- Backend: FastAPI (Python), Uvicorn
- Machine Learning (Planned): Scikit-learn / TensorFlow / PyTorch
- Database (Planned): PostgreSQL / SQLite (for trip history & training data)
- Deployment: Docker, Cloud (AWS/GCP/Render)
- User enters trip details on the frontend form
- Data sent to FastAPI backend via REST API
- Backend applies:
- Rule-based optimization (initial version)
- ML-powered prediction (future upgrade)
- Results returned as:
- JSON with recommended settings
- Numerical predictions (range, battery left)
- Frontend renders:
- Optimization summary cards
- Dynamic interactive graphs using Plotly.js
-
Frontend Module
FormHandler→ Collects user input & validates dataAPICaller→ Sends request to backend using AxiosChartManager→ Renders Plotly.js chartsUIManager→ Displays results in structured format
-
Backend Module (FastAPI)
InputModel(Pydantic) → Schema validationOptimizationEngine→ Core logic for speed, AC, regen brakingMLModelHandler(Future) → Loads trained ML model for predictionsResponseBuilder→ Formats output JSON
-
Data Layer
- Planned: Store historical trips for ML training (SQLite/PostgreSQL)
User → Frontend Form → APICaller → FastAPI Endpoint (/optimize)
→ OptimizationEngine → MLModelHandler (future)
→ ResponseBuilder → JSON Response → ChartManager → UI
class TripInput(BaseModel):
distance_km: float
battery_percent: float
outside_temp: float
battery_temp: float
traffic: str
driving: str
mode: str
payload: float
class OptimizationEngine:
def __init__(self, data: TripInput):
self.data = data
def compute_settings(self) -> dict:
# Logic for speed, AC %, regen braking
...
def predict_range(self) -> float:
# Formula/ML prediction
...
def estimate_battery_left(self) -> float:
...
class ResponseBuilder:
def __init__(self, settings, range_val, battery_left):
self.settings = settings
self.range_val = range_val
self.battery_left = battery_left
def to_dict(self):
return {
"recommended_settings": self.settings,
"predicted_range": self.range_val,
"battery_left": self.battery_left
}{
"recommended_settings": {
"speed": 55,
"ac": 25,
"regen": "Medium",
"acceleration_limit": "Low"
},
"predicted_range": 178.5,
"battery_left": 45.0
}cd backend
pip install fastapi uvicorn pydantic
uvicorn main:app --reload --port 8000Backend runs at 👉 http://127.0.0.1:8000
Open frontend/index.html in your browser.
It connects to the backend API automatically.
- ✅ ML model integration for range prediction & optimal strategy
- ✅ Trip history database for personalized recommendations
- ✅ Google Maps API integration for real routes
- ✅ Real-time driving telemetry simulation
- ✅ Mobile app (React Native / Flutter)