# ujjwal-1267/algorithm-visualizer architecture

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

- Interactive diagram: https://gitdiagram.com/ujjwal-1267/algorithm-visualizer
- Repository: https://github.com/ujjwal-1267/algorithm-visualizer

## Overview

Algorithm Visualizer is a browser-based learning tool: users choose an algorithm, supply or generate input, and control a replay of its recorded events on a canvas. The architecture separates algorithm execution from playback and rendering, with shared state and UI panels for controls, pseudocode, complexity, status, and statistics. The README documents the event pipeline and capabilities; sampled app excerpts show setup and dispatch, while some UI wiring and individual algorithm implementations are unsampled, so those links are omitted or based on documented behavior.

Main entry points: [`js/app.js`](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/app.js) (App orchestration), [`js/core/AnimationEngine.js`](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/AnimationEngine.js) (Animation engine), [`js/core/AlgorithmRegistry.js`](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/AlgorithmRegistry.js) (Algorithm registry), [`js/core/EventQueue.js`](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/EventQueue.js) (Event queue)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_app["App orchestration<br/>[app.js]"]
  node_sidebar["Algorithm browser<br/>[Sidebar.js]"]
  node_controls["Playback controls<br/>[Controls.js]"]
  node_panels["Info and status panels"]
end

subgraph group_runtime["Visualization runtime"]
  node_registry["Algorithm registry"]
  node_state["Shared state<br/>[StateManager.js]"]
  node_queue["Event queue<br/>[EventQueue.js]"]
  node_engine["Animation engine<br/>[AnimationEngine.js]"]
  node_canvas["Canvas manager<br/>[CanvasManager.js]"]
  node_arrayrender["Array renderer<br/>[ArrayRenderer.js]"]
  node_graphrender["Graph renderer<br/>[GraphRenderer.js]"]
  node_treerender["Tree renderer<br/>[TreeRenderer.js]"]
end

subgraph group_algorithms["Algorithm domains"]
  node_sortsearch["Sorting and search"]
  node_graphalgo["Graph algorithms"]
  node_treealgo["Tree algorithms"]
end

subgraph group_support["Data and input"]
  node_arraygen["Array generator<br/>[arrayGenerator.js]"]
  node_graphgen["Graph generator<br/>[graphGenerator.js]"]
  node_treegen["Tree generator<br/>[treeGenerator.js]"]
  node_algoinfo["Algorithm information<br/>[algorithmInfo.js]"]
  node_pseudocode["Pseudocode data<br/>[pseudocode.js]"]
end

node_learner(("Learner"))

node_learner -->|"chooses algorithm"| node_sidebar
node_learner -.->|"controls playback"| node_controls
node_sidebar -->|"searches algorithms"| node_registry
node_sidebar -->|"selects algorithm"| node_app
node_app -->|"loads algorithm"| node_registry
node_app -->|"generates arrays"| node_arraygen
node_app -->|"generates graphs"| node_graphgen
node_app -->|"generates trees"| node_treegen
node_registry -->|"lazy-loads"| node_sortsearch
node_registry -->|"lazy-loads"| node_graphalgo
node_registry -->|"lazy-loads"| node_treealgo
node_app -->|"runs algorithm"| node_sortsearch
node_app -->|"runs algorithm"| node_graphalgo
node_app -->|"runs algorithm"| node_treealgo
node_sortsearch -.->|"records events"| node_queue
node_graphalgo -.->|"records events"| node_queue
node_treealgo -.->|"records events"| node_queue
node_app -->|"clears queue"| node_queue
node_app -.->|"attaches queue"| node_engine
node_engine -->|"replays events"| node_queue
node_engine -->|"updates playback state"| node_state
node_engine -.->|"applies events"| node_arrayrender
node_engine -.->|"applies events"| node_graphrender
node_engine -.->|"applies events"| node_treerender
node_arrayrender -.->|"draws bars"| node_canvas
node_graphrender -.->|"draws graph"| node_canvas
node_treerender -.->|"draws tree"| node_canvas
node_controls -->|"observes state"| node_state
node_panels -.->|"displays state"| node_state
node_panels -->|"shows complexity"| node_algoinfo
node_panels -->|"shows pseudocode"| node_pseudocode
node_panels -->|"syncs highlights"| node_state

