# luna-caty/sorting-algorithms architecture

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

- Interactive diagram: https://gitdiagram.com/luna-caty/sorting-algorithms
- Repository: https://github.com/luna-caty/sorting-algorithms

## Overview

##### Project type and purpose
- This is a small, monolithic C command-line benchmarking tool whose sole purpose is to implement six sorting algorithms, measure their execution time on arrays of various sizes, and emit comparative results (sorting.csv and charts).

##### File structure
- README.md                ← project description and charts
- main.C                   ← single source file housing:
- array generator (for sizes 50, 100, 200, …)
- six sorting functions (Bubble, Optimized Bubble, Gnome, Radix, Quick, Heap)
- timing harness (using a high-resolution clock)
- CSV logger (writes size, algorithm name, duration)
- main.exe                 ← compiled executable (build artifact)
- sorting.csv              ← output data file consumed by charts

##### README for additional insights
- Confirms the six algorithms and the test sizes
- Shows static chart images (created after CSV is generated)

##### Detailed elements
- Blue for computation modules (sorting functions)
- Green for utility modules (Timer, CSV Writer)
- Gray for data artifacts (sorting.csv, charts)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build Process
    subgraph "Build Process"
        Compiler["C Compiler (gcc/clang)"]:::build
        mainC["main.C"]:::code
        mainExe["main.exe"]:::artifact
        Compiler -->|"compiles"| mainC
        mainC -->|"produces"| mainExe
    end

    %% Runtime Process
    subgraph "Runtime (main.exe execution)"
        orchestrator["main() Orchestrator"]:::runtime
        gen["Input Generator"]:::computation
        subgraph "Sorting Algorithms" 
            bubble["Bubble Sort"]:::computation
            optBubble["Optimized Bubble Sort"]:::computation
            gnome["Gnome Sort"]:::computation
            radix["Radix Sort"]:::computation
            quick["Quick Sort"]:::computation
            heap["Heap Sort"]:::computation
        end
        timer["Timer/Profiler"]:::utility
        csv["CSV Writer"]:::utility
        dataCSV["sorting.csv"]:::data
    end

    %% Data Flow
    mainExe -->|"runs"| orchestrator
    orchestrator -->|"generate size & select algorithm"| gen
    gen -->|"unsorted array"| bubble
    gen -->|"unsorted array"| optBubble
    gen -->|"unsorted array"| gnome
    gen -->|"unsorted array"| radix
    gen -->|"unsorted array"| quick
    gen -->|"unsorted array"| heap
    bubble -->|"sorted array"| timer
    optBubble -->|"sorted array"| timer
    gnome -->|"sorted array"| timer
    radix -->|"sorted array"| timer
    quick -->|"sorted array"| timer
    heap -->|"sorted array"| timer
    timer -->|"duration record"| csv
    csv -->|"write CSV row"| dataCSV
    dataCSV -->|"used by"| charts["Post-Processing Charts"]:::data

    %% Click Events
    click orchestrator "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click gen "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click bubble "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click optBubble "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click gnome "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click radix "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click quick "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click heap "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click timer "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click csv "https://github.com/luna-caty/sorting-algorithms/blob/main/main.C"
    click mainExe "https://github.com/luna-caty/sorting-algorithms/blob/main/main.exe"
    click dataCSV "https://github.com/luna-caty/sorting-algorithms/blob/main/sorting.csv"
    click charts "https://github.com/luna-caty/sorting-algorithms/blob/main/README.md"

    %% Styles
    classDef build fill:#f9d776,stroke:#333,stroke-width:1px
    classDef code fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef artifact fill:#f9d776,stroke:#333,stroke-width:1px
    classDef runtime fill:#ffffff,stroke:#333,stroke-width:1px
    classDef computation fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef utility fill:#d4edda,stroke:#333,stroke-width:1px
    classDef data fill:#e2e3e5,stroke:#333,stroke-width:1px
```
