# ducanhdaniel/dungeongamever2 architecture

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

- Interactive diagram: https://gitdiagram.com/ducanhdaniel/dungeongamever2
- Repository: https://github.com/ducanhdaniel/dungeongamever2

## Overview

##### Project Type and Purpose
- This is a full-stack game application. The “client” directory contains the game’s front-end (with assets, game engine code, component-based entity management, gamestates, input handling, map management, etc.), while the “server” directory houses a Spring Boot backend service (with controllers for authentication, record saving, and game saves).
- The README explains it as an action-adventure game with roguelike elements where players explore dungeons and interact with a backend for authentication and record keeping.

##### Analysis of the File Structure
- Client Module:
- Contains several directories:
- Assets & Resources (res, res_tile, maps, sound and font assets) for graphics, animations, and audio.
- Game engine code under src which is organized into modules such as “main,” “gamestates,” “entities” (including separate folders for monsters, NPCs, projectiles), “components” (such as Animation, Render, Physics, Hitbox), “system” (managing game logic for authentication, collectible items, rendering, monster behavior, door interactions, etc.), and “data” for game settings, save-load operations, and record data.
- The “api” folder shows that the client uses classes like ApiClient and HttpClient to interact with external services (i.e. the backend).
- Server Module:
- A Spring Boot application with:
- Controllers (LoginController, RecordController, SaveController) for handling client API requests.
- Data Transfer Objects (e.g., LoginDTO), Model classes (User, Record) indicating an MVC pattern.
- Service classes for file processing.
- Resources that include JSON files for user authentication and game saves.
- It uses a typical RESTful approach to serve data to the game client.

##### Final Assembly
- Inside the Client section, subdivide into:
- Core Engine & Game Loop, Gamestates/UI, Entity-Component Systems, and API Communication.
- In the Server section, subdivide into:
- REST API Controllers, Business Logic Services, and Data Persistence/Configuration.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Section
    subgraph "Client"
        %% Game Engine Core
        subgraph "Game Engine Core"
            game["Game.java"]:::client
            gamePanel["GamePanel.java"]:::client
            gameWindow["GameWindow.java"]:::client
            main["Main.java"]:::client
        end
        %% Gamestates & UI
        subgraph "Gamestates & UI"
            gamestates["Gamestates (Menu,Playing,GameOver)"]:::client
            ui["UI"]:::client
        end
        %% Input Handling
        subgraph "Input Handling"
            input["KeyboardInputs"]:::client
        end
        %% Entity-Component System
        subgraph "Entity-Component System"
            components["Components"]:::client
            entities["Entities"]:::client
        end
        %% System & Logic Modules
        subgraph "System & Logic Modules"
            systems["System Modules"]:::client
        end
        %% Data Management
        subgraph "Data Management"
            dataMgmt["Data Management"]:::client
        end
        %% API Communication
        subgraph "API Communication"
            apiClient["ApiClient"]:::client
            httpClient["HttpClient"]:::client
        end
        %% Resource Management
        subgraph "Resource Management"
            resources["Resource Management"]:::client
        end
    end

    %% Server Section
    subgraph "Server"
        %% REST API Controllers
        subgraph "REST API Controllers"
            controllers["API Controllers"]:::server
        end
        %% Business Logic / Services
        subgraph "Business Logic / Services"
            fileService["FileService"]:::server
        end
        %% Data Transfer & Model Layer
        subgraph "Data Transfer & Model Layer"
            loginDTO["LoginDTO"]:::server
            models["Data Models"]:::server
        end
        %% Configuration & Resources
        subgraph "Configuration & Resources"
            configProps["Application Properties"]:::server
            maven["Maven"]:::server
            jsonRes["JSON Config"]:::server
        end
    end

    %% Client Internal Connections
    game -->|"triggers"| gamestates
    game -->|"triggers"| input
    game -->|"initiates"| components
    game -->|"orchestrates"| systems
    game -->|"manages"| dataMgmt
    game -->|"calls"| apiClient
    game -->|"calls"| httpClient
    game -->|"loads"| resources
    gamestates -->|"updates"| ui
    components -->|"updates"| systems
    entities -->|"integrated with"| systems

    %% Client to Server API Communication
    apiClient -->|"HTTPRequest"| controllers
    httpClient -->|"HTTPRequest"| controllers
    controllers -->|"HTTPResponse"| apiClient
    controllers -->|"HTTPResponse"| httpClient

    %% Server Internal Connections
    controllers -->|"invoke"| fileService
    fileService -->|"usesDTO"| loginDTO
    fileService -->|"accesses"| models
    fileService -->|"uses"| configProps
    fileService -->|"uses"| maven
    fileService -->|"uses"| jsonRes

    %% Class Definitions (Colors)
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef server fill:#FFCCCC,stroke:#333,stroke-width:2px;

    %% Click Events for Client Modules
    click game "https://github.com/ducanhdaniel/dungeongamever2/blob/master/client/src/main/Game.java"
    click gamePanel "https://github.com/ducanhdaniel/dungeongamever2/blob/master/client/src/main/GamePanel.java"
    click gameWindow "https://github.com/ducanhdaniel/dungeongamever2/blob/master/client/src/main/GameWindow.java"
    click main "https://github.com/ducanhdaniel/dungeongamever2/blob/master/client/src/main/Main.java"
    click gamestates "https://github.com/ducanhdaniel/dungeongamever2/tree/master/client/src/gamestates"
    click ui "https://github.com/ducanhdaniel/dungeongamever2/blob/master/client/src/main/UI.java"
    click input "https://github.com/ducanhdaniel/dungeongamever2/blob/master/client/src/inputs/KeyboardInputs.java"
    click components "https://github.com/ducanhdaniel/dungeongamever2/tree/master/client/src/components"
    click entities "https://github.com/ducanhdaniel/dungeongamever2/tree/master/client/src/entities"
    click systems "https://github.com/ducanhdaniel/dungeongamever2/tree/master/client/src/system"
    click dataMgmt "https://github.com/ducanhdaniel/dungeongamever2/tree/master/client/src/data"
    click apiClient "https://github.com/ducanhdaniel/dungeongamever2/blob/master/client/src/api/ApiClient.java"
    click httpClient "https://github.com/ducanhdaniel/dungeongamever2/blob/master/client/src/api/HttpClient.java"
    click resources "https://github.com/ducanhdaniel/dungeongamever2/tree/master/client/src/utils"

    %% Click Events for Server Modules
    click controllers "https://github.com/ducanhdaniel/dungeongamever2/tree/master/server/src/main/java/com/backend/controller"
    click fileService "https://github.com/ducanhdaniel/dungeongamever2/blob/master/server/src/main/java/com/backend/service/FileService.java"
    click loginDTO "https://github.com/ducanhdaniel/dungeongamever2/blob/master/server/src/main/java/com/backend/dto/LoginDTO.java"
    click models "https://github.com/ducanhdaniel/dungeongamever2/tree/master/server/src/main/java/com/backend/model"
    click configProps "https://github.com/ducanhdaniel/dungeongamever2/blob/master/server/src/main/resources/application.properties"
    click maven "https://github.com/ducanhdaniel/dungeongamever2/blob/master/server/pom.xml"
    click jsonRes "https://github.com/ducanhdaniel/dungeongamever2/blob/master/server/src/main/resources/auth.json"
```