click node_app "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/app.js"
click node_sidebar "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/ui/Sidebar.js"
click node_controls "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/ui/Controls.js"
click node_panels "https://github.com/ujjwal-1267/algorithm-visualizer/tree/main/js/ui"
click node_registry "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/AlgorithmRegistry.js"
click node_state "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/StateManager.js"
click node_queue "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/EventQueue.js"
click node_engine "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/AnimationEngine.js"
click node_canvas "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/visualizer/CanvasManager.js"
click node_arrayrender "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/visualizer/ArrayRenderer.js"
click node_graphrender "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/visualizer/GraphRenderer.js"
click node_treerender "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/visualizer/TreeRenderer.js"
click node_sortsearch "https://github.com/ujjwal-1267/algorithm-visualizer/tree/main/js/algorithms"
click node_graphalgo "https://github.com/ujjwal-1267/algorithm-visualizer/tree/main/js/algorithms/graph"
click node_treealgo "https://github.com/ujjwal-1267/algorithm-visualizer/tree/main/js/algorithms/tree"
click node_arraygen "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/generators/arrayGenerator.js"
click node_graphgen "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/generators/graphGenerator.js"
click node_treegen "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/generators/treeGenerator.js"
click node_algoinfo "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/data/algorithmInfo.js"
click node_pseudocode "https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/data/pseudocode.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,node_sidebar,node_controls,node_panels toneBlue
class node_registry,node_state,node_queue,node_engine,node_canvas,node_arrayrender,node_graphrender,node_treerender toneAmber
class node_sortsearch,node_graphalgo,node_treealgo toneMint
class node_arraygen,node_graphgen,node_treegen,node_algoinfo,node_pseudocode toneRose
class node_learner toneIndigo
```

## Components

### User experience

- [App orchestration](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/app.js): `js/app.js`
- [Algorithm browser](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/ui/Sidebar.js): `js/ui/Sidebar.js`
- [Playback controls](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/ui/Controls.js): `js/ui/Controls.js`
- [Info and status panels](https://github.com/ujjwal-1267/algorithm-visualizer/tree/main/js/ui): `js/ui`

### Visualization runtime

- [Algorithm registry](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/AlgorithmRegistry.js): `js/core/AlgorithmRegistry.js`
- [Shared state](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/StateManager.js): `js/core/StateManager.js`
- [Event queue](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/EventQueue.js): `js/core/EventQueue.js`
- [Animation engine](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/core/AnimationEngine.js): `js/core/AnimationEngine.js`
- [Canvas manager](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/visualizer/CanvasManager.js): `js/visualizer/CanvasManager.js`
- [Array renderer](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/visualizer/ArrayRenderer.js): `js/visualizer/ArrayRenderer.js`
- [Graph renderer](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/visualizer/GraphRenderer.js): `js/visualizer/GraphRenderer.js`
- [Tree renderer](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/visualizer/TreeRenderer.js): `js/visualizer/TreeRenderer.js`

### Algorithm domains

- [Sorting and search](https://github.com/ujjwal-1267/algorithm-visualizer/tree/main/js/algorithms): `js/algorithms`
- [Graph algorithms](https://github.com/ujjwal-1267/algorithm-visualizer/tree/main/js/algorithms/graph): `js/algorithms/graph`
- [Tree algorithms](https://github.com/ujjwal-1267/algorithm-visualizer/tree/main/js/algorithms/tree): `js/algorithms/tree`

### Data and input

- [Array generator](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/generators/arrayGenerator.js): `js/generators/arrayGenerator.js`
- [Graph generator](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/generators/graphGenerator.js): `js/generators/graphGenerator.js`
- [Tree generator](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/generators/treeGenerator.js): `js/generators/treeGenerator.js`
- [Algorithm information](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/data/algorithmInfo.js): `js/data/algorithmInfo.js`
- [Pseudocode data](https://github.com/ujjwal-1267/algorithm-visualizer/blob/main/js/data/pseudocode.js): `js/data/pseudocode.js`

### Other components

- **Learner**

## Connections

- Learner → Algorithm browser: chooses algorithm (evidence: `js/ui/Sidebar.js`)
- Learner → Playback controls: controls playback
- Algorithm browser → Algorithm registry: searches algorithms (evidence: `js/ui/Sidebar.js`)
- Algorithm browser → App orchestration: selects algorithm (evidence: `js/ui/Sidebar.js`)
- App orchestration → Algorithm registry: loads algorithm (evidence: `js/app.js`)
- App orchestration → Array generator: generates arrays (evidence: `js/app.js`)
- App orchestration → Graph generator: generates graphs (evidence: `js/app.js`)
- App orchestration → Tree generator: generates trees (evidence: `js/app.js`)
- Algorithm registry → Sorting and search: lazy-loads (evidence: `js/core/AlgorithmRegistry.js`)
- Algorithm registry → Graph algorithms: lazy-loads (evidence: `js/core/AlgorithmRegistry.js`)
- Algorithm registry → Tree algorithms: lazy-loads (evidence: `js/core/AlgorithmRegistry.js`)
- App orchestration → Sorting and search: runs algorithm (evidence: `js/app.js`)
- App orchestration → Graph algorithms: runs algorithm (evidence: `js/app.js`)
- App orchestration → Tree algorithms: runs algorithm (evidence: `js/app.js`)
- Sorting and search → Event queue: records events
- Graph algorithms → Event queue: records events
- Tree algorithms → Event queue: records events
- App orchestration → Event queue: clears queue (evidence: `js/app.js`)
- App orchestration → Animation engine: attaches queue (evidence: `js/app.js`)
- Animation engine → Event queue: replays events (evidence: `js/core/AnimationEngine.js`)
- Animation engine → Shared state: updates playback state (evidence: `js/core/AnimationEngine.js`)
- Animation engine → Array renderer: applies events
- Animation engine → Graph renderer: applies events
- Animation engine → Tree renderer: applies events
- Array renderer → Canvas manager: draws bars
- Graph renderer → Canvas manager: draws graph
- Tree renderer → Canvas manager: draws tree
- Playback controls → Shared state: observes state (evidence: `js/ui/Controls.js`)
- Info and status panels → Shared state: displays state (evidence: `js/ui/StatusBar.js`)
- Info and status panels → Algorithm information: shows complexity (evidence: `js/ui/ComplexityPanel.js`)
- Info and status panels → Pseudocode data: shows pseudocode (evidence: `js/ui/PseudocodePanel.js`)
- Info and status panels → Shared state: syncs highlights (evidence: `js/ui/PseudocodePanel.js`)
