# marvi401/algorithmcomparation architecture

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

- Interactive diagram: https://gitdiagram.com/marvi401/algorithmcomparation
- Repository: https://github.com/marvi401/algorithmcomparation

## Overview

Pathfinding Labs is a browser-based visualizer for comparing graph-search and reinforcement-learning pathfinding. Users choose a grid preset or draw walls, select Dijkstra, A*, Q-Learning, or Hybrid, then inspect the animated route and exploration, path-length, and timing metrics; learning modes also expose training progress and learned-path playback. The React app wires the interface to a custom hook that owns grid state, algorithm execution, training, and results. Algorithm stages share that hook implementation. Some documented capabilities are represented from the README; unsampled relationships are omitted.

Main entry points: [`src/hooks/usePathfinding.js`](https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js) (Pathfinding hook), [`src/App.jsx`](https://github.com/marvi401/algorithmcomparation/blob/main/src/App.jsx) (App orchestrator), [`src/components/Sidebar.jsx`](https://github.com/marvi401/algorithmcomparation/blob/main/src/components/Sidebar.jsx) (Controls and presets), [`src/components/GridBoard.jsx`](https://github.com/marvi401/algorithmcomparation/blob/main/src/components/GridBoard.jsx) (Interactive board)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Interactive interface"]
  node_app["App orchestrator<br/>[App.jsx]"]
  node_controls["Controls and presets<br/>[Sidebar.jsx]"]
end

subgraph group_environment["Grid environment"]
  node_board["Interactive board<br/>[GridBoard.jsx]"]
  node_gridstate["Grid and scenarios<br/>[usePathfinding.js]"]
end

subgraph group_search["Search and learning"]
  node_engine["Pathfinding hook<br/>[usePathfinding.js]"]
  node_dijkstra["Dijkstra search<br/>[usePathfinding.js]"]
  node_astar["A-star search<br/>[usePathfinding.js]"]
  node_qlearn["Q-learning training<br/>[usePathfinding.js]"]
  node_hybrid["Hybrid training<br/>[usePathfinding.js]"]
end

subgraph group_results["Results and feedback"]
  node_playback["Learned path playback<br/>[usePathfinding.js]"]
  node_metrics["Run metrics<br/>[Header.jsx]"]
  node_trainingview["Training progress<br/>[TrainingModal.jsx]"]
  node_errorview["Unreachable-path dialog<br/>[ErrorModal.jsx]"]
end

node_user(("Researcher"))

node_user -->|"chooses mode"| node_controls
node_user -->|"draws walls"| node_board
node_app -->|"uses hook"| node_engine
node_app -->|"renders controls"| node_controls
node_app -->|"renders grid"| node_board
node_app -->|"renders training"| node_trainingview
node_app -->|"renders errors"| node_errorview
node_controls -->|"dispatches run"| node_engine
node_board -->|"updates walls"| node_gridstate
node_gridstate -.->|"provides grid"| node_engine
node_engine -->|"runs search"| node_dijkstra
node_engine -->|"runs search"| node_astar
node_engine -->|"trains agent"| node_qlearn
node_engine -->|"trains agent"| node_hybrid
node_trainingview -->|"requests playback"| node_engine
node_engine -->|"infers route"| node_playback
node_engine -->|"supplies statistics"| node_metrics
node_engine -->|"supplies progress"| node_trainingview
node_engine -->|"reports failure"| node_errorview
node_controls -->|"selects preset"| node_gridstate

click node_app "https://github.com/marvi401/algorithmcomparation/blob/main/src/App.jsx"
click node_controls "https://github.com/marvi401/algorithmcomparation/blob/main/src/components/Sidebar.jsx"
click node_board "https://github.com/marvi401/algorithmcomparation/blob/main/src/components/GridBoard.jsx"
click node_gridstate "https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js"
click node_engine "https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js"
click node_dijkstra "https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js"
click node_astar "https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js"
click node_qlearn "https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js"
click node_hybrid "https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js"
click node_playback "https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js"
click node_metrics "https://github.com/marvi401/algorithmcomparation/blob/main/src/components/Header.jsx"
click node_trainingview "https://github.com/marvi401/algorithmcomparation/blob/main/src/components/TrainingModal.jsx"
click node_errorview "https://github.com/marvi401/algorithmcomparation/blob/main/src/components/ErrorModal.jsx"

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_controls toneBlue
class node_board,node_gridstate toneAmber
class node_engine,node_dijkstra,node_astar,node_qlearn,node_hybrid toneMint
class node_playback,node_metrics,node_trainingview,node_errorview toneRose
class node_user toneIndigo
```

## Components

### Interactive interface

- [App orchestrator](https://github.com/marvi401/algorithmcomparation/blob/main/src/App.jsx): `src/App.jsx`
- [Controls and presets](https://github.com/marvi401/algorithmcomparation/blob/main/src/components/Sidebar.jsx): `src/components/Sidebar.jsx`

### Grid environment

- [Interactive board](https://github.com/marvi401/algorithmcomparation/blob/main/src/components/GridBoard.jsx): `src/components/GridBoard.jsx`
- [Grid and scenarios](https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js): `src/hooks/usePathfinding.js`

### Search and learning

- [Pathfinding hook](https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js): `src/hooks/usePathfinding.js`
- [Dijkstra search](https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js): `src/hooks/usePathfinding.js`
- [A-star search](https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js): `src/hooks/usePathfinding.js`
- [Q-learning training](https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js): `src/hooks/usePathfinding.js`
- [Hybrid training](https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js): `src/hooks/usePathfinding.js`

### Results and feedback

- [Learned path playback](https://github.com/marvi401/algorithmcomparation/blob/main/src/hooks/usePathfinding.js): `src/hooks/usePathfinding.js`
- [Run metrics](https://github.com/marvi401/algorithmcomparation/blob/main/src/components/Header.jsx): `src/components/Header.jsx`
- [Training progress](https://github.com/marvi401/algorithmcomparation/blob/main/src/components/TrainingModal.jsx): `src/components/TrainingModal.jsx`
- [Unreachable-path dialog](https://github.com/marvi401/algorithmcomparation/blob/main/src/components/ErrorModal.jsx): `src/components/ErrorModal.jsx`

### Other components

- **Researcher**

## Connections

- Researcher → Controls and presets: chooses mode (evidence: `src/components/Sidebar.jsx`)
- Researcher → Interactive board: draws walls (evidence: `src/components/GridBoard.jsx`)
- App orchestrator → Pathfinding hook: uses hook (evidence: `src/App.jsx`)
- App orchestrator → Controls and presets: renders controls (evidence: `src/App.jsx`)
- App orchestrator → Interactive board: renders grid (evidence: `src/App.jsx`)
- App orchestrator → Training progress: renders training (evidence: `src/App.jsx`)
- App orchestrator → Unreachable-path dialog: renders errors (evidence: `src/App.jsx`)
- Controls and presets → Pathfinding hook: dispatches run (evidence: `src/components/Sidebar.jsx`)
- Interactive board → Grid and scenarios: updates walls (evidence: `src/components/GridBoard.jsx`)
- Grid and scenarios → Pathfinding hook: provides grid (evidence: `src/hooks/usePathfinding.js`)
- Pathfinding hook → Dijkstra search: runs search (evidence: `src/hooks/usePathfinding.js`)
- Pathfinding hook → A-star search: runs search (evidence: `src/hooks/usePathfinding.js`)
- Pathfinding hook → Q-learning training: trains agent (evidence: `src/hooks/usePathfinding.js`)
- Pathfinding hook → Hybrid training: trains agent (evidence: `src/hooks/usePathfinding.js`)
- Training progress → Pathfinding hook: requests playback (evidence: `src/App.jsx`)
- Pathfinding hook → Learned path playback: infers route (evidence: `src/hooks/usePathfinding.js`)
- Pathfinding hook → Run metrics: supplies statistics (evidence: `src/App.jsx`)
- Pathfinding hook → Training progress: supplies progress (evidence: `src/App.jsx`)
- Pathfinding hook → Unreachable-path dialog: reports failure (evidence: `src/App.jsx`)
- Controls and presets → Grid and scenarios: selects preset (evidence: `src/components/Sidebar.jsx`)
