# 11fenil11/gui-based-algorithm-calculator architecture

> Architecture diagram of the GitHub repository 11fenil11/gui-based-algorithm-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/11fenil11/gui-based-algorithm-calculator
- Repository: https://github.com/11fenil11/gui-based-algorithm-calculator

## Overview

1. This repository is a small Java desktop application: a Swing-based “algorithm calculator” for demonstrating and running six sorting algorithms on integer arrays.

2. The architecture is intentionally simple and mostly single-process. There is no server, database, or network layer. The whole app runs locally in the JVM and uses Swing/AWT for the UI.

3. The two main source classes are:
   - `Frame.java`: the main navigation/UI frame.
   - `Sortingss.java`: the sorting-oriented second frame and/or the sorting logic behind it.
   The package name is `algo_Calc`, which also appears under `bin/` as the compiled output.

4. UI flow is a two-screen desktop workflow:
   - Main frame: presents six buttons, one per sorting algorithm.
   - Secondary frame: accepts input, shows sorted output, and provides an “Open Code” action.
   Clicking an algorithm button hides the current frame and shows the next one, carrying a key/selection value that identifies the chosen algorithm.

5. The primary data flow is user input → parsing → sorting → formatted output:
   - The user enters an integer array in a text area.
   - The app interprets that input according to the selected algorithm screen.
   - The chosen algorithm is executed.
   - The sorted array is rendered back into an output text area.

6. The repository supports these six algorithms:
   - Bubble sort
   - Insertion sort
   - Merge sort
   - Quick sort
   - Heap sort
   - Selection sort
   Each algorithm is exposed as a separate UI choice, but they appear to share the same interaction pattern and output surface.

7. Exception handling is part of the input boundary. Since the app expects integer arrays from free-form text input, input validation/parsing errors are an important edge case in the UI-to-algorithm transition.

8. The “Open Code” feature is a separate desktop boundary from the sorting engine. It uses `ProcessBuilder` to launch the associated `.txt` file for the selected algorithm in an external editor, likely Notepad on Windows. That means the app depends on the host operating system’s file-opening behavior.

9. The algorithm source references are stored as plain text files at the repo root:
   - `bubble.txt`
   - `insertion.txt`
   - `merge.txt`
   - `quicksort.txt`
   - `maxheap.txt`
   - `selection.txt`
   These are not runtime data files for computation; they are documentation/code-view assets used by the Open Code action.

10. The UI technology stack is standard Java Swing plus AWT event handling:
    - `JFrame`, `JButton`, `JTextArea`, `JLabel`, `JTextField`
    - `ActionListener` / `ActionEvent`
    - `EventQueue`
    This strongly suggests a traditional event-driven desktop application rather than a layered web or service architecture.

11. The repository structure reflects an Eclipse-managed Java project:
    - `.project` and `.settings` indicate Eclipse metadata.
    - `bin/` holds compiled classes.
    - `src/` holds the editable source.
    - `Images/` contains screenshots used in the README, not runtime logic.

12. The most important architectural boundary is between “algorithm selection/UI state” and “sorting execution.” The selected button determines which algorithm path the second frame uses, but the interaction remains a single user-driven loop inside the desktop app.

13. For an architecture diagram, the key components are:
    - User
    - Main menu frame
    - Sorting/input frame
    - Sorting logic for six algorithms
    - External text-file/code viewer launched by `ProcessBuilder`
    - Local `.txt` algorithm reference files
    The arrows should show user-driven navigation and one-way file launching, not persistent data exchange.

