# syedhaider037/fuel-route-planner architecture

> Architecture diagram of the GitHub repository syedhaider037/fuel-route-planner, 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/syedhaider037/fuel-route-planner
- Repository: https://github.com/syedhaider037/fuel-route-planner

## Overview

Fuel Route Planner is a Django API and Leaflet map that turns two US locations into a GeoJSON route, an optimal fuel-stop plan, and trip costs. The request flow runs from the API view through trip orchestration, local or remote place resolution, routing, nearby-stop indexing, and fuel planning before returning the response; the map page presents that API result. The graph also captures offline stop-data preparation and the documented ORS/OSRM and map-tile integrations. Edges are limited to relationships shown in excerpts or stated in the README; unsampled map-page implementation details are not inferred.

Main entry points: [`fuel/management/commands/prepare_stops.py`](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/management/commands/prepare_stops.py) (Prepare stops command), [`fuel/trip.py`](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/trip.py) (Trip orchestration), [`fuel/ors.py`](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/ors.py) (Routing client), [`fuel/management/commands/geocode_unplaced.py`](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/management/commands/geocode_unplaced.py) (Geocode unplaced)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_request["Trip Request"]
  node_api["Route API<br/>[views.py]"]
  node_trip["Trip orchestration<br/>[trip.py]"]
  node_errors["API errors<br/>[api_errors.py]"]
end

subgraph group_routing["Places and Routing"]
  node_places["Place resolution<br/>[places.py]"]
  node_ors["Routing client<br/>[ors.py]"]
  node_ors_service{{"OpenRouteService"}}
  node_osrm_service{{"OSRM demo"}}
end

subgraph group_fuel["Fuel Planning"]
  node_stop_index["Stop index<br/>[stops.py]"]
  node_planner["Fuel planner<br/>[planner.py]"]
end

subgraph group_data["Stop Data Preparation"]
  node_fuel_csv["Fuel price source<br/>[fuel_prices.csv]"]
  node_prepare["Stop preparation<br/>[prepare.py]"]
  node_prepare_command["Prepare stops command<br/>[prepare_stops.py]"]
  node_geocode_command["Geocode unplaced"]
  node_shared_command["Command utilities<br/>[_shared.py]"]
  node_stops_data["Prepared stop data<br/>[stops.csv]"]
  node_places_data["Local place data<br/>[us_places.csv]"]
  node_fallback_data["Fallback places"]
end

subgraph group_presentation["Map Presentation"]
  node_map_page["Map page<br/>[views.py]"]
  node_map_template["Leaflet interface<br/>[map.html]"]
  node_map_tiles{{"OpenStreetMap tiles"}}
end

node_driver(("Trip requester"))

node_driver -->|"submits trip"| node_api
node_api -->|"plans trip"| node_trip
node_api -->|"shapes errors"| node_errors
node_trip -->|"resolves places"| node_places
node_places -->|"geocodes text"| node_ors
node_trip -->|"requests route"| node_ors
node_ors -->|"calls routing"| node_ors_service
node_ors -.->|"falls back"| node_osrm_service
node_trip -->|"finds nearby stops"| node_stop_index
node_trip -->|"plans purchases"| node_planner
node_stop_index -->|"loads"| node_stops_data
node_places -->|"loads"| node_places_data
node_prepare_command -->|"cleans and places"| node_prepare
node_prepare_command -->|"loads Census inputs"| node_shared_command
node_prepare_command -->|"reads prices"| node_fuel_csv
node_prepare_command -->|"writes stops"| node_stops_data
node_prepare_command -->|"writes places"| node_places_data
node_geocode_command -->|"finds unplaced towns"| node_prepare
node_geocode_command -->|"geocodes towns"| node_ors
node_geocode_command -->|"loads Census inputs"| node_shared_command
node_geocode_command -->|"writes geocodes"| node_fallback_data
node_map_page -->|"renders"| node_map_template
node_driver -->|"opens map"| node_map_page
node_map_template -->|"requests trip"| node_api
node_map_template -->|"draws with tiles"| node_map_tiles

