# zhaw-team-toxic/pm4-team-toxic architecture

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

- Interactive diagram: https://gitdiagram.com/zhaw-team-toxic/pm4-team-toxic
- Repository: https://github.com/zhaw-team-toxic/pm4-team-toxic

## Overview

##### Project Type & Purpose
- The project is a Java game built with Gradle, using a modular design. It has clear separation between the core game logic (in the “core” module), the LWJGL3-based desktop launcher (in the “lwjgl3” module), and asset management (inside the “assets” folder). The README also outlines various testing strategies (unit, integration, screenshot) and even provides a decision matrix related to the ECS system tests.
- The purpose is to implement a game (named “Frontier”), which likely utilizes an ECS (Entity Component System) architecture (as indicated by the “components”, “systems” and “wrappers” directories), with a focus on rendering, game-state/screens management, and integration with LibGDX.

##### Analyzing the File Structure
- Notice key top-level directories:
- The “frontier” directory is the main project container.
- “frontier/core” holds the game logic (game screens, game systems, components, and the main game entry point).
- “frontier/lwjgl3” contains the platform-specific launcher code for desktop, indicating how the game is started when run on desktop environments.
- “frontier/assets” manages game-related assets like skins and fonts.
- “frontier/test” is dedicated to tests (with unit, integration, and even mock setups for UI and rendering components).
- Gradle configuration files (build.gradle, settings.gradle, gradlew scripts, and gradle wrapper files) show how the project is built and structured.
- Additional directories such as “mockups” contain UI sketches, which can inform the UI/UX aspects of the system design.

##### Extracting Information from the README
- The README clarifies how to run the game on desktop by launching the LWJGL3 module.
- It also includes detailed instructions on formatting code with Gradle tasks and provides a decision matrix on testing strategies for core game functionalities.
- This README reinforces the use of an ECS (via Ashley) approach by detailing how various game components and systems are tested.

a. Main Components:
- LWJGL3 Launcher: Acts as the entry point for desktop execution and handles the native aspects.
- Core Game Engine: Implements the game’s logic using an ECS pattern. This includes:
- Game Screens (GameScreen, LoadingScreen, StartScreen)
- Game Components (AnimationComponent, PositionComponent, RenderComponent)
- Systems such as the RenderSystem that process entities.
- Wrappers (such as FrontierSpriteBatch) that abstract rendering details.
- Asset Management: Manages resources (skins, fonts, atlases) utilized by the rendering system.
- Testing Suite: Encompasses unit tests, integration tests, and screenshot tests that verify different levels of functionality.
- Build & Configuration Management: Uses Gradle (and associated scripts) to manage dependencies and build processes.

b. Relationships and Interactions:
- The LWJGL3 module initializes the game and hands off control to the Core Game Engine.
- The Core module uses an ECS architecture where game Screens, Systems, and Components interact to update and render the game state.
- Asset management components feed graphical and UI information (through assets in the “assets” folder) into the game’s renderers.
- Testing modules are designed to interoperate with both the game logic on the core module and external libraries (like LibGDX) to validate both logic and visual correctness.
- Gradle scripts coordinate the build/deployment of multiple modules (core, lwjgl3, tests).

c. Architectural Patterns & Technologies:
- ECS Pattern: Separating entity data (components) from behavior (systems) as seen in directories for “components” and “systems.”
- Modular Layering: The separation of concerns among the launcher (lwjgl3), core game logic, and asset management.
- Build Automation & Dependency Management via Gradle.
- Usage of LibGDX libraries for game development and Ashley for the ECS (as indicated by references to ECS testing in the README).

