# gautam23145032/sortingvisualizer architecture

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

- Interactive diagram: https://gitdiagram.com/gautam23145032/sortingvisualizer
- Repository: https://github.com/gautam23145032/sortingvisualizer

## Overview

##### File structure
- Top-level files only:
- index.html – the shell/UI container
- style.css – all layout and styling (Flexbox, responsive tweaks)
- script.js – the entire sorting logic, event handlers, and animation routines
- No backend, no build tools, no dependencies.

##### README for additional insights
- Confirms it’s purely HTML/CSS/JS.
- Features include play/pause controls, algorithm benchmarking, adjustable array size/speed, real-time timing metrics.
- Technologies: HTML5, CSS3, JavaScript (ES6+).

a. Main components to represent:
- Browser (Client Runtime)
- UI Layer (HTML + CSS)
- Sorting Engine (JavaScript module in script.js)
- Control Panel & User Input (buttons, sliders)
- Rendering Engine (DOM update & animation loop)
- Metrics Collector (timing & comparisons counter)
b. Relationships & interactions:
1. User interacts with Control Panel → events fired to Sorting Engine
2. Sorting Engine manipulates the in-memory array model
3. Sorting Engine emits update events → Rendering Engine updates the DOM bars
4. Metrics Collector hooks into Sorting Engine to compute time/operations → updates UI
c. Architectural patterns / design principles:
- MVC-like separation:
- Model: the in-memory array & metrics state
- View: DOM elements styled by CSS
- Controller: event handlers in script.js that orchestrate sorting calls and animations
- Single responsibility: each function in script.js handles one sorting algorithm or one UI update
- Event-driven: using requestAnimationFrame or setTimeout for smooth step-by-step animations
d. Key technologies/frameworks:
- HTML5 (semantic structure for chart & controls)
- CSS3 Flexbox (responsive layout)

## Diagram (Mermaid)

```mermaid
flowchart TB
    Browser["Browser (Client Runtime)"]:::external

    subgraph "Client Side"
        subgraph "UI Layer"
            UI["UI Layer"]:::ui
            CP["Control Panel & User Input"]:::ui
            UIDisplay["UI Display (Time & Comparisons)"]:::ui
            CSS["Styling & Layout"]:::ui
        end
        subgraph "Logic Layer"
            SE["Sorting Engine"]:::logic
            MC["Metrics Collector"]:::logic
        end
        subgraph "Rendering & Animation"
            RE["Rendering Engine"]:::render
        end
    end

    RO["Project Overview & Usage Instructions"]:::external

    Browser --> UI
    UI --> CSS
    CP -->|"onClick"| SE
    SE -->|"stepComplete"| RE
    SE -->|"hooks"| MC
    RE -->|"renderFrame"| UI
    MC -->|"updateMetrics"| UIDisplay

    click UI "https://github.com/gautam23145032/sortingvisualizer/blob/main/index.html"
    click CP "https://github.com/gautam23145032/sortingvisualizer/blob/main/script.js"
    click SE "https://github.com/gautam23145032/sortingvisualizer/blob/main/script.js"
    click RE "https://github.com/gautam23145032/sortingvisualizer/blob/main/script.js"
    click MC "https://github.com/gautam23145032/sortingvisualizer/blob/main/script.js"
    click CSS "https://github.com/gautam23145032/sortingvisualizer/blob/main/style.css"
    click RO "https://github.com/gautam23145032/sortingvisualizer/blob/main/README.md"

    classDef ui fill:#E0F7FA,stroke:#006064,stroke-width:2px,shape:round;
    classDef logic fill:#E8F5E9,stroke:#1B5E20,stroke-width:2px;
    classDef render fill:#FFF3E0,stroke:#E65100,stroke-width:2px;
    classDef external fill:#ECEFF1,stroke:#546E7A,stroke-width:2px,stroke-dasharray: 5 5;
```
