# derek-le1105/algorithm-visualizers architecture

> Architecture diagram of the GitHub repository derek-le1105/algorithm-visualizers, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/derek-le1105/algorithm-visualizers
- Repository: https://github.com/derek-le1105/algorithm-visualizers

## Overview

##### Project Type and Purpose
- This is a front-end web application built with ReactJS. Its purpose is to visually demonstrate different algorithm behaviors in an interactive way.
- The three primary modules are:
- Sorting Visualizer (for demonstrating sorting algorithms)
- Pathfinding Visualizer (for grid-based pathfinding algorithms)
- 8-Tile Solver (for demonstrating state-search and heuristic-based puzzle solving)

##### Main Components
a. Core Application Shell:
- Components such as App.js and index.js serve as the entry point.
- The main navigation (NavBar) and home page (HomePage) components that allow users to switch between modules.

b. Module-Specific Components:
- Sorting Visualizer:
- Contains SortingVisualizer, SortingParameters, and AlgorithmDropDown.
- Has helper functions and various sorting algorithm implementations (bubbleSort, mergeSort, etc.).
- Pathfinding Visualizer:
- Contains Pathfinding component, Node components for the grid, Parameters (including AlgorithmDropDown and SettingBar).
- Implements different maze generation and pathfinding algorithms (A*, DFS, BFS, etc.), along with helper functions.
- 8-Tile Solver:
- Contains the EightTile component with its child components: TreeVisualization, TileSetting, and helper modules (Node, PriorityQueue, A* Search and other search variants).

c. Shared/Utility Components:
- Assets (Images, GIFs for demos)
- Common CSS files cross-cutting the modules.
- Helper functions such as asyncTimeout that appear in various parts of the application.

##### Relationships and Interactions
- The NavBar component provides navigation between the Sorting, Pathfinding, and 8-Tile modules.
- The App component serves as the container, routing and rendering these modules based on user interaction.
- Each module is self-contained in its own directory under src/components, using subdirectories for algorithms (e.g., SortingAlgorithms, MazeGeneration) and helper functions that perform computational logic.
- There are many splits between UI (e.g., visual display components, settings panels) and logic (e.g., search algorithms, sorting functions, path generation).

##### Architectural Patterns and Design Principles
- The project follows a component-based architecture typical of React applications.
- There is a clear separation of concerns: UI components are separated from algorithm logic (handled in distinct helper files).
- Modules are organized logically by function, supporting an MVC-like separation (View components, algorithm “Controllers”, and utility “Models” or logic functions).
- The use of encapsulated submodules like “PathfindingParameters” and “SortingParameters” suggests a layered design to handle user input, parameter selection, and invocation of the algorithms.

##### Technologies and Their Roles
- ReactJS is the central framework for building the UI.
- HTML and CSS are used for layout and styling.
- JavaScript drives the algorithm implementations and interactions.
- The project does not show server-side components – it maintains a purely client-side interactive app.