- Clearly separate the desktop-specific entry point (LWJGL3 launcher) from the core game engine.
- Core game engine as a set of related modules: game screens, components, systems, and wrappers; note the flow from game initialization (in FrontierGame.java) to dynamic screen changes.
- A module for asset management that feeds into rendering pipelines.
- Testing suite as an external system showing how it interfaces with core functionalities (with indicators for unit, integration, and screenshot testing).
- A side note for Gradle’s role in tying these components together for builds and CI processes.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Desktop Launcher Subgraph
    subgraph "Desktop Launcher"
        Lwjgl3Launcher("Lwjgl3Launcher"):::launcher
        StartupHelper("StartupHelper"):::launcher
    end

    %% Core Game Engine Subgraph with internal components
    subgraph "Core Game Engine"
        FrontierGame("FrontierGame"):::core
        subgraph "Game Screens"
            GameScreen("GameScreen"):::screen
            LoadingScreen("LoadingScreen"):::screen
            StartScreen("StartScreen"):::screen
        end
        subgraph "Game Components"
            AnimationComponent("AnimationComponent"):::component
            PositionComponent("PositionComponent"):::component
            RenderComponent("RenderComponent"):::component
        end
        subgraph "Systems (ECS)"
            RenderSystem("RenderSystem"):::system
        end
        subgraph "Wrappers"
            FrontierSpriteBatch("FrontierSpriteBatch"):::wrapper
            SpriteBatchInterface("SpriteBatchInterface"):::wrapper
        end
    end

    %% Asset Management Node
    AM("Asset Management"):::asset

    %% Testing Suite Subgraph
    subgraph "Testing Suite"
        ExampleTest("ExampleTest"):::test
        GdxExtension("GdxExtension"):::test
        MockSpriteBatch("MockSpriteBatch"):::test
    end

    %% Build & Config Subgraph
    subgraph "Build & Config"
        GRADLE1("build.gradle"):::gradle
        GRADLE2("gradlew"):::gradle
        GRADLE3("gradlew.bat"):::gradle
    end

    %% Connections from Desktop Launcher to Core Game Engine
    Lwjgl3Launcher -->|"initializes"| FrontierGame
    StartupHelper -->|"assists"| FrontierGame

    %% Connections inside Core Game Engine
    FrontierGame -->|"manages"| GameScreen
    FrontierGame -->|"manages"| LoadingScreen
    FrontierGame -->|"manages"| StartScreen
    FrontierGame -->|"uses"| AnimationComponent
    FrontierGame -->|"uses"| PositionComponent
    FrontierGame -->|"uses"| RenderComponent
    FrontierGame -->|"executes"| RenderSystem
    FrontierGame -->|"rendersVia"| FrontierSpriteBatch
    FrontierGame -->|"interfaces"| SpriteBatchInterface

    %% Asset Management feeds into Core Game Engine
    AM -->|"assetLoading"| FrontierGame

    %% Testing Suite interactions with Core Game Engine
    ExampleTest -->|"tests"| FrontierGame
    GdxExtension -->|"tests"| FrontierGame
    MockSpriteBatch -->|"mocks"| FrontierGame

    %% Build & Config builds Launchers and Core
    GRADLE1 -->|"builds"| Lwjgl3Launcher
    GRADLE1 -->|"builds"| FrontierGame
    GRADLE2 -->|"builds"| Lwjgl3Launcher
    GRADLE2 -->|"builds"| FrontierGame
    GRADLE3 -->|"builds"| Lwjgl3Launcher
    GRADLE3 -->|"builds"| FrontierGame

    %% Click Events
    click Lwjgl3Launcher "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/lwjgl3/src/main/java/com/zhaw/frontier/lwjgl3/Lwjgl3Launcher.java"
    click StartupHelper "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/lwjgl3/src/main/java/com/zhaw/frontier/lwjgl3/StartupHelper.java"
    click FrontierGame "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/FrontierGame.java"
    click GameScreen "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/screens/GameScreen.java"
    click LoadingScreen "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/screens/LoadingScreen.java"
    click StartScreen "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/screens/StartScreen.java"
    click AnimationComponent "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/components/AnimationComponent.java"
    click PositionComponent "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/components/PositionComponent.java"
    click RenderComponent "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/components/RenderComponent.java"
    click RenderSystem "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/systems/RenderSystem.java"
    click FrontierSpriteBatch "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/wrappers/FrontierSpriteBatch.java"
    click SpriteBatchInterface "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/core/src/main/java/com/zhaw/frontier/wrappers/SpriteBatchInterface.java"
    click AM "https://github.com/zhaw-team-toxic/pm4-team-toxic/tree/main/frontier/assets"
    click ExampleTest "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/test/ExampleTest.java"
    click GdxExtension "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/test/GdxExtension.java"
    click MockSpriteBatch "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/test/mocks/MockSpriteBatch.java"
    click GRADLE1 "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/build.gradle"
    click GRADLE2 "https://github.com/zhaw-team-toxic/pm4-team-toxic/tree/main/frontier/gradlew"
    click GRADLE3 "https://github.com/zhaw-team-toxic/pm4-team-toxic/blob/main/frontier/gradlew.bat"

    %% Styles
    classDef launcher fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef core fill:#a2d2ff,stroke:#333,stroke-width:2px;
    classDef screen fill:#ffc8dd,stroke:#333,stroke-width:2px;
    classDef component fill:#ffafcc,stroke:#333,stroke-width:2px;
    classDef system fill:#bde0fe,stroke:#333,stroke-width:2px;
    classDef wrapper fill:#caffbf,stroke:#333,stroke-width:2px;
    classDef asset fill:#d0f4de,stroke:#333,stroke-width:2px;
    classDef test fill:#ffe066,stroke:#333,stroke-width:2px;
    classDef gradle fill:#adb5bd,stroke:#333,stroke-width:2px;
```
