# otniel113/tugasbesaraka architecture

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

- Interactive diagram: https://gitdiagram.com/otniel113/tugasbesaraka
- Repository: https://github.com/otniel113/tugasbesaraka

## Overview

##### Project type and purpose
- This is a standalone, console-based algorithm comparison tool written in C/C++.
- Its purpose is to generate a random array of user-specified length, sort it using BubbleSort and MergeSort, measure execution times, and display the results.

##### File structure
- Top level:
- README.md, PPT.pptx, Laporan_1301180469_1301180392.pdf (documentation)
- Source Code/MergeBubbleSortV2 (Code::Blocks project)
- Source Code/MergeBubbleSortV2 contains:
- header.h – declarations of functions and includes
- source.cpp – implementations of sorting and helper functions
- main.cpp – driver orchestrating user I/O, array generation, timing, and calls into source.cpp
- bin/Debug – compiled executable
- obj/Debug – object files
- .cbp, .depend, .layout – project metadata for Code::Blocks

##### README for additional insights
- Describes program flow: input array length → random array creation → main menu with options to display array, run BubbleSort (O(n²)), run MergeSort (O(n log n)), reset array, or exit.
- Notes that runtime measurements are shown in milliseconds.
- No external services or persistent storage.

##### Main components
a. User (Console)
b. Main Module (main.cpp)
c. Utility Module (header.h + source.cpp)
– Random Array Generator
– BubbleSort function
– MergeSort function
– Timer/Performance Measurement
d. Output Renderer (console printing)

##### Relationships and interactions
- User → (inputs array length) → Main Module
- Main Module → (calls) → Random Array Generator → returns array
- Main Module → displays menu → User selects option
- If “Display Array”: Main Module → Output Renderer
- If “BubbleSort” or “MergeSort”: Main Module → Timer start → calls respective sort function in Utility Module → Timer stop → returns sorted array + duration → Main Module → Output Renderer
- If “Reset Array”: Main Module → Random Array Generator
- Exit option terminates the process

##### Architectural patterns and design principles
- Separation of concerns:
- I/O logic in main.cpp
- Algorithm implementations in source.cpp/header.h
- Build artifacts separated under bin/ and obj/
- Modular design enables adding more sorting algorithms or features without touching driver code heavily.

##### Relevant technologies
- Language: C++ (with C linkage where needed)
- Build system: Code::Blocks project (.cbp files), GNU GCC toolchain
- Standard library: <chrono> for timing, <vector> or raw arrays for data, <random> or srand/rand

## Diagram (Mermaid)

```mermaid
flowchart TB
    User["User"]:::user
    CLI["CLI Interface / Main Controller"]:::io
    Output["Console Output (Renderer)"]:::io

    subgraph "Algorithm Library"
        HEAD["Header Declarations"]:::core
        IMPL["Implementations"]:::core
        PRG["Random Array Generator"]:::util
        BS["BubbleSort Function"]:::core
        MS["MergeSort Function"]:::core
        TIM["Timer / Performance Measurement"]:::util
    end

    subgraph "Build Artifacts"
        EXE["Executable (.exe)"]:::artifact
        OBJ1["main.o"]:::artifact
        OBJ2["source.o"]:::artifact
        CBP["MergeBubbleSortV2.cbp"]:::artifact
        DEP["MergeBubbleSortV2.depend"]:::artifact
        LAY["MergeBubbleSortV2.layout"]:::artifact
    end

    User -->|"input array length"| CLI
    CLI -->|"generate array[n]"| PRG
    PRG -->|"[int[]]"| CLI
    CLI -->|"request BubbleSort"| BS
    CLI -->|"request MergeSort"| MS
    CLI -->|"start/stop timer"| TIM
    TIM -->|"[duration ms]"| CLI
    BS -->|"[sorted int[]]"| CLI
    MS -->|"[sorted int[]]"| CLI
    CLI -->|"display results"| Output
    CLI -->|"reset array"| PRG

    CLI -->|"build"| EXE
    EXE --> OBJ1
    EXE --> OBJ2
    EXE --> CBP
    EXE --> DEP
    EXE --> LAY

    click CLI "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/main.cpp"
    click Output "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/main.cpp"
    click HEAD "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/header.h"
    click IMPL "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/source.cpp"
    click PRG "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/source.cpp"
    click BS "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/source.cpp"
    click MS "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/source.cpp"
    click TIM "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/source.cpp"
    click EXE "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/bin/Debug/MergeBubbleSortV2.exe"
    click OBJ1 "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/obj/Debug/main.o"
    click OBJ2 "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/obj/Debug/source.o"
    click CBP "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/MergeBubbleSortV2.cbp"
    click DEP "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/MergeBubbleSortV2.depend"
    click LAY "https://github.com/otniel113/tugasbesaraka/blob/main/Source Code/MergeBubbleSortV2/MergeBubbleSortV2.layout"

    classDef user fill:#ddf,stroke:#333,stroke-width:1px
    classDef io fill:#cfc,stroke:#333,stroke-width:1px
    classDef core fill:#ccf,stroke:#333,stroke-width:1px
    classDef util fill:#fcf,stroke:#333,stroke-width:1px
    classDef artifact fill:#eee,stroke:#999,stroke-dasharray: 5 5
```
