# joseecodm/hanoi-s-towers architecture

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

- Interactive diagram: https://gitdiagram.com/joseecodm/hanoi-s-towers
- Repository: https://github.com/joseecodm/hanoi-s-towers

## Overview

##### And List the Main Components
- User Interface (GUI) Component:
- Represented by src/gui.py, which handles interactive operations using Tkinter.
- Uses assets (located in src/assets and src/assets/images) for graphical elements.
- Game Logic Component:
- Represented by src/stack_hanoi.py, which encapsulates the puzzle rules (moving disks, move validations, etc.).
- Application Control and Configuration:
- Main program flow exists in src/main.py.
- Additional supporting components like src/menu.py (for menu interactions) and src/settings.py.
- Build and Packaging Process:
- PyInstaller (as indicated by main.spec, the build outputs in build and the final executable in dist/main.exe) is used to package the Python code into an executable.

##### Relationships and Interactions
- The User interacts with the GUI.
- The interface allows you to drag and drop disks between towers.
- The GUI Component calls functions from the Game Logic module.
- The Main Application ties together these modules.
- “main.py” connected to both the GUI and Game Logic components, representing the orchestrator that initializes everything.
- The assets folder is used by the GUI to load images.
- A dependency line from “Assets” (src/assets/images) to the “GUI” component.
- The Build/Packaging Workflow:

##### Incorporate Architectural Patterns and Design Principles
- Separation of concerns:
- Clearly distinguish between user interface code (GUI), business logic (game/puzzle operations), and application orchestration/control (main, menu, settings).
- Modularity:
- Each Python file represents a module; show these modules as distinct blocks that interact to form the complete system.
- Packaging step as part of the lifecycle, ensuring clarity between development (source code and modules) and production (standalone executable).

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Entity
    User["User"]:::external

    %% Application Modules
    subgraph "Application Modules"
        GUI["GUI (Tkinter)"]:::module
        GL["Tower of Hanoi Rules"]:::module
        MC["Main Controller"]:::module
        Menu["Menu"]:::module
        Settings["Settings"]:::module
        Assets["Assets (Images)"]:::resource
    end

    %% Build and Packaging Process
    subgraph "Build & Packaging"
        SRC["Source Code (src)"]:::source
        BS["Build Spec"]:::build
        BF["Build Folder"]:::build
        DE["Dist (Executable)"]:::build
    end

    %% Interactions between external user and application modules
    User -->|"activates"| GUI
    GUI -->|"calls_logic"| GL
    MC -->|"initializes"| GUI
    MC -->|"initializes"| GL
    MC -->|"manages"| Menu
    MC -->|"manages"| Settings
    Assets -->|"supplies"| GUI

    %% Packaging flow
    SRC -->|"packaged_by"| BS
    BS -->|"compiled_to"| BF
    BF -->|"outputs"| DE

    %% Click Events
    click GUI "https://github.com/joseecodm/hanoi-s-towers/blob/main/src/gui.py"
    click Assets "https://github.com/joseecodm/hanoi-s-towers/tree/main/src/assets/images"
    click GL "https://github.com/joseecodm/hanoi-s-towers/blob/main/src/stack_hanoi.py"
    click MC "https://github.com/joseecodm/hanoi-s-towers/blob/main/src/main.py"
    click Menu "https://github.com/joseecodm/hanoi-s-towers/blob/main/src/menu.py"
    click Settings "https://github.com/joseecodm/hanoi-s-towers/blob/main/src/settings.py"
    click BS "https://github.com/joseecodm/hanoi-s-towers/blob/main/main.spec"
    click BF "https://github.com/joseecodm/hanoi-s-towers/tree/main/build/"
    click DE "https://github.com/joseecodm/hanoi-s-towers/blob/main/dist/main.exe"

    %% Styles
    classDef external fill:#a3d5f7,stroke:#333,stroke-width:2px;
    classDef module fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef resource fill:#cfd8dc,stroke:#333,stroke-width:2px;
    classDef source fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef build fill:#f5b7b1,stroke:#333,stroke-width:2px;
```
