# camargo-panqueva/proyecto-final architecture

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

- Interactive diagram: https://gitdiagram.com/camargo-panqueva/proyecto-final
- Repository: https://github.com/camargo-panqueva/proyecto-final

## Overview

##### Main Components of the System
- Game Logic/Controller Layer:
– Packages under “src/controller” host all the game control logic, including the main launcher, game states and state management, AI players, cell and wall management, and actions.
– Note the “dto” sub-package that encapsulates data transfer objects used for communication between different layers.

- Domain Model Layer:
– The “src/model” directory holds classes representing the core entities of the game such as GameModel, Board, Player (and AI settings), and wall/cell types.
– This layer defines the game’s state, rules, and essential entities.

- Presentation/View Layer:
– The “src/view” folder contains the UI elements, scene management (such as WelcomeScene, PlayingScene, SettingsScene, WinnerScene), game components (like Board, CellRenderer, WallRenderer), and window configuration.
– Input handling is managed in “src/view/input”, which processes keyboard and mouse events.

- Resources & Themes:
– The “src/resources” and “src/view/themes” directories define the aesthetic components like fonts and themes (DarkTheme, LightTheme) for the overall look of the game.

- Utility & Testing Layers:
– Utility functions found in “src/util” serve various helper roles (logging, concurrent loops, timeouts).
– The “test” directory provides unit and integration tests to verify functionality (e.g., saving and loading matches).

##### Relationships and Interactions
- The Controller then manipulates the Domain Model (e.g., game board, players, walls), managing game state transitions, AI decision-making, and player actions.
- The updated Model state is passed back to the View, where different Scenes (Playing, Settings, Welcome) update to reflect changes.
- DTOs are used to transmit state and response data between components, ensuring that there is a clear demarcation between backend logic and presentation.
- External resources (e.g., themes and fonts) inform the UI’s appearance, while tests verify the correctness of controller operations.

##### Architectural Patterns and Key Technologies
- MVC Pattern: Separating concerns between control logic, the domain, and the UI.
- Modularization: The project is divided into well-defined sub-packages (cells, wall, state, input, components) that reflect specific responsibilities.
- Use of Java and Canvas library for graphics as indicated by the README.
- The DTO pattern is used to decouple service responses and requests, facilitating maintainability and testability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input/Interaction Layer
    subgraph "Input/Interaction Layer"
        INPUT["Keyboard/Mouse Events"]:::input
    end

    %% Presentation/View Layer
    subgraph "Presentation/View Layer"
        UI["UI Components"]:::view
        SCENES["Scenes (Playing, Welcome, Settings, Winner)"]:::view
        RESOURCES["Resources & Themes"]:::resources
    end

    %% Controller/Business Logic Layer
    subgraph "Controller/Business Logic Layer"
        CONTROLLER["GameController & State Management"]:::controller
        AI["AIPlayer, MatchManager, Chronometer"]:::controller
        DTO["Data Transfer Objects (DTO)"]:::controller
    end

    %% Domain Model Layer
    subgraph "Domain Model Layer"
        MODEL["GameModel & Core Entities"]:::model
        BOARD["Board"]:::model
        PLAYER["Player & AI Settings"]:::model
        WALL["Wall/Cell Entities"]:::model
    end

    %% Utility & Testing Layer
    subgraph "Utility & Testing Layer"
        UTIL["Utility Functions (Logger, ConcurrentLoop, Timeout)"]:::utility
        TEST["Testing Modules"]:::test
    end

    %% Data Flow Connections
    INPUT -->|"UserInput"| UI
    INPUT -->|"UserInput"| SCENES

    UI -->|"Triggers"| CONTROLLER
    SCENES -->|"Triggers"| CONTROLLER
    CONTROLLER -->|"Updates"| MODEL
    CONTROLLER -->|"Uses"| DTO
    MODEL -->|"Reflects State"| SCENES
    AI -->|"Integrates with"| CONTROLLER

    BOARD -->|"Represents"| MODEL
    PLAYER -->|"Represents"| MODEL
    WALL -->|"Represents"| MODEL

    UTIL -->|"Supports"| CONTROLLER
    UTIL -->|"Supports"| MODEL
    TEST -->|"Validates"| CONTROLLER
    TEST -->|"Validates"| MODEL

    SCENES -->|"Applies"| RESOURCES
    UI -->|"Uses"| RESOURCES

    %% Click Events for Component Mapping
    click CONTROLLER "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/controller"
    click AI "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/controller/logic"
    click DTO "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/controller/dto"
    click MODEL "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/model"
    click BOARD "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/model/board"
    click PLAYER "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/model/player"
    click WALL "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/model/wall"
    click SCENES "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/view/scene"
    click UI "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/view/components"
    click INPUT "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/view/input"
    click UTIL "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/util"
    click TEST "https://github.com/camargo-panqueva/proyecto-final/tree/main/test"
    click RESOURCES "https://github.com/camargo-panqueva/proyecto-final/tree/main/src/resources"

    %% Styles
    classDef input fill:#FFE4E1,stroke:#333,stroke-width:2px;
    classDef view fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef controller fill:#F08080,stroke:#333,stroke-width:2px;
    classDef model fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef utility fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef test fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef resources fill:#FFD700,stroke:#333,stroke-width:2px;
```
