# techprep-gh/pathfinding-visualizer architecture

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

- Interactive diagram: https://gitdiagram.com/techprep-gh/pathfinding-visualizer
- Repository: https://github.com/techprep-gh/pathfinding-visualizer

## Overview

Pathfinding Visualizer is a browser-based React app for choosing a maze and search algorithm, then watching traversal and the resulting route animate on an editable grid. The main workflow runs from the navigation controls through dispatchers to maze or pathfinding algorithms, with shared grid and tile state rendered by the grid view. The graph preserves the documented algorithm families; source excerpts and the index establish many imports, but not every runtime detail, so unsupported links are omitted.

Main entry points: [`src/components/Nav.tsx`](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/Nav.tsx) (Navigation controls), [`src/utils/helpers.ts`](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/helpers.ts) (Grid helpers), [`src/App.tsx`](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/App.tsx) (App shell), [`src/utils/runPathfindingAlgorithm.ts`](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/runPathfindingAlgorithm.ts) (Search dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["App shell<br/>[App.tsx]"]
  node_nav["Navigation controls<br/>[Nav.tsx]"]
  node_gridview["Grid view<br/>[Grid.tsx]"]
  node_tile["Tile view<br/>[Tile.tsx]"]
  node_select["Select control<br/>[Select.tsx]"]
  node_play["Play control<br/>[PlayButton.tsx]"]
end

subgraph group_state["Application state"]
  node_pathstate["Pathfinding state"]
  node_tilestate["Tile state<br/>[TileContext.tsx]"]
  node_speedstate["Speed state<br/>[SpeedContext.tsx]"]
  node_pathhook["Pathfinding hook<br/>[usePathfinding.tsx]"]
  node_tilehook["Tile hook<br/>[useTile.tsx]"]
  node_speedhook["Speed hook<br/>[useSpeed.tsx]"]
end

subgraph group_workflow["Visualization workflow"]
  node_pathdispatch["Search dispatcher"]
  node_mazedispatch["Maze dispatcher"]
  node_animation["Path animation<br/>[animatePath.ts]"]
  node_reset["Grid reset<br/>[resetGrid.ts]"]
end

subgraph group_search["Pathfinding algorithms"]
  node_astar["A-star<br/>[aStar.ts]"]
  node_bfs["Breadth-first search<br/>[bfs.ts]"]
  node_dfs["Depth-first search<br/>[dfs.ts]"]
  node_dijkstra["Dijkstra<br/>[dijkstra.ts]"]
end

subgraph group_maze["Maze algorithms"]
  node_binary["Binary-tree maze<br/>[binaryTree.ts]"]
  node_recursive["Recursive division"]
  node_horizontal["Horizontal division"]
  node_vertical["Vertical division"]
end

subgraph group_shared["Shared algorithm logic"]
  node_neighbors["Neighbor lookup"]
  node_heuristics["Search heuristics<br/>[heuristics.ts]"]
  node_gridhelpers["Grid helpers<br/>[helpers.ts]"]
end

node_user(("App user"))

node_user -->|"chooses options"| node_nav
node_user -->|"edits grid"| node_gridview
node_app -->|"renders"| node_nav
node_app -->|"renders"| node_gridview
node_app -->|"provides state"| node_pathstate
node_app -->|"provides state"| node_tilestate
node_app -->|"provides state"| node_speedstate
node_gridview -->|"renders"| node_tile
node_gridview -->|"reads state"| node_pathhook
node_nav -->|"reads state"| node_pathhook
node_nav -->|"reads state"| node_tilehook
node_nav -->|"reads state"| node_speedhook
node_pathhook -->|"reads context"| node_pathstate
node_tilehook -->|"reads context"| node_tilestate
node_speedhook -->|"reads context"| node_speedstate
node_nav -->|"renders"| node_select
node_nav -->|"renders"| node_play
node_nav -->|"runs maze"| node_mazedispatch
node_nav -->|"runs search"| node_pathdispatch
node_nav -->|"animates result"| node_animation
node_nav -->|"resets grid"| node_reset
node_pathdispatch -->|"dispatches"| node_astar
node_pathdispatch -->|"dispatches"| node_bfs
node_pathdispatch -->|"dispatches"| node_dfs
node_pathdispatch -->|"dispatches"| node_dijkstra
node_mazedispatch -->|"dispatches"| node_binary
node_mazedispatch -->|"dispatches"| node_recursive
node_recursive -->|"divides recursively"| node_horizontal
node_recursive -->|"divides recursively"| node_vertical
node_astar -->|"gets neighbors"| node_neighbors
node_astar -->|"uses costs"| node_heuristics
node_astar -->|"uses queue helpers"| node_gridhelpers
node_bfs -->|"gets neighbors"| node_neighbors
node_bfs -->|"uses helpers"| node_gridhelpers
node_dfs -->|"gets neighbors"| node_neighbors
node_dfs -->|"uses helpers"| node_gridhelpers
node_dijkstra -->|"gets neighbors"| node_neighbors
node_dijkstra -->|"uses helpers"| node_gridhelpers
node_binary -->|"uses helpers"| node_gridhelpers
node_horizontal -->|"uses helpers"| node_gridhelpers
node_vertical -->|"uses helpers"| node_gridhelpers

click node_app "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/App.tsx"
click node_nav "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/Nav.tsx"
click node_gridview "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/Grid.tsx"
click node_tile "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/Tile.tsx"
click node_select "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/Select.tsx"
click node_play "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/PlayButton.tsx"
click node_pathstate "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/context/PathfindingContext.tsx"
click node_tilestate "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/context/TileContext.tsx"
click node_speedstate "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/context/SpeedContext.tsx"
click node_pathhook "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/hooks/usePathfinding.tsx"
click node_tilehook "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/hooks/useTile.tsx"
click node_speedhook "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/hooks/useSpeed.tsx"
click node_pathdispatch "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/runPathfindingAlgorithm.ts"
click node_mazedispatch "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/runMazeAlgorithm.ts"
click node_animation "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/animatePath.ts"
click node_reset "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/resetGrid.ts"
click node_astar "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/pathfinding/aStar.ts"
click node_bfs "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/pathfinding/bfs.ts"
click node_dfs "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/pathfinding/dfs.ts"
click node_dijkstra "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/pathfinding/dijkstra.ts"
click node_binary "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/maze/binaryTree.ts"
click node_recursive "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/maze/recursiveDivision.ts"
click node_horizontal "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/maze/horizontalDivision.ts"
click node_vertical "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/maze/verticalDivision.ts"
click node_neighbors "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/getUntraversedNeighbors.ts"
click node_heuristics "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/heuristics.ts"
click node_gridhelpers "https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/helpers.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_nav,node_gridview,node_tile,node_select,node_play,node_user toneBlue
class node_pathstate,node_tilestate,node_speedstate,node_pathhook,node_tilehook,node_speedhook toneAmber
class node_pathdispatch,node_mazedispatch,node_animation,node_reset toneMint
class node_astar,node_bfs,node_dfs,node_dijkstra toneRose
class node_binary,node_recursive,node_horizontal,node_vertical toneIndigo
class node_neighbors,node_heuristics,node_gridhelpers toneTeal
```

## Components

### User interface

- [App shell](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/App.tsx): `src/App.tsx`
- [Navigation controls](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/Nav.tsx): `src/components/Nav.tsx`
- [Grid view](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/Grid.tsx): `src/components/Grid.tsx`
- [Tile view](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/Tile.tsx): `src/components/Tile.tsx`
- [Select control](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/Select.tsx): `src/components/Select.tsx`
- [Play control](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/components/PlayButton.tsx): `src/components/PlayButton.tsx`

### Application state

- [Pathfinding state](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/context/PathfindingContext.tsx): `src/context/PathfindingContext.tsx`
- [Tile state](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/context/TileContext.tsx): `src/context/TileContext.tsx`
- [Speed state](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/context/SpeedContext.tsx): `src/context/SpeedContext.tsx`
- [Pathfinding hook](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/hooks/usePathfinding.tsx): `src/hooks/usePathfinding.tsx`
- [Tile hook](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/hooks/useTile.tsx): `src/hooks/useTile.tsx`
- [Speed hook](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/hooks/useSpeed.tsx): `src/hooks/useSpeed.tsx`

### Visualization workflow

- [Search dispatcher](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/runPathfindingAlgorithm.ts): `src/utils/runPathfindingAlgorithm.ts`
- [Maze dispatcher](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/runMazeAlgorithm.ts): `src/utils/runMazeAlgorithm.ts`
- [Path animation](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/animatePath.ts): `src/utils/animatePath.ts`
- [Grid reset](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/resetGrid.ts): `src/utils/resetGrid.ts`

### Pathfinding algorithms

- [A-star](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/pathfinding/aStar.ts): `src/lib/algorithms/pathfinding/aStar.ts`
- [Breadth-first search](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/pathfinding/bfs.ts): `src/lib/algorithms/pathfinding/bfs.ts`
- [Depth-first search](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/pathfinding/dfs.ts): `src/lib/algorithms/pathfinding/dfs.ts`
- [Dijkstra](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/pathfinding/dijkstra.ts): `src/lib/algorithms/pathfinding/dijkstra.ts`

### Maze algorithms

- [Binary-tree maze](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/maze/binaryTree.ts): `src/lib/algorithms/maze/binaryTree.ts`
- [Recursive division](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/maze/recursiveDivision.ts): `src/lib/algorithms/maze/recursiveDivision.ts`
- [Horizontal division](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/maze/horizontalDivision.ts): `src/lib/algorithms/maze/horizontalDivision.ts`
- [Vertical division](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/lib/algorithms/maze/verticalDivision.ts): `src/lib/algorithms/maze/verticalDivision.ts`

### Shared algorithm logic

- [Neighbor lookup](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/getUntraversedNeighbors.ts): `src/utils/getUntraversedNeighbors.ts`
- [Search heuristics](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/heuristics.ts): `src/utils/heuristics.ts`
- [Grid helpers](https://github.com/techprep-gh/pathfinding-visualizer/blob/main/src/utils/helpers.ts): `src/utils/helpers.ts`

### Other components

- **App user**

## Connections

- App user → Navigation controls: chooses options (evidence: `src/components/Nav.tsx`)
- App user → Grid view: edits grid (evidence: `src/components/Grid.tsx`)
- App shell → Navigation controls: renders (evidence: `src/App.tsx`)
- App shell → Grid view: renders (evidence: `src/App.tsx`)
- App shell → Pathfinding state: provides state (evidence: `src/App.tsx`)
- App shell → Tile state: provides state (evidence: `src/App.tsx`)
- App shell → Speed state: provides state (evidence: `src/App.tsx`)
- Grid view → Tile view: renders (evidence: `src/components/Grid.tsx`)
- Grid view → Pathfinding hook: reads state (evidence: `src/components/Grid.tsx`)
- Navigation controls → Pathfinding hook: reads state (evidence: `src/components/Nav.tsx`)
- Navigation controls → Tile hook: reads state (evidence: `src/components/Nav.tsx`)
- Navigation controls → Speed hook: reads state (evidence: `src/components/Nav.tsx`)
- Pathfinding hook → Pathfinding state: reads context (evidence: `src/hooks/usePathfinding.tsx`)
- Tile hook → Tile state: reads context (evidence: `src/hooks/useTile.tsx`)
- Speed hook → Speed state: reads context (evidence: `src/hooks/useSpeed.tsx`)
- Navigation controls → Select control: renders (evidence: `src/components/Nav.tsx`)
- Navigation controls → Play control: renders (evidence: `src/components/Nav.tsx`)
- Navigation controls → Maze dispatcher: runs maze (evidence: `src/components/Nav.tsx`)
- Navigation controls → Search dispatcher: runs search (evidence: `src/components/Nav.tsx`)
- Navigation controls → Path animation: animates result (evidence: `src/components/Nav.tsx`)
- Navigation controls → Grid reset: resets grid (evidence: `src/components/Nav.tsx`)
- Search dispatcher → A-star: dispatches (evidence: `src/utils/runPathfindingAlgorithm.ts`)
- Search dispatcher → Breadth-first search: dispatches (evidence: `src/utils/runPathfindingAlgorithm.ts`)
- Search dispatcher → Depth-first search: dispatches (evidence: `src/utils/runPathfindingAlgorithm.ts`)
- Search dispatcher → Dijkstra: dispatches (evidence: `src/utils/runPathfindingAlgorithm.ts`)
- Maze dispatcher → Binary-tree maze: dispatches (evidence: `src/utils/runMazeAlgorithm.ts`)
- Maze dispatcher → Recursive division: dispatches (evidence: `src/utils/runMazeAlgorithm.ts`)
- Recursive division → Horizontal division: divides recursively (evidence: `src/lib/algorithms/maze/recursiveDivision.ts`)
- Recursive division → Vertical division: divides recursively (evidence: `src/lib/algorithms/maze/recursiveDivision.ts`)
- A-star → Neighbor lookup: gets neighbors (evidence: `src/lib/algorithms/pathfinding/aStar.ts`)
- A-star → Search heuristics: uses costs (evidence: `src/lib/algorithms/pathfinding/aStar.ts`)
- A-star → Grid helpers: uses queue helpers (evidence: `src/lib/algorithms/pathfinding/aStar.ts`)
- Breadth-first search → Neighbor lookup: gets neighbors (evidence: `src/lib/algorithms/pathfinding/bfs.ts`)
- Breadth-first search → Grid helpers: uses helpers (evidence: `src/lib/algorithms/pathfinding/bfs.ts`)
- Depth-first search → Neighbor lookup: gets neighbors (evidence: `src/lib/algorithms/pathfinding/dfs.ts`)
- Depth-first search → Grid helpers: uses helpers (evidence: `src/lib/algorithms/pathfinding/dfs.ts`)
- Dijkstra → Neighbor lookup: gets neighbors (evidence: `src/lib/algorithms/pathfinding/dijkstra.ts`)
- Dijkstra → Grid helpers: uses helpers (evidence: `src/lib/algorithms/pathfinding/dijkstra.ts`)
- Binary-tree maze → Grid helpers: uses helpers (evidence: `src/lib/algorithms/maze/binaryTree.ts`)
- Horizontal division → Grid helpers: uses helpers (evidence: `src/lib/algorithms/maze/horizontalDivision.ts`)
- Vertical division → Grid helpers: uses helpers (evidence: `src/lib/algorithms/maze/verticalDivision.ts`)
