# anunayreddy22/sorting-visualizer architecture

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

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

## Overview

1. This repository is a single-purpose Java desktop application: a sorting visualizer. The architecture is centered on a GUI that animates sorting algorithms step by step for educational use.

2. Entry and orchestration appear to live in `Visualizer/SortingVisualizer.java`. This is likely the application bootstrap and the coordination point that wires the frame, the array data, the selected algorithm, and the animation lifecycle together.

3. The UI boundary is `Visualizer/VisualizerFrame.java`. This class is the presentation layer: it presents the controls the README mentions, such as algorithm selection and speed adjustment, and renders the array state during sorting.

4. The algorithm layer is isolated under `Visualizer/Sorts/`. Each file represents one sorting strategy: `BubbleSort`, `SelectionSort`, `InsertionSort`, `MergeSort`, `RadixSort`, `ShellSort`, `GnomeSort`, and `QuandrixSort`. This separation makes the system easy to diagram as “UI” → “algorithm implementation.”

5. The key data flow is: the UI or main controller creates an input array, passes it to the chosen sort implementation, and the sort updates the array state while the frame repaints the visual bars/markers. The animation is therefore driven by algorithm progress, not by a separate backend service.

6. Real-time visualization is the core coupling between the UI and sorting logic. The sort classes are likely instrumented to expose intermediate swaps or comparisons so the frame can redraw after each meaningful step instead of only showing the final result.

7. Speed control is a distinct interaction boundary in the UI. It likely influences timing between animation frames or pauses inside the sorting loop, which means it affects execution pacing rather than the sorting outcome itself.

8. The repository does not show a network layer, persistence layer, or external service integration. This is a self-contained local GUI program, so the architectural diagram should stay focused on in-process components only.

9. There is a clear separation between reusable algorithm code and visual presentation code. That makes the sort classes portable, while the frame and controller are specific to the visualization experience.

10. For a diagram, the main boxes are: application bootstrap, visual frame/controls, array state/animation engine, and the individual sorting algorithm modules. The arrows should show user input flowing into the frame, algorithm choice flowing into the controller, and array mutations flowing back to the renderer during execution.

Main entry points: [`Sorting-Visualizer/Visualizer/SortingVisualizer.java`](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/SortingVisualizer.java) (Sorting app), [`Sorting-Visualizer/Visualizer/VisualizerFrame.java`](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/VisualizerFrame.java) (Visualizer frame), [`Sorting-Visualizer/Visualizer/Sorts/BubbleSort.java`](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/BubbleSort.java) (Bubble sort), [`Sorting-Visualizer/Visualizer/Sorts/SelectionSort.java`](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/SelectionSort.java) (Selection sort)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Visualizer"]
  node_visualizer["Sorting app<br/>bootstrap/controller"]
  node_frame["Visualizer frame<br/>ui/frame"]
  node_array[("Array state<br/>data/model")]
  node_render(("Render loop<br/>animation/repaint"))
  node_speed["Speed control<br/>ui/input"]
  node_select["Algo picker<br/>ui/input"]
end

subgraph group_sorts["Sorting algorithms"]
  node_bubble["Bubble sort<br/>sort/algorithm<br/>[BubbleSort.java]"]
  node_selection["Selection sort<br/>sort/algorithm<br/>[SelectionSort.java]"]
  node_insertion["Insertion sort<br/>sort/algorithm<br/>[InsertionSort.java]"]
  node_merge["Merge sort<br/>sort/algorithm<br/>[MergeSort.java]"]
  node_radix["Radix sort<br/>sort/algorithm<br/>[RadixSort.java]"]
  node_shell["Shell sort<br/>sort/algorithm<br/>[ShellSort.java]"]
  node_gnome["Gnome sort<br/>sort/algorithm<br/>[GnomeSort.java]"]
  node_quandrix["Quandrix sort<br/>sort/algorithm<br/>[QuandrixSort.java]"]
end

node_visualizer -->|"creates"| node_frame
node_visualizer -->|"initializes"| node_array
node_visualizer -->|"wires"| node_select
node_visualizer -->|"wires"| node_speed
node_visualizer -->|"drives"| node_render
node_frame -->|"hosts"| node_select
node_frame -->|"hosts"| node_speed
node_frame -->|"paints"| node_render
node_array -->|"feeds"| node_render
node_select -->|"routes to"| node_bubble
node_select -->|"routes to"| node_selection
node_select -->|"routes to"| node_insertion
node_select -->|"routes to"| node_merge
node_select -->|"routes to"| node_radix
node_select -->|"routes to"| node_shell
node_select -->|"routes to"| node_gnome
node_select -->|"routes to"| node_quandrix
node_bubble -->|"mutates"| node_array
node_selection -->|"mutates"| node_array
node_insertion -->|"mutates"| node_array
node_merge -->|"mutates"| node_array
node_radix -->|"mutates"| node_array
node_shell -->|"mutates"| node_array
node_gnome -->|"mutates"| node_array
node_quandrix -->|"mutates"| node_array
node_speed -->|"paces"| node_render

