# cataurjc/prueba architecture

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

- Interactive diagram: https://gitdiagram.com/cataurjc/prueba
- Repository: https://github.com/cataurjc/prueba

## Overview

##### Project Type and Purpose
- This is a Java-based, networked two-player Stratego game with a clear client–server architecture.
- The application is organized under the package `edu.asu.stratego.game`, with subpackages for board representation, client logic, shared models, and server logic.

##### Top-Level Components
a. Client Application
- GUI controllers and view updaters (e.g., `BoardUpdater`, `ResetImageVisibility`).
- Connection and gameplay managers (e.g., `GameConnectionManager`, `ClientGameManager`, `GamePlayManager`, `GameSetupManager`, `AttackHandler`).
- Data conversion between server and client board representations (`ServerBoardConverter`).
b. Shared Models
- Domain objects exchanged between client and server (e.g., `Game`, `Move`, `Piece`, `Player`, `BattleOutcome`, `GameState`, `GameStatus`, `MoveStatus`, `PieceColor`, `PieceType`, `ClientSocket`).
c. Server Application
- Core game flow manager (`ServerGameManager`).
- I/O and network stream handling (`IOStreamManager`).
- Move processing and rules engine (`MoveCalculator`, `PieceCombatResolver`).
- Game setup and player coordination (`SetupManager`, `PlayerExchangeManager`, `GameMoveManager`).
d. Board Representations
- Server-side board (`ServerBoard`, `ServerSquare`).
- Client-side board (`ClientBoard`, `ClientSquare`).
- Initial board setup (`SetupBoard`).

##### Relationships and Data Flows
- Client GUI → ClientGameManager → GameConnectionManager: issues connect/load/save requests.
- ClientGameManager ↔ IOStreamManager (over network sockets wrapped by `ClientSocket`): sends `Move` and `LoadRequest`/`SaveRequest` objects.
- Server IOStreamManager receives requests → ServerGameManager → dispatches to SetupManager (initialization) or to GameMoveManager.
- GameMoveManager uses MoveCalculator and PieceCombatResolver to validate and resolve battles → updates ServerBoard.
- ServerGameManager sends updated game state or board snapshots back to client.
- Client receives new state → BoardUpdater converts server board via ServerBoardConverter → updates GUI components (ClientBoard/ClientSquare).

##### Architectural Patterns and Principles
- Layered architecture separating presentation (client UI), business logic (game managers, move calculators), and data (models + board representations).
- Client–server pattern over TCP sockets, with serialized request/response objects.
- Clear demarcation of responsibilities: conversion layer (`ServerBoardConverter`), I/O layer (`IOStreamManager`), game engine layer (calc/resolver), orchestration layer (GameManager classes).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Side
    subgraph "Client" 
        direction TB
        GUI["GUI Controllers & Views"]:::client
        BU["BoardUpdater"]:::client
        RIV["ResetImageVisibility"]:::client
        CGM["ClientGameManager"]:::client
        GCM["GameConnectionManager"]:::client
        GPM["GamePlayManager"]:::client
        GSM["GameSetupManager"]:::client
        AH["AttackHandler"]:::client
        SBC["ServerBoardConverter"]:::client
    end

    %% Shared Models
    subgraph "Shared Models"
        direction TB
        Move["Move"]:::shared
        GameState["GameState"]:::shared
        LoadReq["LoadRequest"]:::shared
        SaveReq["SaveRequest"]:::shared
        Game["Game"]:::shared
        MS["MoveStatus"]:::shared
        PS["Piece"]:::shared
        PL["Player"]:::shared
        BO["BattleOutcome"]:::shared
        GS["GameStatus"]:::shared
        PC["PieceColor"]:::shared
        PT["PieceType"]:::shared
        CS["ClientSocket"]:::shared
    end

    %% Server Side
    subgraph "Server"
        direction TB
        IO["IOStreamManager"]:::server
        SGM["ServerGameManager"]:::server
        SM["SetupManager"]:::server
        PEM["PlayerExchangeManager"]:::server
        GMM["GameMoveManager"]:::server
        MC["MoveCalculator"]:::server
        PCR["PieceCombatResolver"]:::server
    end

    %% Interaction Flows
    GUI -->|"user action"| CGM
    CGM -->|"connect/load/save"| GCM
    CGM -->|"send Move / LoadReq / SaveReq"| CS
    CS -->|"over TCP"| IO
    IO -->|"receive Move / LoadReq / SaveReq"| SGM
    SGM -->|"1. Setup"| SM
    SGM -->|"1. Setup"| PEM
    SGM -->|"2. Play Move"| GMM
    GMM -->|"validate"| MC
    GMM -->|"resolve"| PCR
    GMM -->|"update board"| SGM
    SGM -->|"send GameState"| IO
    IO -->|"send GameState"| CS
    CS -->|"deliver GameState"| CGM
    CGM -->|"transform"| SBC
    SBC -->|"update"| BU
    BU -->|"refresh GUI"| RIV

    %% Click Events - Client Side
    click BU "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/client/BoardUpdater.java"
    click RIV "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/client/ResetImageVisibility.java"
    click GCM "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/client/GameConnectionManager.java"
    click CGM "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/client/ClientGameManager.java"
    click GPM "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/client/GamePlayManager.java"
    click GSM "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/client/GameSetupManager.java"
    click AH "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/client/AttackHandler.java"
    click SBC "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/ServerBoardConverter.java"

    %% Click Events - Shared Models
    click Move "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/Move.java"
    click GameState "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/GameState.java"
    click LoadReq "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/LoadRequest.java"
    click SaveReq "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/SaveRequest.java"
    click Game "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/Game.java"
    click MS "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/MoveStatus.java"
    click PS "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/Piece.java"
    click PL "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/Player.java"
    click BO "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/BattleOutcome.java"
    click GS "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/GameStatus.java"
    click PC "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/PieceColor.java"
    click PT "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/PieceType.java"
    click CS "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/models/ClientSocket.java"

    %% Click Events - Server Side
    click IO "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/server/IOStreamManager.java"
    click SGM "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/server/ServerGameManager.java"
    click SM "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/server/SetupManager.java"
    click PEM "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/server/PlayerExchangeManager.java"
    click GMM "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/server/GameMoveManager.java"
    click MC "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/server/MoveCalculator.java"
    click PCR "https://github.com/cataurjc/prueba/blob/main/src/edu/asu/stratego/game/server/PieceCombatResolver.java"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef server fill:#98FB98,stroke:#000,stroke-width:1px;
    classDef shared fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
