# surajklmn/algolizer architecture

> Architecture diagram of the GitHub repository surajklmn/algolizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/surajklmn/algolizer
- Repository: https://github.com/surajklmn/algolizer

## Overview

##### Project type and purpose
- Algolizer is a C++-based desktop application (an open-source visualization tool) that uses Raylib (and Raygui) to render and interactively demonstrate data structures and algorithms in real time.

##### File structure
- Top-level:
- CMakeLists.txt – build configuration
- docs/ – design proposals and reports
- external/raygui – third-party UI widget library
- src/ – application source code
- src/ is subdivided into:
- core modules (array, linked_list, tree, graph) – implement data structures
- algorithm modules (bubble_sort, quick_sort, binary_search, etc.)
- utils (InputBox) – UI helper
- main.cpp / main.h – application entry point, event loop, and coordinator

##### Key insights from README
- Core functionality: interactive visualization of structures and step-by-step algorithms
- Dependencies: Raylib (graphics), Raygui (widgets), CMake, GCC/G++
- No network or persistent storage—purely in-memory, real-time graphics

##### Main components
a. Application Entry Point (main)
– Initializes Raylib, sets up window & canvas
– Loads/initializes Raygui
– Drives the main event/render loop
b. UI Layer
– Raygui widgets for menus, buttons, InputBox (src/utils)
– Captures user input (select structure/algorithm, tweak parameters)
c. Controller / Coordinator
– Interprets UI events, dispatches to algorithm/data modules
– Manages “play/pause/step” state for animations
d. Model (Data Structures & Algorithms)
– Data modules: array, linked_list, tree, graph
– Algorithm modules: sorting (bubble, quick, merge, selection, insertion), searching (binary, linear), queue, stack
– Each algorithm exposes a “step()” API to advance visualization state
e. Visualization Engine (View)
f. External Libraries
– Raylib: windowing, drawing, input, timing
– Raygui: high-level UI widgets
g. Build System
– CMake orchestrates compilation, links Raylib and the app

##### Relationships and data flows
- User Input → Raygui (UI Layer) → Controller
- Controller → Model (algorithm/data) “step” / “reset” calls
- Model returns updated state → Visualization Engine
- Main loop coordinates polling, updating, rendering each frame

