# heitor-rocha/sistema-rotas-dijkstra architecture

> Architecture diagram of the GitHub repository heitor-rocha/sistema-rotas-dijkstra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/heitor-rocha/sistema-rotas-dijkstra
- Repository: https://github.com/heitor-rocha/sistema-rotas-dijkstra

## Overview

This browser-based route planner models Viçosa-region roads as a weighted graph, lets users calculate and visualize shortest routes, and supports editing and saving custom networks. The main workflow is: choose cities, run Dijkstra’s algorithm, then display the exploration and route on the map. The graph editor, default regional dataset, and local persistence support that workflow. OSRM supplies road geometry and optional distance suggestions; OpenStreetMap supplies map tiles. The graph follows README documentation and excerpted calls; unsampled UI details are represented at the main-module level.

Main entry points: [`src/main.ts`](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/main.ts) (UI Orchestrator), [`src/core/Grafo.ts`](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/core/Grafo.ts) (Weighted Graph), [`src/ui/MapManager.ts`](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/ui/MapManager.ts) (Map Rendering), [`src/core/Dijkstra.ts`](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/core/Dijkstra.ts) (Shortest-Path Search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application"]
  node_app["UI Orchestrator<br/>[main.ts]"]
  node_editor["Network Editing<br/>[main.ts]"]
  node_persistence["Local Scenario Storage<br/>[main.ts]"]
end

subgraph group_routing["Routing Core"]
  node_dijkstra["Shortest-Path Search<br/>[Dijkstra.ts]"]
  node_heap["Priority Queue<br/>[MinHeap.ts]"]
end

subgraph group_network["Road Network"]
  node_dataset["Default Region Dataset<br/>[regiaoVicosa.ts]"]
  node_graph["Weighted Graph<br/>[Grafo.ts]"]
end

subgraph group_mapping["Map Services"]
  node_map["Map Rendering<br/>[MapManager.ts]"]
end

node_user(("Route Planner User"))
node_osrm{{"OSRM Routing API"}}
node_tiles{{"OpenStreetMap Tiles"}}
node_localstorage[("Browser LocalStorage")]

node_user -->|"uses"| node_app
node_app -->|"loads defaults"| node_dataset
node_dataset -->|"populates"| node_graph
node_app -->|"manages network"| node_graph
node_app -->|"handles edits"| node_editor
node_editor -->|"updates"| node_graph
node_app -->|"calculates route"| node_dijkstra
node_dijkstra -->|"reads neighbors"| node_graph
node_dijkstra -->|"queues candidates"| node_heap
node_app -->|"animates exploration"| node_map
node_map -->|"reads roads"| node_graph
node_app -->|"saves and restores"| node_persistence
node_persistence -->|"serializes state"| node_graph
node_persistence -->|"reads and writes"| node_localstorage
node_map -->|"fetches geometry"| node_osrm
node_map -->|"loads tiles"| node_tiles
node_app -->|"suggests distance"| node_osrm

click node_app "https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/main.ts"
click node_editor "https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/main.ts"
click node_persistence "https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/main.ts"
click node_dataset "https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/data/regiaoVicosa.ts"
click node_graph "https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/core/Grafo.ts"
click node_dijkstra "https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/core/Dijkstra.ts"
click node_heap "https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/core/MinHeap.ts"
click node_map "https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/ui/MapManager.ts"

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_editor,node_persistence,node_user toneBlue
class node_dijkstra,node_heap,node_localstorage toneAmber
class node_dataset,node_graph,node_osrm toneMint
class node_map toneRose
class node_tiles toneIndigo
```

## Components

### Application

- [UI Orchestrator](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/main.ts): `src/main.ts`
- [Network Editing](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/main.ts): `src/main.ts`
- [Local Scenario Storage](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/main.ts): `src/main.ts`

### Routing Core

- [Shortest-Path Search](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/core/Dijkstra.ts): `src/core/Dijkstra.ts`
- [Priority Queue](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/core/MinHeap.ts): `src/core/MinHeap.ts`

### Road Network

- [Default Region Dataset](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/data/regiaoVicosa.ts): `src/data/regiaoVicosa.ts`
- [Weighted Graph](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/core/Grafo.ts): `src/core/Grafo.ts`

### Map Services

- [Map Rendering](https://github.com/heitor-rocha/sistema-rotas-dijkstra/blob/main/src/ui/MapManager.ts): `src/ui/MapManager.ts`

### Other components

- **Route Planner User**
- **OSRM Routing API**
- **OpenStreetMap Tiles**
- **Browser LocalStorage**

## Connections

- Route Planner User → UI Orchestrator: uses (evidence: `README.md`)
- UI Orchestrator → Default Region Dataset: loads defaults (evidence: `src/main.ts`)
- Default Region Dataset → Weighted Graph: populates (evidence: `src/data/regiaoVicosa.ts`)
- UI Orchestrator → Weighted Graph: manages network (evidence: `src/main.ts`)
- UI Orchestrator → Network Editing: handles edits (evidence: `src/main.ts`)
- Network Editing → Weighted Graph: updates (evidence: `src/main.ts`)
- UI Orchestrator → Shortest-Path Search: calculates route (evidence: `src/main.ts`)
- Shortest-Path Search → Weighted Graph: reads neighbors (evidence: `src/core/Dijkstra.ts`)
- Shortest-Path Search → Priority Queue: queues candidates (evidence: `src/core/Dijkstra.ts`)
- UI Orchestrator → Map Rendering: animates exploration (evidence: `src/main.ts`)
- Map Rendering → Weighted Graph: reads roads (evidence: `src/ui/MapManager.ts`)
- UI Orchestrator → Local Scenario Storage: saves and restores (evidence: `src/main.ts`)
- Local Scenario Storage → Weighted Graph: serializes state (evidence: `src/main.ts`)
- Local Scenario Storage → Browser LocalStorage: reads and writes (evidence: `src/main.ts`)
- Map Rendering → OSRM Routing API: fetches geometry (evidence: `src/ui/MapManager.ts`)
- Map Rendering → OpenStreetMap Tiles: loads tiles (evidence: `src/ui/MapManager.ts`)
- UI Orchestrator → OSRM Routing API: suggests distance (evidence: `src/main.ts`)
