# niicooam12/ejercicios_caballoreinahanoi architecture

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

- Interactive diagram: https://gitdiagram.com/niicooam12/ejercicios_caballoreinahanoi
- Repository: https://github.com/niicooam12/ejercicios_caballoreinahanoi

## Overview

##### Project Type and Purpose
- This is a Python-based application designed as an exercise involving three distinct puzzles or algorithms: “Caballo” (likely a knight’s movement or tour puzzle), “Reina” (the N-Queens problem), and “Hanoi” (the Tower of Hanoi puzzle).
- The project’s purpose is to implement and launch these puzzle modules, possibly with a backend persistence layer (as indicated by the database files juegos.db and movimientos.db) for storing game information or moves.

##### Main Components
a. Main Controller:
- main.py: Acts as the central entry point of the application. It may orchestrate which puzzle module to launch or integrate with the database.
- models.py: Manages data models and likely contains logic for interacting with the databases.
b. Puzzle Modules:
- Caballo module: Contains logic in MovsCaballo.py and is launched via lanzador.py. This module handles the knight-related puzzle logic.
- Reina module: Contains the NReinas.py file for addressing N-Queens puzzles and its own lanzador.py.
- Hanoi module: Contains TorreHanoi.py for the Tower of Hanoi puzzle and a corresponding lanzador.py.
c. Data Storage:
- Juegos.db and movimientos.db: Database files used to persist game configuration/results or move sequences.
d. Auxiliary Components:
- Each module’s __init__.py indicates they are set up as proper Python packages.
- The .gitignore manages files to exclude (such as __pycache__ directories) to keep the repository clean.

##### Relationships and Interactions
- main.py works as the starting point. It likely loads the necessary components (puzzle modules and data models) to initiate the puzzles.
- Each puzzle module (Caballo, Reina, Hanoi) is self-contained with its launcher, which simplifies executing puzzle-specific logic.
- models.py interacts with the databases to record or retrieve game data, linking the user interactions with persistent storage.
- The database files serve as shared resources that might be accessed by multiple modules depending on their requirements.

##### Architectural Patterns and Design Principles
- The modular design of separating puzzles into their own directories follows a separation of concerns, easing maintenance and development.
- Use of a centralized main driver and data models encourages an MVC-like approach even if not fully formalized.
- The presence of configuration files (e.g., .gitignore) and structured package directories indicates a well-organized project structure.

- Within each module, show that the ‘lanzador.py’ acts as the entry point to initiate that module’s functionality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Core
    subgraph "Application Core"
        A["main.py"]:::core
        B["models.py"]:::core
    end

    %% Caballo Module
    subgraph "Caballo Module"
        C1["Caballo: lanzador.py"]:::module
        C2["MovsCaballo.py"]:::module
    end

    %% Reina Module
    subgraph "Reina Module"
        D1["Reina: lanzador.py"]:::module
        D2["NReinas.py"]:::module
    end

    %% Hanoi Module
    subgraph "Hanoi Module"
        E1["Hanoi: lanzador.py"]:::module
        E2["TorreHanoi.py"]:::module
    end

    %% Data Storage
    subgraph "Data Storage"
        F1["juegos.db"]:::db
        F2["movimientos.db"]:::db
    end

    %% Relationships
    A -->|"loads"| B
    A -->|"invoke"| C1
    A -->|"invoke"| D1
    A -->|"invoke"| E1

    C1 -->|"executes"| C2
    D1 -->|"executes"| D2
    E1 -->|"executes"| E2

    B -->|"accesses"| F1
    B -->|"accesses"| F2

    %% Click Events
    click A "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/main.py"
    click B "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/models.py"
    click C1 "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/Caballo/lanzador.py"
    click C2 "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/Caballo/MovsCaballo.py"
    click D1 "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/Reina/lanzador.py"
    click D2 "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/Reina/NReinas.py"
    click E1 "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/Hanoi/lanzador.py"
    click E2 "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/Hanoi/TorreHanoi.py"
    click F1 "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/juegos.db"
    click F2 "https://github.com/niicooam12/ejercicios_caballoreinahanoi/blob/main/movimientos.db"

    %% Styles
    classDef core fill:#FFD700,stroke:#333,stroke-width:2px,color:#000;
    classDef module fill:#8FBC8F,stroke:#333,stroke-width:2px,color:#000;
    classDef db fill:#ADD8E6,stroke:#333,stroke-width:2px,color:#000;
```