##### Architectural patterns & design principles
- Modular separation of concerns: UI, Controller, Model, View
- Plugin-style algorithm modules: easy to add new algorithms by conforming to a “step()” interface
- In-memory, single-process desktop app—no network or DB layers

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::external
    subgraph "Application Entry Point (main)"
        MainCPP["main.cpp"]:::core
        MainH["main.h"]:::core
    end
    subgraph "UI Layer"
        Raygui["Raygui (Widgets)"]:::external
        InputBoxCPP["InputBox.cpp"]:::core
        InputBoxH["InputBox.h"]:::core
    end
    subgraph "Controller / Coordinator"
        Controller["Controller"]:::core
    end
    subgraph "Model"
        subgraph "Data Structures"
            ArrayCPP["array.cpp"]:::core
            ArrayH["array.h"]:::core
            LLCPP["linked_list.cpp"]:::core
            LLH["linked_list.hpp"]:::core
            TreeCPP["tree.cpp"]:::core
            TreeH["tree.hpp"]:::core
            GraphCPP["graph.cpp"]:::core
            GraphH["graph.h"]:::core
            QueueCPP["queue.cpp"]:::core
            QueueH["queue.h"]:::core
            StackCPP["stack.cpp"]:::core
            StackH["stack.h"]:::core
        end
        subgraph "Algorithm Modules"
            BubbleCPP["bubble_sort.cpp"]:::core
            BubbleH["bubble_sort.h"]:::core
            SelCPP["selection_sort.cpp"]:::core
            SelH["selection_sort.h"]:::core
            InsCPP["insertion_sort.cpp"]:::core
            InsH["insertion_sort.h"]:::core
            MergeCPP["merge_sort.cpp"]:::core
            MergeH["merge_sort.hpp"]:::core
            QuickCPP["quick_sort.cpp"]:::core
            QuickH["quick_sort.hpp"]:::core
            BinCPP["binary_search.cpp"]:::core
            BinH["binary_search.h"]:::core
            LinCPP["linear_search.cpp"]:::core
            LinH["linear_search.h"]:::core
        end
    end
    subgraph "Visualization Engine (View)"
        View["Raylib Draw Calls"]:::core
    end
    subgraph "External Libraries"
        Raylib["Raylib"]:::external
    end
    Build["CMakeLists.txt"]:::config

    %% Connections
    User -->|"interacts"| Raygui
    Raygui -->|"UI events"| Controller
    Controller -->|"step()/reset() calls"| ArrayCPP
    Controller -->|"step()/reset() calls"| BubbleCPP
    Controller -->|"step()/reset() calls"| SelCPP
    Controller -->|"step()/reset() calls"| InsCPP
    Controller -->|"step()/reset() calls"| MergeCPP
    Controller -->|"step()/reset() calls"| QuickCPP
    Controller -->|"step()/reset() calls"| BinCPP
    Controller -->|"step()/reset() calls"| LinCPP
    ArrayCPP -->|"state"| View
    LLCPP -->|"state"| View
    TreeCPP -->|"state"| View
    GraphCPP -->|"state"| View
    QueueCPP -->|"state"| View
    StackCPP -->|"state"| View
    BubbleCPP -->|"state"| View
    SelCPP -->|"state"| View
    InsCPP -->|"state"| View
    MergeCPP -->|"state"| View
    QuickCPP -->|"state"| View
    BinCPP -->|"state"| View
    LinCPP -->|"state"| View
    View -->|"draw()/update"| Raylib
    MainCPP --> Controller
    MainCPP --> Raylib
    Build -->|"build/link"| MainCPP
    Build -->|"link"| Raylib

    %% Click Events
    click MainCPP "https://github.com/surajklmn/algolizer/blob/main/src/main.cpp"
    click MainH "https://github.com/surajklmn/algolizer/blob/main/src/main.h"
    click Raygui "https://github.com/surajklmn/algolizer/blob/main/external/raygui/raygui.h"
    click InputBoxCPP "https://github.com/surajklmn/algolizer/blob/main/src/utils/InputBox.cpp"
    click InputBoxH "https://github.com/surajklmn/algolizer/blob/main/src/utils/InputBox.h"
    click ArrayCPP "https://github.com/surajklmn/algolizer/blob/main/src/array.cpp"
    click ArrayH "https://github.com/surajklmn/algolizer/blob/main/src/array.h"
    click LLCPP "https://github.com/surajklmn/algolizer/blob/main/src/linked_list.cpp"
    click LLH "https://github.com/surajklmn/algolizer/blob/main/src/linked_list.hpp"
    click TreeCPP "https://github.com/surajklmn/algolizer/blob/main/src/tree.cpp"
    click TreeH "https://github.com/surajklmn/algolizer/blob/main/src/tree.hpp"
    click GraphCPP "https://github.com/surajklmn/algolizer/blob/main/src/graph.cpp"
    click GraphH "https://github.com/surajklmn/algolizer/blob/main/src/graph.h"
    click QueueCPP "https://github.com/surajklmn/algolizer/blob/main/src/queue.cpp"
    click QueueH "https://github.com/surajklmn/algolizer/blob/main/src/queue.h"
    click StackCPP "https://github.com/surajklmn/algolizer/blob/main/src/stack.cpp"
    click StackH "https://github.com/surajklmn/algolizer/blob/main/src/stack.h"
    click BubbleCPP "https://github.com/surajklmn/algolizer/blob/main/src/bubble_sort.cpp"
    click BubbleH "https://github.com/surajklmn/algolizer/blob/main/src/bubble_sort.h"
    click SelCPP "https://github.com/surajklmn/algolizer/blob/main/src/selection_sort.cpp"
    click SelH "https://github.com/surajklmn/algolizer/blob/main/src/selection_sort.h"
    click InsCPP "https://github.com/surajklmn/algolizer/blob/main/src/insertion_sort.cpp"
    click InsH "https://github.com/surajklmn/algolizer/blob/main/src/insertion_sort.h"
    click MergeCPP "https://github.com/surajklmn/algolizer/blob/main/src/merge_sort.cpp"
    click MergeH "https://github.com/surajklmn/algolizer/blob/main/src/merge_sort.hpp"
    click QuickCPP "https://github.com/surajklmn/algolizer/blob/main/src/quick_sort.cpp"
    click QuickH "https://github.com/surajklmn/algolizer/blob/main/src/quick_sort.hpp"
    click BinCPP "https://github.com/surajklmn/algolizer/blob/main/src/binary_search.cpp"
    click BinH "https://github.com/surajklmn/algolizer/blob/main/src/binary_search.h"
    click LinCPP "https://github.com/surajklmn/algolizer/blob/main/src/linear_search.cpp"
    click LinH "https://github.com/surajklmn/algolizer/blob/main/src/linear_search.h"
    click Build "https://github.com/surajklmn/algolizer/blob/main/CMakeLists.txt"

    %% Styles
    classDef core fill:#cce5ff,stroke:#004085,color:#004085
    classDef external fill:#d4edda,stroke:#155724,color:#155724
    classDef config fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