##### Final Recommendations for the Principal Software Engineer
- Separation between UI input components (e.g., SettingBar, Dropdowns) and the algorithms responsible for visualizing that logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Application Shell
    subgraph "Core Application Shell"
        index["index.js"]:::entry
        app["App.js"]:::entry
        nav["NavBar"]:::ui
        home["HomePage"]:::ui
    end
    index --> app
    app --> nav
    app --> home

    %% Sorting Visualizer Module
    subgraph "Sorting Visualizer"
        sortingVis["SortingVisualizer"]:::module
        sortingParams["SortingParameters"]:::ui
        sortAlgDropDown["AlgorithmDropDown"]:::ui
        settingBar["SettingBar (Sorting)"]:::ui
        sortAlgorithms["Sorting Algorithms"]:::module
        sortHelpers["Helper Functions (Sorting)"]:::module
    end
    %% Navigation to Sorting Module
    nav -->|"selects"| sortingVis
    app --> sortingVis

    %% Internal flow for Sorting Module
    sortingParams -->|"controls"| sortingVis
    sortAlgDropDown -->|"selects"| sortAlgorithms
    settingBar -->|"configures"| sortAlgorithms
    sortAlgorithms -->|"updates"| sortingVis
    sortHelpers -->|"supports"| sortingVis

    %% Pathfinding Visualizer Module
    subgraph "Pathfinding Visualizer"
        pathfinding["Pathfinding"]:::module
        node["Grid Node"]:::ui
        pathParams["Pathfinding Parameters"]:::ui
        pfAlgDropDown["AlgorithmDropDown (Pathfinding)"]:::ui
        pfSettingBar["SettingBar (Pathfinding)"]:::ui
        pfAlgorithms["Pathfinding Algorithms"]:::module
        mazeGeneration["Maze Generation"]:::module
        pfHelpers["Helper Functions (Pathfinding)"]:::module
    end
    %% Navigation to Pathfinding Module
    nav -->|"selects"| pathfinding
    app --> pathfinding

    %% Internal flow for Pathfinding Module
    pathParams -->|"supplies"| pathfinding
    pfAlgDropDown -->|"chooses"| pfAlgorithms
    pfSettingBar -->|"configures"| pfAlgorithms
    mazeGeneration -->|"generates"| pfAlgorithms
    pfAlgorithms -->|"updates"| pathfinding
    node -->|"renders"| pathfinding
    pfHelpers -->|"supports"| pathfinding

    %% 8-Tile Solver Module
    subgraph "8-Tile Solver"
        eightTile["EightTile"]:::module
        tileSetting["TileSetting"]:::ui
        treeVisualization["TreeVisualization"]:::ui
        eightTileHelpers["Helper Files (8-Tile)"]:::module
    end
    %% Navigation to 8-Tile Module
    nav -->|"selects"| eightTile
    app --> eightTile

    %% Internal flow for 8-Tile Module
    tileSetting -->|"configures"| eightTile
    treeVisualization -->|"visualizes"| eightTile
    eightTileHelpers -->|"supports"| eightTile

    %% Shared Utilities
    subgraph "Shared Utilities"
        assets["Assets"]:::utils
        appcss["Common CSS: App.css"]:::utils
        indexcss["Common CSS: index.css"]:::utils
        sharedHelpers["Shared Helper Functions"]:::utils
    end
    %% Linking Shared Utilities to Module Helpers
    sharedHelpers --> sortHelpers
    sharedHelpers --> pfHelpers
    sharedHelpers --> eightTileHelpers

    %% Click Events
    click index "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/index.js"
    click app "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/App.js"
    click nav "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/NavBar/NavBar.js"
    click home "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/HomePage/Home.js"
    click sortingVis "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/Sorting/SortingVisualizer.js"
    click sortAlgDropDown "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/Sorting/SortingParameters/AlgorithmDropDown/AlgorithmDropDown.js"
    click settingBar "https://github.com/derek-le1105/algorithm-visualizers/tree/main/src/components/Sorting/SortingParameters/SettingBar"
    click sortHelpers "https://github.com/derek-le1105/algorithm-visualizers/tree/main/src/components/Sorting/HelperFunctions"
    click pathfinding "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/Pathfinding/Pathfinding.js"
    click node "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/Pathfinding/Node/index.js"
    click pfAlgDropDown "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/Pathfinding/PathfindingParameters/AlgorithmDropDown/AlgorithmDropDown.js"
    click pfSettingBar "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/Pathfinding/PathfindingParameters/SettingBar/SettingBar.js"
    click mazeGeneration "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/Pathfinding/Algorithms/MazeGeneration/recursiveDivision.js"
    click pfHelpers "https://github.com/derek-le1105/algorithm-visualizers/tree/main/src/components/Pathfinding/HelperFunctions"
    click eightTile "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/EightTile/EightTile.js"
    click tileSetting "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/EightTile/Components/TileSetting.js"
    click treeVisualization "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/components/EightTile/Components/TreeVisualization.js"
    click eightTileHelpers "https://github.com/derek-le1105/algorithm-visualizers/tree/main/src/components/EightTile/HelperFiles"
    click assets "https://github.com/derek-le1105/algorithm-visualizers/tree/main/src/Assets"
    click appcss "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/App.css"
    click indexcss "https://github.com/derek-le1105/algorithm-visualizers/blob/main/src/index.css"

    %% Styles
    classDef entry fill:#fdd,stroke:#900,stroke-width:2px;
    classDef ui fill:#dfd,stroke:#070,stroke-width:2px;
    classDef module fill:#ddf,stroke:#004,stroke-width:2px;
    classDef utils fill:#ffd,stroke:#aa0,stroke-width:2px;
```
