# fraankz/haltingproblem architecture

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

- Interactive diagram: https://gitdiagram.com/fraankz/haltingproblem
- Repository: https://github.com/fraankz/haltingproblem

## Overview

- Main Entry Point: Include the Main class that serves as the application’s starting point where either the GUI (MainUI) is initialized or console-based tests are executed.
- User Interface: Represent the UI component (MainUI) built with Swing. Indicate that it provides interactive controls (buttons) for running the different simulated programs.
– The Program interface (the basic contract for all example programs).
– Implementations like CountDown (which terminates) and CountUp (which loops indefinitely).
- Checker Component: Create a node for the HaltChecker. It “simulates” the decision on whether a given program stops or loops.
- Tests: Optionally, include a brief note on the test layer (located under src/test), showing that it mirrors the structure of the main packages.

##### Relationships and Data Flow
- That within the execution flow, the HaltChecker is invoked to predict if a program stops.
- Optionally, show that the Main entry point can also run tests or console commands interacting with similar components.

##### Architectural Patterns and Design Decisions
- Layer Separation: Visually separate the UI layer from the business logic (checker and logic) and the program simulation layer. This helps clarify the separation of concerns.
- “Simulation Logic”: Stress that HaltChecker and Reverser, while individually simple, combine to create a paradox that is the heart of the project.
- Technologies Highlight: Annotate components with notes like “Swing” for the UI, “Maven (pom.xml)” for build management, and “JUnit” (implied by the test directory structure) for tests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point
    Main["Main"]:::entry
    click Main "https://github.com/fraankz/haltingproblem/blob/main/src/main/java/haltingproblem/Main.java"

    %% UI Layer
    MainUI["MainUI (Swing)"]:::ui
    click MainUI "https://github.com/fraankz/haltingproblem/blob/main/src/main/java/haltingproblem/ui/MainUI.java"

    %% Programs Package Layer
    subgraph "Programs Layer"
        Program["Program Interface"]:::programs
        click Program "https://github.com/fraankz/haltingproblem/blob/main/src/main/java/haltingproblem/programs/Program.java"
        
        CountDown["CountDown (Terminates)"]:::programs
        click CountDown "https://github.com/fraankz/haltingproblem/blob/main/src/main/java/haltingproblem/programs/CountDown.java"
        
        CountUp["CountUp (Runs indefinitely)"]:::programs
        click CountUp "https://github.com/fraankz/haltingproblem/blob/main/src/main/java/haltingproblem/programs/CountUp.java"
    end

    %% Business Logic Layer
    HaltChecker["HaltChecker"]:::logic
    click HaltChecker "https://github.com/fraankz/haltingproblem/blob/main/src/main/java/haltingproblem/checker/HaltChecker.java"
    
    Reverser["Reverser (Inverts Prediction)"]:::logic
    click Reverser "https://github.com/fraankz/haltingproblem/blob/main/src/main/java/haltingproblem/logic/Reverser.java"

    %% Tests Layer
    Tests["Tests"]:::test
    click Tests "https://github.com/fraankz/haltingproblem/tree/main/src/test/java/haltingproblem"

    %% Connections
    Main -->|"launches"| MainUI
    Main -->|"executes"| Tests

    MainUI -->|"triggers"| CountDown
    MainUI -->|"triggers"| CountUp

    CountDown -->|"checkedBy"| HaltChecker
    CountUp -->|"checkedBy"| HaltChecker

    HaltChecker -->|"passesResultTo"| Reverser
    Reverser -->|"callsBack"| HaltChecker

    %% Styles
    classDef entry fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef ui fill:#9FE2BF,stroke:#000,stroke-width:2px;
    classDef programs fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef logic fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef test fill:#D8BFD8,stroke:#000,stroke-width:2px;
```
