# edrisajobe/sorting-visualizer architecture

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

- Interactive diagram: https://gitdiagram.com/edrisajobe/sorting-visualizer
- Repository: https://github.com/edrisajobe/sorting-visualizer

## Overview

##### Main Components

A. User Interface Layer
- Main Application (Entry Point)
- Visualization View
- Compare View
- Algorithm Ranking View
- Quiz View
- Help View
- FXML resources connection

B. Algorithm Layer
- Abstract Algorithm Base Classes
- Sorting Algorithms Implementation
- Search Algorithms Implementation
- Inheritance relationships

C. State Management
- AlgoState component
- Data flow between algorithms and UI

##### Component Relationships

**[Main Application] → [Controllers] → [Algorithm Components]**
- ↓
- [FXML Resources/Views]

##### Detailed Structure

A. Create three main vertical sections:

- UI Layer     |  |   Controller  |  |   Algorithm    |
- Layer     |  |     Layer      |
- [FXML Views]   |  |              |  |                |
- [CSS Styles]   |  | [Controllers] |  | [Algorithms]   |

##### Important Elements to Highlight

- Inheritance hierarchy:
- AbstractAlgorithm → Specific Algorithm Implementations
- AbstractAlgorithmTree → Tree-based Algorithms

- Demonstrate the MVC pattern:
- Models: Algorithm implementations
- Views: FXML files
- Controllers: *Controller.java files

##### Data Flow Indicators

- User input flow from UI to Controllers
- Algorithm execution flow from Controllers to Algorithms
- Visualization data flow back to UI
- State management flow through AlgoState

##### Technical Details

- JavaFX Framework integration
- FXML-based view management
- CSS styling system
- Module system (module-info.java)

##### The multiple visualization modes (single view, comparison, ranking)

Keep the abstraction level focused on the architectural components while showing enough detail to understand the interaction between the visualization system and the algorithm implementations.

Remember to indicate that this is a standalone Java application with JavaFX, not a web-based or distributed system, which affects how the components interact with each other.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI_Layer
        MainApp["Main Application"]:::entry
        subgraph Views
            MainView["Main View"]:::view
            VisView["Visualization View"]:::view
            CompView["Compare View"]:::view
            RankView["Algorithm Ranking View"]:::view
            QuizView["Quiz View"]:::view
            HelpView["Help View"]:::view
        end
        
        subgraph Resources
            FXML["FXML Resources"]:::resource
            CSS["CSS Styles"]:::resource
        end
    end

    subgraph Controller_Layer
        MainCtrl["Main Controller"]:::controller
        VisCtrl["Visualizer Controller"]:::controller
        CompCtrl["Compare Controller"]:::controller
        RankCtrl["Algorithm Ranking Controller"]:::controller
        QuizCtrl["Quiz Controller"]:::controller
        HelpCtrl["Help Controller"]:::controller
    end

    subgraph Algorithm_Layer
        subgraph Base_Classes
            AbstractAlgo["Abstract Algorithm"]:::base
            AbstractTree["Abstract Algorithm Tree"]:::base
        end

        subgraph Sorting_Algorithms
            BubbleSort["Bubble Sort"]:::algo
            QuickSort["Quick Sort"]:::algo
            MergeSort["Merge Sort"]:::algo
            HeapSort["Heap Sort"]:::algo
            InsertSort["Insertion Sort"]:::algo
            SelectSort["Selection Sort"]:::algo
            TreeSort["Tree Sort"]:::algo
            BucketSort["Bucket Sort"]:::algo
            CountSort["Counting Sort"]:::algo
        end

        subgraph Search_Algorithms
            BinarySearch["Binary Search"]:::algo
            LinearSearch["Linear Search"]:::algo
        end

        AlgoState["Algorithm State"]:::state
    end

    %% Relationships
    MainApp --> MainView
    MainApp --> MainCtrl
    
    MainView --> VisView
    MainView --> CompView
    MainView --> RankView
    MainView --> QuizView
    MainView --> HelpView

    Views --> FXML
    Views --> CSS

    MainCtrl --> VisCtrl
    MainCtrl --> CompCtrl
    MainCtrl --> RankCtrl
    MainCtrl --> QuizCtrl
    MainCtrl --> HelpCtrl

    AbstractAlgo --> BubbleSort
    AbstractAlgo --> QuickSort
    AbstractAlgo --> MergeSort
    AbstractAlgo --> HeapSort
    AbstractAlgo --> InsertSort
    AbstractAlgo --> SelectSort
    AbstractAlgo --> BucketSort
    AbstractAlgo --> CountSort
    
    AbstractTree --> TreeSort
    AbstractAlgo --> BinarySearch
    AbstractAlgo --> LinearSearch

    Controller_Layer --> AlgoState
    Algorithm_Layer --> AlgoState

    %% Click Events
    click MainApp "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/UserInterface/MainApplication.java"
    click MainCtrl "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/UserInterface/MainController.java"
    click VisCtrl "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/UserInterface/VisualizerController.java"
    click CompCtrl "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/UserInterface/CompareController.java"
    click RankCtrl "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/UserInterface/AlgorithmRankingController.java"
    click QuizCtrl "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/UserInterface/QuizController.java"
    click HelpCtrl "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/UserInterface/HelpController.java"
    click MainView "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/resources/UserInterface/main-view.fxml"
    click VisView "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/resources/UserInterface/visualizer-view.fxml"
    click CompView "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/resources/UserInterface/compare-view.fxml"
    click RankView "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/resources/UserInterface/algorithmranking-view.fxml"
    click QuizView "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/resources/UserInterface/quiz-view.fxml"
    click HelpView "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/resources/UserInterface/help-view.fxml"
    click AbstractAlgo "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/AbstractAlgorithm.java"
    click AbstractTree "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/AbstractAlgorithmTree.java"
    click BubbleSort "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/BubbleSort.java"
    click QuickSort "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/QuickSort.java"
    click MergeSort "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/MergeSort.java"
    click HeapSort "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/HeapSort.java"
    click InsertSort "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/InsertionSort.java"
    click SelectSort "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/SelectionSort.java"
    click TreeSort "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/TreeSort.java"
    click BucketSort "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/BucketSort.java"
    click CountSort "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/CountingSort.java"
    click BinarySearch "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/BinarySearch.java"
    click LinearSearch "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/LinearSearch.java"
    click AlgoState "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/java/Algorithms/AlgoState.java"
    click CSS "https://github.com/EdrisaJobe/sorting-visualizer/blob/main/src/main/resources/UserInterface/styles.css"

    %% Styling
    classDef entry fill:#ff9900,stroke:#333,stroke-width:2px
    classDef view fill:#bb99ff,stroke:#333
    classDef resource fill:#ffcc99,stroke:#333
    classDef controller fill:#99ccff,stroke:#333
    classDef base fill:#99ff99,stroke:#333
    classDef algo fill:#ffff99,stroke:#333
    classDef state fill:#ff9999,stroke:#333

    %% Legend
    subgraph Legend
        Entry["Entry Point"]:::entry
        View["View Component"]:::view
        Resource["Resource"]:::resource
        Controller["Controller"]:::controller
        Base["Base Class"]:::base
        Algorithm["Algorithm"]:::algo
        State["State Management"]:::state
    end
```
