# gnarendra9014-user/map-routing architecture

> Architecture diagram of the GitHub repository gnarendra9014-user/map-routing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gnarendra9014-user/map-routing
- Repository: https://github.com/gnarendra9014-user/map-routing

## Overview

Map Router turns OpenStreetMap road data into a routable graph, then answers route queries through a CLI or embedded HTTP server. The browser provides the interactive map and routing experience, calling same-origin endpoints for routes, waypoint optimization, and network data. Its documented capabilities also include algorithm comparison, tours, overlays, elevation, and export. The graph reflects sampled parser, algorithm, and frontend/API evidence; some UI features are documented but their implementation details were not sampled, so their internal wiring is omitted.

Main entry points: [`tools/main.cpp`](https://github.com/gnarendra9014-user/map-routing/blob/main/tools/main.cpp) (CLI and HTTP server), [`web/app.js`](https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js) (Map interface), [`include/types.hpp`](https://github.com/gnarendra9014-user/map-routing/blob/main/include/types.hpp) (Route result), [`src/osm_parser.cpp`](https://github.com/gnarendra9014-user/map-routing/blob/main/src/osm_parser.cpp) (OSM parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_webapp["Map interface<br/>[app.js]"]
  node_gpx["GPX and sharing<br/>[app.js]"]
  node_dash["Comparison and diagnostics<br/>[app.js]"]
  node_tour["3D tour and guidance<br/>[app.js]"]
  node_overlays["Traffic and overlays<br/>[app.js]"]
  node_elevation["Elevation profile<br/>[app.js]"]
end

subgraph group_ingest["Road data"]
  node_parser["OSM parser<br/>[osm_parser.cpp]"]
  node_rawdata["Road data<br/>[osm_parser.hpp]"]
  node_graph["Road graph<br/>[graph.cpp]"]
  node_graphfile["Serialized graph<br/>[graph.hpp]"]
end

subgraph group_routing["Routing engine"]
  node_dijkstra["Dijkstra<br/>[dijkstra.cpp]"]
  node_astar["A*<br/>[astar.cpp]"]
  node_bidir["Bidirectional A*"]
  node_chquery["CH query<br/>[ch.cpp]"]
  node_route_result["Route result<br/>[types.hpp]"]
end

subgraph group_preprocess["Query preprocessing"]
  node_chbuild["CH preprocessing<br/>[ch.cpp]"]
  node_altbuild["ALT preprocessing<br/>[alt.cpp]"]
  node_hublabels["Hub labeling<br/>[hub_labeling.cpp]"]
  node_altfile["ALT data<br/>[alt.hpp]"]
  node_chfile["CH data<br/>[ch.hpp]"]
end

subgraph group_service["CLI and HTTP"]
  node_server["CLI and HTTP server<br/>[main.cpp]"]
  node_optimizer["Waypoint optimizer<br/>[main.cpp]"]
  node_geojson["GeoJSON export<br/>[geojson.cpp]"]
end

node_user(("Traveler"))
node_maplibre["MapLibre tiles"]
node_osmfile["OSM PBF"]

node_user -->|"sets route"| node_webapp
node_webapp -.->|"renders map"| node_maplibre
node_osmfile -->|"supplies data"| node_parser
node_parser -->|"extracts roads"| node_rawdata
node_rawdata -->|"builds graph"| node_graph
node_server -->|"parses input"| node_parser
node_server -->|"builds graph"| node_graph
node_server -->|"loads or saves"| node_graphfile
node_graph -->|"serializes"| node_graphfile
node_server -->|"dispatches query"| node_dijkstra
node_server -->|"dispatches query"| node_astar
node_server -->|"dispatches query"| node_bidir
node_server -->|"dispatches query"| node_chquery
node_dijkstra -->|"returns route"| node_route_result
node_astar -->|"returns route"| node_route_result
node_bidir -->|"returns route"| node_route_result
node_chquery -->|"returns route"| node_route_result
node_server -->|"builds hierarchy"| node_chbuild
node_server -->|"builds landmarks"| node_altbuild
node_chbuild -->|"saves hierarchy"| node_chfile
node_server -->|"loads hierarchy"| node_chfile
node_altbuild -->|"saves landmarks"| node_altfile
node_server -->|"loads landmarks"| node_altfile
node_hublabels -->|"uses hierarchy"| node_chfile
node_webapp -->|"requests routes"| node_server
node_webapp -->|"optimizes stops"| node_server
node_server -->|"dispatches optimization"| node_optimizer
node_webapp -->|"shows metrics"| node_dash
node_webapp -->|"plays route tour"| node_tour
node_webapp -->|"displays overlays"| node_overlays
node_webapp -->|"displays profile"| node_elevation
node_webapp -->|"exports or shares"| node_gpx
node_route_result -->|"formats route"| node_geojson

click node_webapp "https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js"
click node_parser "https://github.com/gnarendra9014-user/map-routing/blob/main/src/osm_parser.cpp"
click node_rawdata "https://github.com/gnarendra9014-user/map-routing/blob/main/include/osm_parser.hpp"
click node_graph "https://github.com/gnarendra9014-user/map-routing/blob/main/src/graph.cpp"
click node_graphfile "https://github.com/gnarendra9014-user/map-routing/blob/main/include/graph.hpp"
click node_dijkstra "https://github.com/gnarendra9014-user/map-routing/blob/main/src/dijkstra.cpp"
click node_astar "https://github.com/gnarendra9014-user/map-routing/blob/main/src/astar.cpp"
click node_bidir "https://github.com/gnarendra9014-user/map-routing/blob/main/src/bidirectional_astar.cpp"
click node_chquery "https://github.com/gnarendra9014-user/map-routing/blob/main/src/ch.cpp"
click node_route_result "https://github.com/gnarendra9014-user/map-routing/blob/main/include/types.hpp"
click node_chbuild "https://github.com/gnarendra9014-user/map-routing/blob/main/src/ch.cpp"
click node_altbuild "https://github.com/gnarendra9014-user/map-routing/blob/main/src/alt.cpp"
click node_hublabels "https://github.com/gnarendra9014-user/map-routing/blob/main/src/hub_labeling.cpp"
click node_altfile "https://github.com/gnarendra9014-user/map-routing/blob/main/include/alt.hpp"
click node_chfile "https://github.com/gnarendra9014-user/map-routing/blob/main/include/ch.hpp"
click node_server "https://github.com/gnarendra9014-user/map-routing/blob/main/tools/main.cpp"
click node_optimizer "https://github.com/gnarendra9014-user/map-routing/blob/main/tools/main.cpp"
click node_geojson "https://github.com/gnarendra9014-user/map-routing/blob/main/src/geojson.cpp"
click node_gpx "https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js"
click node_dash "https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js"
click node_tour "https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js"
click node_overlays "https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js"
click node_elevation "https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js"

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_webapp,node_gpx,node_dash,node_tour,node_overlays,node_elevation toneBlue
class node_parser,node_rawdata,node_graph,node_graphfile toneAmber
class node_dijkstra,node_astar,node_bidir,node_chquery,node_route_result toneMint
class node_chbuild,node_altbuild,node_hublabels,node_altfile,node_chfile toneRose
class node_server,node_optimizer,node_geojson,node_user,node_maplibre,node_osmfile toneIndigo
```

## Components

### Browser experience

- [Map interface](https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js): `web/app.js`
- [GPX and sharing](https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js): `web/app.js`
- [Comparison and diagnostics](https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js): `web/app.js`
- [3D tour and guidance](https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js): `web/app.js`
- [Traffic and overlays](https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js): `web/app.js`
- [Elevation profile](https://github.com/gnarendra9014-user/map-routing/blob/main/web/app.js): `web/app.js`

### Road data

- [OSM parser](https://github.com/gnarendra9014-user/map-routing/blob/main/src/osm_parser.cpp): `src/osm_parser.cpp`
- [Road data](https://github.com/gnarendra9014-user/map-routing/blob/main/include/osm_parser.hpp): `include/osm_parser.hpp`
- [Road graph](https://github.com/gnarendra9014-user/map-routing/blob/main/src/graph.cpp): `src/graph.cpp`
- [Serialized graph](https://github.com/gnarendra9014-user/map-routing/blob/main/include/graph.hpp): `include/graph.hpp`

### Routing engine

- [Dijkstra](https://github.com/gnarendra9014-user/map-routing/blob/main/src/dijkstra.cpp): `src/dijkstra.cpp`
- [A*](https://github.com/gnarendra9014-user/map-routing/blob/main/src/astar.cpp): `src/astar.cpp`
- [Bidirectional A*](https://github.com/gnarendra9014-user/map-routing/blob/main/src/bidirectional_astar.cpp): `src/bidirectional_astar.cpp`
- [CH query](https://github.com/gnarendra9014-user/map-routing/blob/main/src/ch.cpp): `src/ch.cpp`
- [Route result](https://github.com/gnarendra9014-user/map-routing/blob/main/include/types.hpp): `include/types.hpp`

### Query preprocessing

- [CH preprocessing](https://github.com/gnarendra9014-user/map-routing/blob/main/src/ch.cpp): `src/ch.cpp`
- [ALT preprocessing](https://github.com/gnarendra9014-user/map-routing/blob/main/src/alt.cpp): `src/alt.cpp`
- [Hub labeling](https://github.com/gnarendra9014-user/map-routing/blob/main/src/hub_labeling.cpp): `src/hub_labeling.cpp`
- [ALT data](https://github.com/gnarendra9014-user/map-routing/blob/main/include/alt.hpp): `include/alt.hpp`
- [CH data](https://github.com/gnarendra9014-user/map-routing/blob/main/include/ch.hpp): `include/ch.hpp`

### CLI and HTTP

- [CLI and HTTP server](https://github.com/gnarendra9014-user/map-routing/blob/main/tools/main.cpp): `tools/main.cpp`
- [Waypoint optimizer](https://github.com/gnarendra9014-user/map-routing/blob/main/tools/main.cpp): `tools/main.cpp`
- [GeoJSON export](https://github.com/gnarendra9014-user/map-routing/blob/main/src/geojson.cpp): `src/geojson.cpp`

### Other components

- **Traveler**
- **MapLibre tiles**
- **OSM PBF**

## Connections

- Traveler → Map interface: sets route
- Map interface → MapLibre tiles: renders map
- OSM PBF → OSM parser: supplies data
- OSM parser → Road data: extracts roads
- Road data → Road graph: builds graph
- CLI and HTTP server → OSM parser: parses input
- CLI and HTTP server → Road graph: builds graph
- CLI and HTTP server → Serialized graph: loads or saves
- Road graph → Serialized graph: serializes
- CLI and HTTP server → Dijkstra: dispatches query
- CLI and HTTP server → A*: dispatches query
- CLI and HTTP server → Bidirectional A*: dispatches query
- CLI and HTTP server → CH query: dispatches query
- Dijkstra → Route result: returns route
- A* → Route result: returns route
- Bidirectional A* → Route result: returns route
- CH query → Route result: returns route
- CLI and HTTP server → CH preprocessing: builds hierarchy
- CLI and HTTP server → ALT preprocessing: builds landmarks
- CH preprocessing → CH data: saves hierarchy
- CLI and HTTP server → CH data: loads hierarchy
- ALT preprocessing → ALT data: saves landmarks
- CLI and HTTP server → ALT data: loads landmarks
- Hub labeling → CH data: uses hierarchy
- Map interface → CLI and HTTP server: requests routes
- Map interface → CLI and HTTP server: optimizes stops
- CLI and HTTP server → Waypoint optimizer: dispatches optimization
- Map interface → Comparison and diagnostics: shows metrics
- Map interface → 3D tour and guidance: plays route tour
- Map interface → Traffic and overlays: displays overlays
- Map interface → Elevation profile: displays profile
- Map interface → GPX and sharing: exports or shares
- Route result → GeoJSON export: formats route