click node_api "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/views.py"
click node_trip "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/trip.py"
click node_errors "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/api_errors.py"
click node_places "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/places.py"
click node_ors "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/ors.py"
click node_stop_index "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/stops.py"
click node_planner "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/planner.py"
click node_fuel_csv "https://github.com/syedhaider037/fuel-route-planner/blob/main/data/fuel_prices.csv"
click node_prepare "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/prepare.py"
click node_prepare_command "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/management/commands/prepare_stops.py"
click node_geocode_command "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/management/commands/geocode_unplaced.py"
click node_shared_command "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/management/commands/_shared.py"
click node_stops_data "https://github.com/syedhaider037/fuel-route-planner/blob/main/data/stops.csv"
click node_places_data "https://github.com/syedhaider037/fuel-route-planner/blob/main/data/us_places.csv"
click node_fallback_data "https://github.com/syedhaider037/fuel-route-planner/blob/main/data/fallback_places.csv"
click node_map_page "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/views.py"
click node_map_template "https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/templates/fuel/map.html"

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_api,node_trip,node_errors toneBlue
class node_places,node_ors,node_ors_service,node_osrm_service toneAmber
class node_stop_index,node_planner,node_driver toneMint
class node_fuel_csv,node_prepare,node_prepare_command,node_geocode_command,node_shared_command,node_stops_data,node_places_data,node_fallback_data toneRose
class node_map_page,node_map_template,node_map_tiles toneIndigo
```

## Components

### Trip Request

- [Route API](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/views.py): `fuel/views.py`
- [Trip orchestration](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/trip.py): `fuel/trip.py`
- [API errors](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/api_errors.py): `fuel/api_errors.py`

### Places and Routing

- [Place resolution](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/places.py): `fuel/places.py`
- [Routing client](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/ors.py): `fuel/ors.py`
- **OpenRouteService**
- **OSRM demo**

### Fuel Planning

- [Stop index](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/stops.py): `fuel/stops.py`
- [Fuel planner](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/planner.py): `fuel/planner.py`

### Stop Data Preparation

- [Fuel price source](https://github.com/syedhaider037/fuel-route-planner/blob/main/data/fuel_prices.csv): `data/fuel_prices.csv`
- [Stop preparation](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/prepare.py): `fuel/prepare.py`
- [Prepare stops command](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/management/commands/prepare_stops.py): `fuel/management/commands/prepare_stops.py`
- [Geocode unplaced](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/management/commands/geocode_unplaced.py): `fuel/management/commands/geocode_unplaced.py`
- [Command utilities](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/management/commands/_shared.py): `fuel/management/commands/_shared.py`
- [Prepared stop data](https://github.com/syedhaider037/fuel-route-planner/blob/main/data/stops.csv): `data/stops.csv`
- [Local place data](https://github.com/syedhaider037/fuel-route-planner/blob/main/data/us_places.csv): `data/us_places.csv`
- [Fallback places](https://github.com/syedhaider037/fuel-route-planner/blob/main/data/fallback_places.csv): `data/fallback_places.csv`

### Map Presentation

- [Map page](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/views.py): `fuel/views.py`
- [Leaflet interface](https://github.com/syedhaider037/fuel-route-planner/blob/main/fuel/templates/fuel/map.html): `fuel/templates/fuel/map.html`
- **OpenStreetMap tiles**

### Other components

- **Trip requester**

## Connections

- Trip requester → Route API: submits trip (evidence: `README.md`)
- Route API → Trip orchestration: plans trip (evidence: `fuel/views.py`)
- Route API → API errors: shapes errors (evidence: `fuel/views.py`)
- Trip orchestration → Place resolution: resolves places (evidence: `fuel/trip.py`)
- Place resolution → Routing client: geocodes text (evidence: `fuel/places.py`)
- Trip orchestration → Routing client: requests route (evidence: `fuel/trip.py`)
- Routing client → OpenRouteService: calls routing (evidence: `README.md`)
- Routing client → OSRM demo: falls back (evidence: `README.md`)
- Trip orchestration → Stop index: finds nearby stops (evidence: `fuel/trip.py`)
- Trip orchestration → Fuel planner: plans purchases (evidence: `fuel/trip.py`)
- Stop index → Prepared stop data: loads (evidence: `README.md`)
- Place resolution → Local place data: loads (evidence: `README.md`)
- Prepare stops command → Stop preparation: cleans and places (evidence: `fuel/management/commands/prepare_stops.py`)
- Prepare stops command → Command utilities: loads Census inputs (evidence: `fuel/management/commands/prepare_stops.py`)
- Prepare stops command → Fuel price source: reads prices (evidence: `fuel/management/commands/prepare_stops.py`)
- Prepare stops command → Prepared stop data: writes stops (evidence: `fuel/management/commands/prepare_stops.py`)
- Prepare stops command → Local place data: writes places (evidence: `fuel/management/commands/prepare_stops.py`)
- Geocode unplaced → Stop preparation: finds unplaced towns (evidence: `fuel/management/commands/geocode_unplaced.py`)
- Geocode unplaced → Routing client: geocodes towns (evidence: `fuel/management/commands/geocode_unplaced.py`)
- Geocode unplaced → Command utilities: loads Census inputs (evidence: `fuel/management/commands/geocode_unplaced.py`)
- Geocode unplaced → Fallback places: writes geocodes (evidence: `fuel/management/commands/geocode_unplaced.py`)
- Map page → Leaflet interface: renders (evidence: `fuel/views.py`)
- Trip requester → Map page: opens map (evidence: `README.md`)
- Leaflet interface → Route API: requests trip (evidence: `README.md`)
- Leaflet interface → OpenStreetMap tiles: draws with tiles (evidence: `README.md`)
