# project-osrm/osrm-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/project-osrm/osrm-frontend
- Repository: https://github.com/project-osrm/osrm-frontend

## Overview

osrm-frontend is a browser-based route-planning map built on Leaflet Routing Machine. Users choose locations, optionally select OSM entrances and routing preferences, request directions from an OSRM backend, then inspect and share the route. The graph also preserves the documented map-background and vector-rendering capabilities, plus route state, responsive presentation, and export tools. Several modules are indexed but not excerpted; their roles and links are included only where the README or source index supports them.

Main entry points: [`src/index.js`](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/index.js) (App bootstrap), [`src/state.js`](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/state.js) (Route and view state), [`src/tools.js`](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/tools.js) (Map tools), [`src/entrance_waypoints.js`](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/entrance_waypoints.js) (Entrance waypoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App orchestration"]
  node_app_entry["App bootstrap<br/>[index.js]"]
end

subgraph group_planning["Route planning"]
  node_waypoint_entry["Waypoint placement"]
  node_geocoder["Place search<br/>[geocoder.js]"]
  node_entrance_picker["Entrance picker<br/>[entrance_picker.js]"]
  node_entrance_waypoints["Entrance waypoints"]
  node_itinerary["Itinerary builder"]
  node_waypoint_reorder["Stop ordering"]
  node_route_preferences["Route preferences"]
  node_router_patches["Router adaptation<br/>[router_patches.js]"]
  node_route_display["Route and directions"]
end

subgraph group_mapping["Map and layers"]
  node_route_zoom["Route framing<br/>[route_zoom.js]"]
  node_map_config["Map configuration<br/>[leaflet_options.js]"]
  node_layer_control["Background selection<br/>[layers_control.js]"]
  node_vector_backgrounds["Vector backgrounds"]
  node_vector_renderer["Vector rendering<br/>[vector_renderer.js]"]
  node_vector_runtime["Vector runtime<br/>[vector_runtime.js]"]
end

subgraph group_presentation["Interface and state"]
  node_state["Route and view state<br/>[state.js]"]
  node_url_state["URL state<br/>[url_state.js]"]
  node_interface_theme["Directions interface<br/>[interface_theme.js]"]
  node_mobile_viewport["Responsive viewport<br/>[mobile_viewport.js]"]
  node_localization["Localization<br/>[localization.js]"]
end

subgraph group_integrations["Services and sharing"]
  node_routing_backend{{"OSRM backend"}}
  node_tile_service{{"Map tile services"}}
  node_tools["Map tools<br/>[tools.js]"]
  node_gpx["GPX export<br/>[gpx.js]"]
  node_shortlink["Short links<br/>[shortlink.js]"]
  node_browser_storage[("Browser storage")]
end

node_user(("Map user"))

node_user -->|"uses"| node_app_entry
node_app_entry -->|"creates"| node_geocoder
node_app_entry -->|"configures"| node_waypoint_entry
node_app_entry -->|"refreshes"| node_entrance_waypoints
node_entrance_waypoints -->|"uses"| node_entrance_picker
node_app_entry -->|"initializes"| node_itinerary
node_app_entry -->|"applies"| node_route_preferences
node_app_entry -->|"patches"| node_router_patches
node_router_patches -->|"requests routes"| node_routing_backend
node_app_entry -.->|"configures"| node_route_display
node_app_entry -.->|"uses"| node_route_zoom
node_app_entry -->|"configures"| node_map_config
node_map_config -->|"creates"| node_vector_backgrounds
node_vector_backgrounds -.->|"renders with"| node_vector_renderer
node_vector_renderer -.->|"uses"| node_vector_runtime
node_vector_runtime -->|"loads tiles"| node_tile_service
node_app_entry -->|"creates"| node_layer_control
node_app_entry -->|"updates"| node_state
node_state -->|"reads"| node_itinerary
node_state -->|"uses"| node_waypoint_reorder
node_state -->|"uses"| node_url_state
node_state -.->|"persists"| node_browser_storage
node_app_entry -->|"initializes"| node_interface_theme
node_interface_theme -->|"uses"| node_mobile_viewport
node_app_entry -->|"configures"| node_localization
node_app_entry -->|"creates"| node_tools
node_tools -->|"exports"| node_gpx
node_tools -->|"creates"| node_shortlink
node_app_entry -.->|"reads settings"| node_browser_storage

click node_app_entry "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/index.js"
click node_waypoint_entry "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/waypoint_placement.js"
click node_geocoder "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/geocoder.js"
click node_entrance_picker "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/entrance_picker.js"
click node_entrance_waypoints "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/entrance_waypoints.js"
click node_itinerary "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/itinerary_builder.js"
click node_waypoint_reorder "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/waypoint_reorder.js"
click node_route_preferences "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/route_preferences.js"
click node_router_patches "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/router_patches.js"
click node_route_display "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/route_properties.js"
click node_route_zoom "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/route_zoom.js"
click node_map_config "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/leaflet_options.js"
click node_layer_control "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/layers_control.js"
click node_vector_backgrounds "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/vector_backgrounds.js"
click node_vector_renderer "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/vector_renderer.js"
click node_vector_runtime "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/vector_runtime.js"
click node_state "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/state.js"
click node_url_state "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/url_state.js"
click node_interface_theme "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/interface_theme.js"
click node_mobile_viewport "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/mobile_viewport.js"
click node_localization "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/localization.js"
click node_tools "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/tools.js"
click node_gpx "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/gpx.js"
click node_shortlink "https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/shortlink.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_app_entry,node_user toneBlue
class node_waypoint_entry,node_geocoder,node_entrance_picker,node_entrance_waypoints,node_itinerary,node_waypoint_reorder,node_route_preferences,node_router_patches,node_route_display toneAmber
class node_route_zoom,node_map_config,node_layer_control,node_vector_backgrounds,node_vector_renderer,node_vector_runtime toneMint
class node_state,node_url_state,node_interface_theme,node_mobile_viewport,node_localization toneRose
class node_routing_backend,node_tile_service,node_tools,node_gpx,node_shortlink,node_browser_storage toneIndigo
```

## Components

### App orchestration

- [App bootstrap](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/index.js): `src/index.js`

### Route planning

- [Waypoint placement](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/waypoint_placement.js): `src/waypoint_placement.js`
- [Place search](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/geocoder.js): `src/geocoder.js`
- [Entrance picker](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/entrance_picker.js): `src/entrance_picker.js`
- [Entrance waypoints](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/entrance_waypoints.js): `src/entrance_waypoints.js`
- [Itinerary builder](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/itinerary_builder.js): `src/itinerary_builder.js`
- [Stop ordering](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/waypoint_reorder.js): `src/waypoint_reorder.js`
- [Route preferences](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/route_preferences.js): `src/route_preferences.js`
- [Router adaptation](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/router_patches.js): `src/router_patches.js`
- [Route and directions](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/route_properties.js): `src/route_properties.js`

### Map and layers

- [Route framing](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/route_zoom.js): `src/route_zoom.js`
- [Map configuration](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/leaflet_options.js): `src/leaflet_options.js`
- [Background selection](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/layers_control.js): `src/layers_control.js`
- [Vector backgrounds](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/vector_backgrounds.js): `src/vector_backgrounds.js`
- [Vector rendering](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/vector_renderer.js): `src/vector_renderer.js`
- [Vector runtime](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/vector_runtime.js): `src/vector_runtime.js`

### Interface and state

- [Route and view state](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/state.js): `src/state.js`
- [URL state](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/url_state.js): `src/url_state.js`
- [Directions interface](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/interface_theme.js): `src/interface_theme.js`
- [Responsive viewport](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/mobile_viewport.js): `src/mobile_viewport.js`
- [Localization](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/localization.js): `src/localization.js`

### Services and sharing

- **OSRM backend**
- **Map tile services**
- [Map tools](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/tools.js): `src/tools.js`
- [GPX export](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/gpx.js): `src/gpx.js`
- [Short links](https://github.com/Project-OSRM/osrm-frontend/blob/gh-pages/src/shortlink.js): `src/shortlink.js`
- **Browser storage**

### Other components

- **Map user**

## Connections

- Map user → App bootstrap: uses
- App bootstrap → Place search: creates (evidence: `src/index.js`)
- App bootstrap → Waypoint placement: configures (evidence: `src/index.js`)
- App bootstrap → Entrance waypoints: refreshes (evidence: `src/index.js`)
- Entrance waypoints → Entrance picker: uses (evidence: `src/entrance_waypoints.js`)
- App bootstrap → Itinerary builder: initializes (evidence: `src/index.js`)
- App bootstrap → Route preferences: applies (evidence: `src/index.js`)
- App bootstrap → Router adaptation: patches (evidence: `src/index.js`)
- Router adaptation → OSRM backend: requests routes
- App bootstrap → Route and directions: configures
- App bootstrap → Route framing: uses (evidence: `src/index.js`)
- App bootstrap → Map configuration: configures (evidence: `src/index.js`)
- Map configuration → Vector backgrounds: creates (evidence: `src/leaflet_options.js`)
- Vector backgrounds → Vector rendering: renders with
- Vector rendering → Vector runtime: uses
- Vector runtime → Map tile services: loads tiles
- App bootstrap → Background selection: creates (evidence: `src/index.js`)
- App bootstrap → Route and view state: updates (evidence: `src/index.js`)
- Route and view state → Itinerary builder: reads (evidence: `src/state.js`)
- Route and view state → Stop ordering: uses (evidence: `src/state.js`)
- Route and view state → URL state: uses (evidence: `src/state.js`)
- Route and view state → Browser storage: persists
- App bootstrap → Directions interface: initializes (evidence: `src/index.js`)
- Directions interface → Responsive viewport: uses (evidence: `src/interface_theme.js`)
- App bootstrap → Localization: configures (evidence: `src/index.js`)
- App bootstrap → Map tools: creates (evidence: `src/index.js`)
- Map tools → GPX export: exports (evidence: `src/tools.js`)
- Map tools → Short links: creates (evidence: `src/tools.js`)
- App bootstrap → Browser storage: reads settings