click node_visualizer "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/SortingVisualizer.java"
click node_frame "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/VisualizerFrame.java"
click node_bubble "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/BubbleSort.java"
click node_selection "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/SelectionSort.java"
click node_insertion "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/InsertionSort.java"
click node_merge "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/MergeSort.java"
click node_radix "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/RadixSort.java"
click node_shell "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/ShellSort.java"
click node_gnome "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/GnomeSort.java"
click node_quandrix "https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/QuandrixSort.java"

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_visualizer,node_frame,node_array,node_render,node_speed,node_select toneBlue
class node_bubble,node_selection,node_insertion,node_merge,node_radix,node_shell,node_gnome,node_quandrix toneAmber
```

## Components

### Visualizer

Bootstrap, frame, and runtime coordination

- [Sorting app](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/SortingVisualizer.java): bootstrap/controller · Starts the application and coordinates sorting runs · `Sorting-Visualizer/Visualizer/SortingVisualizer.java`
- [Visualizer frame](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/VisualizerFrame.java): ui/frame · Main window for controls and drawing · `Sorting-Visualizer/Visualizer/VisualizerFrame.java`
- **Array state**: data/model · In-memory values being sorted and rendered
- **Render loop**: animation/repaint · Redraws the bars and step-by-step progress
- **Speed control**: ui/input · Adjusts animation pacing
- **Algo picker**: ui/input · Chooses which sorting strategy to run

### Sorting algorithms

Algorithm implementations used by the visualizer

- [Bubble sort](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/BubbleSort.java): sort/algorithm · Bubble sort implementation · `Sorting-Visualizer/Visualizer/Sorts/BubbleSort.java`
- [Selection sort](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/SelectionSort.java): sort/algorithm · Selection sort implementation · `Sorting-Visualizer/Visualizer/Sorts/SelectionSort.java`
- [Insertion sort](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/InsertionSort.java): sort/algorithm · Insertion sort implementation · `Sorting-Visualizer/Visualizer/Sorts/InsertionSort.java`
- [Merge sort](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/MergeSort.java): sort/algorithm · Merge sort implementation · `Sorting-Visualizer/Visualizer/Sorts/MergeSort.java`
- [Radix sort](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/RadixSort.java): sort/algorithm · Radix sort implementation · `Sorting-Visualizer/Visualizer/Sorts/RadixSort.java`
- [Shell sort](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/ShellSort.java): sort/algorithm · Shell sort implementation · `Sorting-Visualizer/Visualizer/Sorts/ShellSort.java`
- [Gnome sort](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/GnomeSort.java): sort/algorithm · Gnome sort implementation · `Sorting-Visualizer/Visualizer/Sorts/GnomeSort.java`
- [Quandrix sort](https://github.com/anunayreddy22/sorting-visualizer/blob/main/Sorting-Visualizer/Visualizer/Sorts/QuandrixSort.java): sort/algorithm · Quandrix sort implementation · `Sorting-Visualizer/Visualizer/Sorts/QuandrixSort.java`

## Connections

- Sorting app → Visualizer frame: creates · Bootstraps the UI window
- Sorting app → Array state: initializes · Builds the array to be visualized
- Sorting app → Algo picker: wires · Connects algorithm choice into runtime
- Sorting app → Speed control: wires · Connects pacing control into runtime
- Sorting app → Render loop: drives · Starts and coordinates animation updates
- Visualizer frame → Algo picker: hosts · Presents algorithm selection controls
- Visualizer frame → Speed control: hosts · Presents speed adjustment controls
- Visualizer frame → Render loop: paints · Draws the current array state
- Array state → Render loop: feeds · Current values are rendered as bars/markers
- Algo picker → Bubble sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Selection sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Insertion sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Merge sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Radix sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Shell sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Gnome sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Quandrix sort: routes to · Dispatches to the chosen sort implementation
- Bubble sort → Array state: mutates · Updates the shared array during sorting steps
- Selection sort → Array state: mutates · Updates the shared array during sorting steps
- Insertion sort → Array state: mutates · Updates the shared array during sorting steps
- Merge sort → Array state: mutates · Updates the shared array during sorting steps
- Radix sort → Array state: mutates · Updates the shared array during sorting steps
- Shell sort → Array state: mutates · Updates the shared array during sorting steps
- Gnome sort → Array state: mutates · Updates the shared array during sorting steps
- Quandrix sort → Array state: mutates · Updates the shared array during sorting steps
- Speed control → Render loop: paces · Controls delay between visual steps
