# mzuhaibkhan/route_router architecture

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

- Interactive diagram: https://gitdiagram.com/mzuhaibkhan/route_router
- Repository: https://github.com/mzuhaibkhan/route_router

## Overview

Route Radar is a freight-corridor weather-risk product: dispatchers submit an origin, destination, load weight, and departure time; the service compares routes, samples weather along each corridor, applies vehicle-sensitive risk rules, and returns route recommendations and map-ready risk data. The graph preserves the documented forecast, heatmap, departure-window, demo, and UI capabilities. Some backend wiring is supported by the README and source references rather than complete excerpts; uncertain links are omitted.

Main entry points: [`backend/api/views.py`](https://github.com/mzuhaibkhan/route_router/blob/main/backend/api/views.py) (API controller), [`frontend/src/App.jsx`](https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/App.jsx) (Application shell), [`backend/services/weather.py`](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/weather.py) (Weather forecasts), [`backend/services/data_types.py`](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/data_types.py) (Analysis data models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Dispatcher application"]
  node_app["Application shell<br/>[App.jsx]"]
  node_routeform["Route form<br/>[RouteForm.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_map["Risk map<br/>[MapView.jsx]"]
  node_routecards["Route comparison<br/>[RouteCards.jsx]"]
  node_forecast["Forecast slider<br/>[ForecastSlider.jsx]"]
  node_checkpoints_ui["Checkpoint details"]
  node_sandbox["Risk sandbox<br/>[RiskSandbox.jsx]"]
end

subgraph group_api["API and coordination"]
  node_api_views["API controller<br/>[views.py]"]
  node_serializers["Input validation<br/>[serializers.py]"]
end

subgraph group_analysis["Route risk analysis"]
  node_geocoding["Geocoding<br/>[geocoding.py]"]
  node_routing["Alternative routing<br/>[routing.py]"]
  node_checkpoints["Checkpoint sampling<br/>[checkpoints.py]"]
  node_weather["Weather forecasts<br/>[weather.py]"]
  node_risk["Risk classification<br/>[risk_engine.py]"]
  node_recommendation["Route recommendation<br/>[recommendation.py]"]
  node_heatmap["Corridor heatmap<br/>[heatmap.py]"]
  node_departure["Departure windows<br/>[departure.py]"]
  node_cache["Cache utilities<br/>[cache_utils.py]"]
  node_data_types["Analysis data models<br/>[data_types.py]"]
end

subgraph group_providers["External providers"]
  node_ors["OpenRouteService"]
  node_openmeteo["Open-Meteo"]
end

node_dispatcher(("Dispatcher"))

node_dispatcher -->|"uses"| node_app
node_app -->|"presents"| node_routeform
node_routeform -->|"submits route"| node_api_client
node_app -->|"requests analysis"| node_api_client
node_api_client -->|"calls API"| node_api_views
node_api_views -->|"validates input"| node_serializers
node_serializers -->|"resolves addresses"| node_geocoding
node_api_views -->|"serves autocomplete"| node_geocoding
node_geocoding -->|"geocodes places"| node_ors
node_api_views -->|"requests routes"| node_routing
node_routing -->|"requests directions"| node_ors
node_api_views -->|"samples routes"| node_checkpoints
node_api_views -->|"fetches forecasts"| node_weather
node_weather -->|"fetches hourly data"| node_openmeteo
node_api_views -->|"assesses checkpoint risk"| node_risk
node_weather -->|"provides readings"| node_risk
node_api_views -->|"ranks routes"| node_recommendation
node_api_views -->|"precomputes heatmap"| node_heatmap
node_api_views -->|"optimizes departure"| node_departure
node_api_views -->|"caches analysis"| node_cache
node_api_views -->|"builds results"| node_data_types
node_risk -->|"produces risk records"| node_data_types
node_weather -->|"parses readings"| node_data_types
node_checkpoints -->|"creates checkpoints"| node_data_types
node_app -->|"renders corridor"| node_map
node_app -->|"shows alternatives"| node_routecards
node_app -->|"scrubs forecast"| node_forecast
node_app -->|"shows checkpoints"| node_checkpoints_ui
node_app -->|"presents risk tools"| node_sandbox
node_forecast -->|"updates hour"| node_map

click node_app "https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/App.jsx"
click node_routeform "https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/RouteForm/RouteForm.jsx"
click node_api_client "https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/services/api.js"
click node_map "https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/MapView/MapView.jsx"
click node_routecards "https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/RouteCards/RouteCards.jsx"
click node_forecast "https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/ForecastSlider/ForecastSlider.jsx"
click node_checkpoints_ui "https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/CheckpointTable/CheckpointTable.jsx"
click node_sandbox "https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/RiskSandbox/RiskSandbox.jsx"
click node_api_views "https://github.com/mzuhaibkhan/route_router/blob/main/backend/api/views.py"
click node_serializers "https://github.com/mzuhaibkhan/route_router/blob/main/backend/api/serializers.py"
click node_geocoding "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/geocoding.py"
click node_routing "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/routing.py"
click node_checkpoints "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/checkpoints.py"
click node_weather "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/weather.py"
click node_risk "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/risk_engine.py"
click node_recommendation "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/recommendation.py"
click node_heatmap "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/heatmap.py"
click node_departure "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/departure.py"
click node_cache "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/cache_utils.py"
click node_data_types "https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/data_types.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_app,node_routeform,node_api_client,node_map,node_routecards,node_forecast,node_checkpoints_ui,node_sandbox toneBlue
class node_api_views,node_serializers toneAmber
class node_geocoding,node_routing,node_checkpoints,node_weather,node_risk,node_recommendation,node_heatmap,node_departure,node_cache,node_data_types toneMint
class node_ors,node_openmeteo toneRose
class node_dispatcher toneIndigo
```

## Components

### Dispatcher application

- [Application shell](https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Route form](https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/RouteForm/RouteForm.jsx): `frontend/src/components/RouteForm/RouteForm.jsx`
- [API client](https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Risk map](https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/MapView/MapView.jsx): `frontend/src/components/MapView/MapView.jsx`
- [Route comparison](https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/RouteCards/RouteCards.jsx): `frontend/src/components/RouteCards/RouteCards.jsx`
- [Forecast slider](https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/ForecastSlider/ForecastSlider.jsx): `frontend/src/components/ForecastSlider/ForecastSlider.jsx`
- [Checkpoint details](https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/CheckpointTable/CheckpointTable.jsx): `frontend/src/components/CheckpointTable/CheckpointTable.jsx`
- [Risk sandbox](https://github.com/mzuhaibkhan/route_router/blob/main/frontend/src/components/RiskSandbox/RiskSandbox.jsx): `frontend/src/components/RiskSandbox/RiskSandbox.jsx`

### API and coordination

- [API controller](https://github.com/mzuhaibkhan/route_router/blob/main/backend/api/views.py): `backend/api/views.py`
- [Input validation](https://github.com/mzuhaibkhan/route_router/blob/main/backend/api/serializers.py): `backend/api/serializers.py`

### Route risk analysis

- [Geocoding](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/geocoding.py): `backend/services/geocoding.py`
- [Alternative routing](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/routing.py): `backend/services/routing.py`
- [Checkpoint sampling](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/checkpoints.py): `backend/services/checkpoints.py`
- [Weather forecasts](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/weather.py): `backend/services/weather.py`
- [Risk classification](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/risk_engine.py): `backend/services/risk_engine.py`
- [Route recommendation](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/recommendation.py): `backend/services/recommendation.py`
- [Corridor heatmap](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/heatmap.py): `backend/services/heatmap.py`
- [Departure windows](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/departure.py): `backend/services/departure.py`
- [Cache utilities](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/cache_utils.py): `backend/services/cache_utils.py`
- [Analysis data models](https://github.com/mzuhaibkhan/route_router/blob/main/backend/services/data_types.py): `backend/services/data_types.py`

### External providers

- **OpenRouteService**
- **Open-Meteo**

### Other components

- **Dispatcher**

## Connections

- Dispatcher → Application shell: uses
- Application shell → Route form: presents (evidence: `frontend/src/App.jsx`)
- Route form → API client: submits route
- Application shell → API client: requests analysis (evidence: `frontend/src/App.jsx`)
- API client → API controller: calls API
- API controller → Input validation: validates input (evidence: `backend/api/views.py`)
- Input validation → Geocoding: resolves addresses (evidence: `backend/api/serializers.py`)
- API controller → Geocoding: serves autocomplete (evidence: `backend/api/views.py`)
- Geocoding → OpenRouteService: geocodes places (evidence: `backend/services/geocoding.py`)
- API controller → Alternative routing: requests routes (evidence: `backend/api/views.py`)
- Alternative routing → OpenRouteService: requests directions (evidence: `backend/services/routing.py`)
- API controller → Checkpoint sampling: samples routes (evidence: `backend/api/views.py`)
- API controller → Weather forecasts: fetches forecasts (evidence: `backend/api/views.py`)
- Weather forecasts → Open-Meteo: fetches hourly data (evidence: `backend/services/weather.py`)
- API controller → Risk classification: assesses checkpoint risk
- Weather forecasts → Risk classification: provides readings (evidence: `backend/services/weather.py`)
- API controller → Route recommendation: ranks routes (evidence: `backend/api/views.py`)
- API controller → Corridor heatmap: precomputes heatmap (evidence: `backend/api/views.py`)
- API controller → Departure windows: optimizes departure (evidence: `backend/api/views.py`)
- API controller → Cache utilities: caches analysis (evidence: `backend/api/views.py`)
- API controller → Analysis data models: builds results (evidence: `backend/api/views.py`)
- Risk classification → Analysis data models: produces risk records (evidence: `backend/services/risk_engine.py`)
- Weather forecasts → Analysis data models: parses readings (evidence: `backend/services/weather.py`)
- Checkpoint sampling → Analysis data models: creates checkpoints (evidence: `backend/services/checkpoints.py`)
- Application shell → Risk map: renders corridor (evidence: `frontend/src/App.jsx`)
- Application shell → Route comparison: shows alternatives (evidence: `frontend/src/App.jsx`)
- Application shell → Forecast slider: scrubs forecast (evidence: `frontend/src/App.jsx`)
- Application shell → Checkpoint details: shows checkpoints (evidence: `frontend/src/App.jsx`)
- Application shell → Risk sandbox: presents risk tools (evidence: `frontend/src/App.jsx`)
- Forecast slider → Risk map: updates hour
