# rohit-t4756/temp_ecoroute architecture

> Architecture diagram of the GitHub repository rohit-t4756/temp_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/temp_ecoroute
- Repository: https://github.com/rohit-t4756/temp_ecoroute

## Overview

EcoRoute accepts a map-based route request, evaluates it through FastAPI and a Python gRPC gateway, and returns distinct C++-calculated routes with physical metrics and geometry. Its main stages are road-network snapshot preparation, traffic-factor publication, request caching and dispatch, and CCH routing. The graph also shows internal graph, cost and search layers. Several subsystem links rely on README descriptions because their implementation files were not excerpted; unsampled internals are not inferred beyond those documented relationships.

Main entry points: [`app/main.py`](https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/main.py) (FastAPI gateway), [`routing-engine/src/engine.cpp`](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/engine.cpp) (Route engine), [`routing-engine/integration/grpc_server.py`](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/integration/grpc_server.py) (gRPC gateway), [`routing-engine/src/graph/graph_loader.hpp`](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/graph/graph_loader.hpp) (Snapshot graph loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Route interface"]
  node_frontend["Map interface<br/>[App.jsx]"]
end

subgraph group_services["API and traffic services"]
  node_api["FastAPI gateway<br/>[main.py]"]
  node_api_models["Route request models<br/>[models.py]"]
  node_response_cache[("Route response cache<br/>[main.py]")]
  node_grpc_gateway["gRPC gateway<br/>[grpc_server.py]"]
  node_grpc_transport["gRPC transport<br/>[grpc_transport.py]"]
  node_engine_client["Worker client pool<br/>[engine_client.py]"]
  node_redis_adapter["Traffic adapter"]
end

subgraph group_engine["C++ routing engine"]
  node_graph_loader["Snapshot graph loader<br/>[graph_loader.hpp]"]
  node_road_network["Physical road network<br/>[road_network.hpp]"]
  node_routing_graph["CSR routing graph<br/>[routing_graph.hpp]"]
  node_engine["Route engine<br/>[engine.cpp]"]
  node_snapshot_manager["Metric snapshots"]
  node_cost_model["Profile cost model<br/>[cost_model.cpp]"]
  node_cch_order["CCH node order<br/>[cch_order.hpp]"]
  node_preprocessor["CCH preprocessor"]
  node_alternatives["Route alternatives<br/>[alternatives.cpp]"]
  node_cch_search["CCH search adapter<br/>[cch_adapter.cpp]"]
  node_route_cli["Persistent C++ worker<br/>[route_cli.cpp]"]
end

subgraph group_data["Network and ML data"]
  node_ml_service["Traffic publisher<br/>[ml_service.py]"]
  node_ml_inference["ONNX inference<br/>[inference.py]"]
  node_snapshot_prep["Graph snapshot preparation<br/>[prepare_graph.py]"]
end

node_user(("Route user"))
node_mapbox["Mapbox geocoder"]
node_postgis[("PostGIS network")]
node_redis[("Redis traffic and cache")]

node_user -->|"sets route request"| node_frontend
node_frontend -->|"geocodes places"| node_mapbox
node_frontend -->|"requests routes"| node_api
node_api -->|"validates request"| node_api_models
node_api -->|"reads and writes"| node_response_cache
node_api -->|"queries status"| node_postgis
node_api -->|"dispatches RPC"| node_grpc_gateway
node_grpc_gateway -->|"uses transport"| node_grpc_transport
node_grpc_gateway -->|"dispatches requests"| node_engine_client
node_grpc_gateway -->|"registers updates"| node_redis_adapter
node_redis_adapter -->|"reads traffic batches"| node_redis
node_ml_service -->|"calculates factors"| node_ml_inference
node_ml_service -->|"publishes traffic"| node_redis
node_snapshot_prep -->|"reads road data"| node_postgis
node_snapshot_prep -->|"exports snapshots"| node_graph_loader
node_preprocessor -->|"prepares node order"| node_cch_order
node_engine_client -->|"runs workers"| node_route_cli
node_route_cli -->|"invokes engine"| node_engine
node_engine -->|"loads snapshot"| node_graph_loader
node_graph_loader -->|"constructs network"| node_road_network
node_graph_loader -->|"constructs CSR graph"| node_routing_graph
node_engine -->|"manages traffic metrics"| node_snapshot_manager
node_snapshot_manager -->|"prepares profile metrics"| node_cost_model
node_engine -->|"selects alternatives"| node_alternatives
node_alternatives -->|"searches candidate paths"| node_cch_search
node_engine -->|"customizes and searches"| node_cch_search

click node_frontend "https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/frontend/src/App.jsx"
click node_api "https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/main.py"
click node_api_models "https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/models.py"
click node_response_cache "https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/main.py"
click node_grpc_gateway "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/integration/grpc_server.py"
click node_grpc_transport "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/integration/grpc_transport.py"
click node_engine_client "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/integration/engine_client.py"
click node_redis_adapter "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/integration/redis_traffic_adapter.py"
click node_ml_service "https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/ml_service.py"
click node_ml_inference "https://github.com/rohit-t4756/temp_ecoroute/blob/main/scripts/ml_pipeline/inference.py"
click node_snapshot_prep "https://github.com/rohit-t4756/temp_ecoroute/blob/main/scripts/integration/prepare_graph.py"
click node_graph_loader "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/graph/graph_loader.hpp"
click node_road_network "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/graph/road_network.hpp"
click node_routing_graph "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/graph/routing_graph.hpp"
click node_engine "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/engine.cpp"
click node_snapshot_manager "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/runtime/snapshot_manager.cpp"
click node_cost_model "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/cost/cost_model.cpp"
click node_cch_order "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/search/cch_order.hpp"
click node_preprocessor "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/apps/preprocess_main.cpp"
click node_alternatives "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/search/alternatives.cpp"
click node_cch_search "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/search/cch_adapter.cpp"
click node_route_cli "https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/apps/route_cli.cpp"

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_frontend,node_user toneBlue
class node_api,node_api_models,node_response_cache,node_grpc_gateway,node_grpc_transport,node_engine_client,node_redis_adapter,node_postgis,node_redis toneAmber
class node_graph_loader,node_road_network,node_routing_graph,node_engine,node_snapshot_manager,node_cost_model,node_cch_order,node_preprocessor,node_alternatives,node_cch_search,node_route_cli toneMint
class node_ml_service,node_ml_inference,node_snapshot_prep toneRose
class node_mapbox toneIndigo
```

## Components

### Route interface

- [Map interface](https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/frontend/src/App.jsx): `app/frontend/src/App.jsx`

### API and traffic services

- [FastAPI gateway](https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/main.py): `app/main.py`
- [Route request models](https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/models.py): `app/models.py`
- [Route response cache](https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/main.py): `app/main.py`
- [gRPC gateway](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/integration/grpc_server.py): `routing-engine/integration/grpc_server.py`
- [gRPC transport](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/integration/grpc_transport.py): `routing-engine/integration/grpc_transport.py`
- [Worker client pool](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/integration/engine_client.py): `routing-engine/integration/engine_client.py`
- [Traffic adapter](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/integration/redis_traffic_adapter.py): `routing-engine/integration/redis_traffic_adapter.py`

### C++ routing engine

- [Snapshot graph loader](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/graph/graph_loader.hpp): `routing-engine/src/graph/graph_loader.hpp`
- [Physical road network](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/graph/road_network.hpp): `routing-engine/src/graph/road_network.hpp`
- [CSR routing graph](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/graph/routing_graph.hpp): `routing-engine/src/graph/routing_graph.hpp`
- [Route engine](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/engine.cpp): `routing-engine/src/engine.cpp`
- [Metric snapshots](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/runtime/snapshot_manager.cpp): `routing-engine/src/runtime/snapshot_manager.cpp`
- [Profile cost model](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/cost/cost_model.cpp): `routing-engine/src/cost/cost_model.cpp`
- [CCH node order](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/search/cch_order.hpp): `routing-engine/src/search/cch_order.hpp`
- [CCH preprocessor](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/apps/preprocess_main.cpp): `routing-engine/apps/preprocess_main.cpp`
- [Route alternatives](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/search/alternatives.cpp): `routing-engine/src/search/alternatives.cpp`
- [CCH search adapter](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/src/search/cch_adapter.cpp): `routing-engine/src/search/cch_adapter.cpp`
- [Persistent C++ worker](https://github.com/rohit-t4756/temp_ecoroute/blob/main/routing-engine/apps/route_cli.cpp): `routing-engine/apps/route_cli.cpp`

### Network and ML data

- [Traffic publisher](https://github.com/rohit-t4756/temp_ecoroute/blob/main/app/ml_service.py): `app/ml_service.py`
- [ONNX inference](https://github.com/rohit-t4756/temp_ecoroute/blob/main/scripts/ml_pipeline/inference.py): `scripts/ml_pipeline/inference.py`
- [Graph snapshot preparation](https://github.com/rohit-t4756/temp_ecoroute/blob/main/scripts/integration/prepare_graph.py): `scripts/integration/prepare_graph.py`

### Other components

- **Route user**
- **Mapbox geocoder**
- **PostGIS network**
- **Redis traffic and cache**

## Connections

- Route user → Map interface: sets route request (evidence: `README.md`)
- Map interface → Mapbox geocoder: geocodes places (evidence: `app/frontend/src/App.jsx`)
- Map interface → FastAPI gateway: requests routes (evidence: `README.md`)
- FastAPI gateway → Route request models: validates request (evidence: `app/main.py`)
- FastAPI gateway → Route response cache: reads and writes (evidence: `app/main.py`)
- FastAPI gateway → PostGIS network: queries status (evidence: `app/main.py`)
- FastAPI gateway → gRPC gateway: dispatches RPC (evidence: `app/main.py`)
- gRPC gateway → gRPC transport: uses transport (evidence: `routing-engine/integration/grpc_server.py`)
- gRPC gateway → Worker client pool: dispatches requests (evidence: `routing-engine/integration/grpc_server.py`)
- gRPC gateway → Traffic adapter: registers updates (evidence: `routing-engine/integration/grpc_server.py`)
- Traffic adapter → Redis traffic and cache: reads traffic batches (evidence: `README.md`)
- Traffic publisher → ONNX inference: calculates factors (evidence: `app/ml_service.py`)
- Traffic publisher → Redis traffic and cache: publishes traffic (evidence: `README.md`)
- Graph snapshot preparation → PostGIS network: reads road data (evidence: `README.md`)
- Graph snapshot preparation → Snapshot graph loader: exports snapshots (evidence: `README.md`)
- CCH preprocessor → CCH node order: prepares node order (evidence: `README.md`)
- Worker client pool → Persistent C++ worker: runs workers (evidence: `README.md`)
- Persistent C++ worker → Route engine: invokes engine (evidence: `routing-engine/apps/route_cli.cpp`)
- Route engine → Snapshot graph loader: loads snapshot (evidence: `routing-engine/src/engine.cpp`)
- Snapshot graph loader → Physical road network: constructs network (evidence: `routing-engine/src/graph/graph_loader.hpp`)
- Snapshot graph loader → CSR routing graph: constructs CSR graph (evidence: `routing-engine/src/graph/graph_loader.hpp`)
- Route engine → Metric snapshots: manages traffic metrics (evidence: `routing-engine/src/engine.cpp`)
- Metric snapshots → Profile cost model: prepares profile metrics
- Route engine → Route alternatives: selects alternatives (evidence: `routing-engine/src/engine.cpp`)
- Route alternatives → CCH search adapter: searches candidate paths (evidence: `routing-engine/src/search/alternatives.cpp`)
- Route engine → CCH search adapter: customizes and searches (evidence: `routing-engine/src/engine.cpp`)