Main entry points: [`src/algo_Calc/Sortingss.java`](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java) (Sort engine), [`src/algo_Calc/Frame.java`](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Frame.java) (Main frame), [`bubble.txt`](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/bubble.txt) (Text refs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_source["Source code"]
  node_frame["Main frame<br/>Swing frame<br/>[Frame.java]"]
  node_sortingss["Sort screen<br/>Swing frame<br/>[Sortingss.java]"]
  node_selection_state{{"Selection key<br/>ui state<br/>[Frame.java]"}}
  node_input_parse["Input parser<br/>boundary logic<br/>[Sortingss.java]"]
  node_sort_engine{{"Sort engine<br/>algorithm dispatch<br/>[Sortingss.java]"}}
  node_bubble(("Bubble sort<br/>algorithm<br/>[Sortingss.java]"))
  node_insertion(("Insertion sort<br/>algorithm<br/>[Sortingss.java]"))
  node_merge(("Merge sort<br/>algorithm<br/>[Sortingss.java]"))
  node_quick(("Quick sort<br/>algorithm<br/>[Sortingss.java]"))
  node_heap(("Heap sort<br/>algorithm<br/>[Sortingss.java]"))
  node_selection(("Selection sort<br/>algorithm<br/>[Sortingss.java]"))
  node_output_view["Output area<br/>ui output<br/>[Sortingss.java]"]
  node_code_opener{{"Open Code<br/>ProcessBuilder action<br/>[Sortingss.java]"}}
end

subgraph group_assets["Algorithm refs"]
  node_algo_texts["Text refs<br/>plain text assets<br/>[bubble.txt]"]
end

node_user(("User"))
node_editor["External editor<br/>host OS process"]

node_user -->|"select algorithm"| node_frame
node_frame -->|"set choice"| node_selection_state
node_selection_state -->|"open screen"| node_sortingss
node_user -->|"enter input"| node_sortingss
node_sortingss -->|"parse text"| node_input_parse
node_input_parse -->|"validated array"| node_sort_engine
node_sort_engine -->|"dispatch"| node_bubble
node_sort_engine -->|"dispatch"| node_insertion
node_sort_engine -->|"dispatch"| node_merge
node_sort_engine -->|"dispatch"| node_quick
node_sort_engine -->|"dispatch"| node_heap
node_sort_engine -->|"dispatch"| node_selection
node_sort_engine -->|"render"| node_output_view
node_user -->|"open code"| node_code_opener
node_code_opener -->|"choose file"| node_algo_texts
node_code_opener -->|"spawn process"| node_editor

click node_frame "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Frame.java"
click node_sortingss "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_selection_state "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Frame.java"
click node_input_parse "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_sort_engine "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_bubble "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_insertion "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_merge "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_quick "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_heap "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_selection "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_output_view "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_code_opener "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java"
click node_algo_texts "https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/bubble.txt"

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_frame,node_sortingss,node_selection_state,node_input_parse,node_sort_engine,node_bubble,node_insertion,node_merge,node_quick,node_heap,node_selection,node_output_view,node_code_opener toneBlue
class node_algo_texts toneAmber
class node_user,node_editor toneNeutral
```

## Components

### Source code

Editable Java Swing application code.

- [Main frame](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Frame.java): Swing frame · Main navigation window with six algorithm buttons. · `src/algo_Calc/Frame.java`
- [Sort screen](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): Swing frame · Secondary screen that accepts input, runs the chosen sort, and shows results. · `src/algo_Calc/Sortingss.java`
- [Selection key](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Frame.java): ui state · Carries the chosen algorithm from the menu frame into the sorting screen. · `src/algo_Calc/Frame.java`
- [Input parser](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): boundary logic · Converts free-form text into an integer array and handles parse errors. · `src/algo_Calc/Sortingss.java`
- [Sort engine](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): algorithm dispatch · Routes the selected input through the chosen sorting routine. · `src/algo_Calc/Sortingss.java`
- [Bubble sort](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): algorithm · Supported sorting option. · `src/algo_Calc/Sortingss.java`
- [Insertion sort](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): algorithm · Supported sorting option. · `src/algo_Calc/Sortingss.java`
- [Merge sort](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): algorithm · Supported sorting option. · `src/algo_Calc/Sortingss.java`
- [Quick sort](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): algorithm · Supported sorting option. · `src/algo_Calc/Sortingss.java`
- [Heap sort](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): algorithm · Supported sorting option. · `src/algo_Calc/Sortingss.java`
- [Selection sort](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): algorithm · Supported sorting option. · `src/algo_Calc/Sortingss.java`
- [Output area](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): ui output · Displays the sorted array back to the user. · `src/algo_Calc/Sortingss.java`
- [Open Code](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/src/algo_Calc/Sortingss.java): ProcessBuilder action · Launches the algorithm's reference file in the host editor. · `src/algo_Calc/Sortingss.java`

### Algorithm refs

Plain-text code/reference files opened from the app.

- [Text refs](https://github.com/11fenil11/gui-based-algorithm-calculator/blob/master/bubble.txt): plain text assets · Algorithm reference files opened by the app. · `bubble.txt`

### Other components

- **User**: desktop user · Chooses a sorting algorithm, enters integer arrays, and triggers output or code viewing.
- **External editor**: host OS process · System default text editor or Notepad-like application launched outside the JVM.

## Connections

- User → Main frame: select algorithm · User clicks one of six sorting buttons.
- Main frame → Selection key: set choice · Main menu stores the selected algorithm key.
- Selection key → Sort screen: open screen · Selection is passed into the sorting frame.
- User → Sort screen: enter input · User provides an integer array on the secondary screen.
- Sort screen → Input parser: parse text · Input text is interpreted as integers.
- Input parser → Sort engine: validated array · Parsed integers flow into the selected sort routine.
- Sort engine → Bubble sort: dispatch · Runs bubble sort when selected.
- Sort engine → Insertion sort: dispatch · Runs insertion sort when selected.
- Sort engine → Merge sort: dispatch · Runs merge sort when selected.
- Sort engine → Quick sort: dispatch · Runs quick sort when selected.
- Sort engine → Heap sort: dispatch · Runs heap sort when selected.
- Sort engine → Selection sort: dispatch · Runs selection sort when selected.
- Sort engine → Output area: render · Sorted values are formatted into the output text area.
- User → Open Code: open code · User requests the algorithm source/reference view.
- Open Code → Text refs: choose file · Launcher targets the matching text file for the selected algorithm.
- Open Code → External editor: spawn process · ProcessBuilder starts the external editor or file association.
