# rohit-t4756/ecoroute architecture

> Architecture diagram of the GitHub repository rohit-t4756/ecoroute, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohit-t4756/ecoroute
- Repository: https://github.com/rohit-t4756/ecoroute

## Overview

EcoRoute is a Pune-focused route-planning application intended to compare fast and lower-emission journeys, with supporting road-network data ingestion and traffic-model tooling. The visible user flow is location selection in the map UI, route submission to the API, and route-result display; however, the API currently returns a placeholder rather than computing a route, and the displayed impact metrics remain zero. Traffic inference and Redis edge-weight caching exist as a separate bridge, with no shown connection from the route endpoint. Source excerpts are partial, so unverified integrations and links are omitted.

Main entry points: [`app/frontend/src/App.jsx`](https://github.com/rohit-t4756/ecoroute/blob/main/app/frontend/src/App.jsx) (Map and route UI), [`app/main.py`](https://github.com/rohit-t4756/ecoroute/blob/main/app/main.py) (FastAPI gateway), [`scripts/ml_pipeline/inference.py`](https://github.com/rohit-t4756/ecoroute/blob/main/scripts/ml_pipeline/inference.py) (Congestion inference), [`database/init.sql`](https://github.com/rohit-t4756/ecoroute/blob/main/database/init.sql) (PostGIS database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Route client"]
  node_web_app["Map and route UI<br/>[App.jsx]"]
end

subgraph group_api["Route API"]
  node_api_server["FastAPI gateway<br/>[main.py]"]
  node_route_schema["Route request schema<br/>[models.py]"]
end

subgraph group_roads["Road network"]
  node_postgres[("PostGIS database<br/>[init.sql]")]
  node_map_ingest["Road map ingestion<br/>[ingest_map.py]"]
end

subgraph group_traffic["Traffic modeling"]
  node_traffic_bridge["Traffic cache bridge<br/>[ml_service.py]"]
  node_predictor["Congestion inference<br/>[inference.py]"]
  node_onnx_model["ONNX traffic model<br/>[traffic_model.onnx]"]
  node_redis[("Redis edge weights")]
  node_data_fetch["Pune traffic data generator<br/>[fetch_pune_data.py]"]
  node_traffic_csv["Traffic dataset"]
  node_model_training["Model training and export"]
end

node_traveler(("Traveler"))
node_mapbox["Mapbox services"]
node_openstreetmap["OpenStreetMap"]
node_weather["Open-Meteo archive"]

node_traveler -->|"sets locations"| node_web_app
node_web_app -->|"geocodes locations"| node_mapbox
node_web_app -->|"submits route request"| node_api_server
node_api_server -->|"validates request"| node_route_schema
node_api_server -->|"checks node count"| node_postgres
node_openstreetmap -->|"provides road graph"| node_map_ingest
node_map_ingest -->|"writes nodes and edges"| node_postgres
node_traffic_bridge -->|"requests predictions"| node_predictor
node_predictor -->|"loads model"| node_onnx_model
node_predictor -->|"reads edge attributes"| node_postgres
node_traffic_bridge -->|"caches edge weights"| node_redis
node_data_fetch -->|"fetches weather"| node_weather
node_data_fetch -->|"writes dataset"| node_traffic_csv
node_model_training -->|"loads dataset"| node_traffic_csv
node_model_training -->|"exports model"| node_onnx_model

click node_web_app "https://github.com/rohit-t4756/ecoroute/blob/main/app/frontend/src/App.jsx"
click node_api_server "https://github.com/rohit-t4756/ecoroute/blob/main/app/main.py"
click node_route_schema "https://github.com/rohit-t4756/ecoroute/blob/main/app/models.py"
click node_postgres "https://github.com/rohit-t4756/ecoroute/blob/main/database/init.sql"
click node_map_ingest "https://github.com/rohit-t4756/ecoroute/blob/main/scripts/database/ingest_map.py"
click node_traffic_bridge "https://github.com/rohit-t4756/ecoroute/blob/main/app/ml_service.py"
click node_predictor "https://github.com/rohit-t4756/ecoroute/blob/main/scripts/ml_pipeline/inference.py"
click node_onnx_model "https://github.com/rohit-t4756/ecoroute/blob/main/app/ml/traffic_model.onnx"
click node_data_fetch "https://github.com/rohit-t4756/ecoroute/blob/main/scripts/ml_pipeline/fetch_pune_data.py"
click node_traffic_csv "https://github.com/rohit-t4756/ecoroute/blob/main/pune_traffic_data.csv"
click node_model_training "https://github.com/rohit-t4756/ecoroute/blob/main/scripts/ml_pipeline/train_and_export.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_app toneBlue
class node_api_server,node_route_schema toneAmber
class node_postgres,node_map_ingest toneMint
class node_traffic_bridge,node_predictor,node_onnx_model,node_redis,node_data_fetch,node_traffic_csv,node_model_training toneRose
class node_traveler,node_mapbox,node_openstreetmap,node_weather toneIndigo
```

## Components

### Route client

- [Map and route UI](https://github.com/rohit-t4756/ecoroute/blob/main/app/frontend/src/App.jsx): `app/frontend/src/App.jsx`

### Route API

- [FastAPI gateway](https://github.com/rohit-t4756/ecoroute/blob/main/app/main.py): `app/main.py`
- [Route request schema](https://github.com/rohit-t4756/ecoroute/blob/main/app/models.py): `app/models.py`

### Road network

- [PostGIS database](https://github.com/rohit-t4756/ecoroute/blob/main/database/init.sql): `database/init.sql`
- [Road map ingestion](https://github.com/rohit-t4756/ecoroute/blob/main/scripts/database/ingest_map.py): `scripts/database/ingest_map.py`

### Traffic modeling

- [Traffic cache bridge](https://github.com/rohit-t4756/ecoroute/blob/main/app/ml_service.py): `app/ml_service.py`
- [Congestion inference](https://github.com/rohit-t4756/ecoroute/blob/main/scripts/ml_pipeline/inference.py): `scripts/ml_pipeline/inference.py`
- [ONNX traffic model](https://github.com/rohit-t4756/ecoroute/blob/main/app/ml/traffic_model.onnx): `app/ml/traffic_model.onnx`
- **Redis edge weights**
- [Pune traffic data generator](https://github.com/rohit-t4756/ecoroute/blob/main/scripts/ml_pipeline/fetch_pune_data.py): `scripts/ml_pipeline/fetch_pune_data.py`
- [Traffic dataset](https://github.com/rohit-t4756/ecoroute/blob/main/pune_traffic_data.csv): `pune_traffic_data.csv`
- [Model training and export](https://github.com/rohit-t4756/ecoroute/blob/main/scripts/ml_pipeline/train_and_export.py): `scripts/ml_pipeline/train_and_export.py`

### Other components

- **Traveler**
- **Mapbox services**
- **OpenStreetMap**
- **Open-Meteo archive**

## Connections

- Traveler → Map and route UI: sets locations (evidence: `app/frontend/src/App.jsx`)
- Map and route UI → Mapbox services: geocodes locations (evidence: `app/frontend/src/App.jsx`)
- Map and route UI → FastAPI gateway: submits route request (evidence: `app/frontend/src/App.jsx`)
- FastAPI gateway → Route request schema: validates request (evidence: `app/main.py`)
- FastAPI gateway → PostGIS database: checks node count (evidence: `app/main.py`)
- OpenStreetMap → Road map ingestion: provides road graph (evidence: `scripts/database/ingest_map.py`)
- Road map ingestion → PostGIS database: writes nodes and edges (evidence: `scripts/database/ingest_map.py`)
- Traffic cache bridge → Congestion inference: requests predictions (evidence: `app/ml_service.py`)
- Congestion inference → ONNX traffic model: loads model (evidence: `scripts/ml_pipeline/inference.py`)
- Congestion inference → PostGIS database: reads edge attributes (evidence: `scripts/ml_pipeline/inference.py`)
- Traffic cache bridge → Redis edge weights: caches edge weights (evidence: `app/ml_service.py`)
- Pune traffic data generator → Open-Meteo archive: fetches weather (evidence: `scripts/ml_pipeline/fetch_pune_data.py`)
- Pune traffic data generator → Traffic dataset: writes dataset (evidence: `scripts/ml_pipeline/fetch_pune_data.py`)
- Model training and export → Traffic dataset: loads dataset (evidence: `scripts/ml_pipeline/train_and_export.py`)
- Model training and export → ONNX traffic model: exports model (evidence: `scripts/ml_pipeline/train_and_export.py`)
