# ziblic/hwr-oop-project-gruppe-3 architecture

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

- Interactive diagram: https://gitdiagram.com/ziblic/hwr-oop-project-gruppe-3
- Repository: https://github.com/ziblic/hwr-oop-project-gruppe-3

## Overview

##### Project Type and Purpose
- This is a small, CLI-based full-stack (single-module) application written in Kotlin.
- Purpose: a Pokémon-style battle simulator with a command-line interface. It uses OOP design and TDD.

##### File Structure
- Top-level build files and tools: `pom.xml`, `mvnw`, `justfile`, `ktlint`, Maven wrapper under `.mvn/`.
- Executable CLI: the `tnp` script in project root.
- Source code in `src/main/kotlin/hwr/oop/tnp/`: domain model and engine classes.
- Tests in `src/test/kotlin/hwr/oop/tnp/`: one-to-one coverage of domain/engine.

##### Key Components
a. Presentation Layer (CLI)
- `tnp` script (invokes the fat-jar or `main` entry).
- Responsible for reading user commands and printing output.
b. Application Layer
- Game orchestration class: `Game.kt`
- Parses user commands: `GameParser.kt`
- Loads game data/resources: `GameLoader.kt`
c. Domain Layer
- Core entities: `Monster.kt`, `Trainer.kt`, `Type.kt`, `Attack.kt`, `BattleStats.kt`
- Constants and configuration: `Constants.kt`
d. Infrastructure Layer
- Build tools: Maven wrapper, Just
- Ktlint formatting workflow
- GitHub Actions for linting and testing
e. Testing Suite
- JUnit tests mirroring each domain & engine class

##### Interactions and Data Flow
- CLI invokes `main() → Game`
- `Game` uses `GameParser` to interpret commands
- Parsed commands trigger `GameLoader` (e.g., load monster data)
- `Game` constructs or fetches domain objects (`Monster`, `Trainer`, etc.)
- Battle logic: `BattleStats` and `Attack` compute fight outcomes
- Results return back up to `Game` → CLI prints results

##### Architectural Patterns & Principles
- Layered architecture (Presentation → Application → Domain → Infrastructure)
- Single executable JAR/CLI (no microservices)
- OOP principles: encapsulation (each entity class), single-responsibility (separate parser/loader)
- Test-Driven Development: each domain class has a corresponding test

##### Essential Elements
- Optional: note the main entry point (`main()` in `Game.kt`)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["CLI Script: tnp"]:::presentation
        GameMain["Game.kt (main)"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        Game["Game"]:::application
        Parser["GameParser"]:::application
        Loader["GameLoader"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Monster["Monster"]:::domain
        Trainer["Trainer"]:::domain
        Type["Type"]:::domain
        Attack["Attack"]:::domain
        BattleStats["BattleStats"]:::domain
        Constants["Constants"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Pom["pom.xml"]:::infra
        MavenWrap["mvnw & .mvn/wrapper"]:::infra
        JustFile["justfile"]:::infra
        Ktlint["ktlint"]:::infra
        CI1["lint_and_format_kt.yml"]:::infra
        CI2["test.yml"]:::infra
    end

    %% Testing Suite
    subgraph "Testing Suite" 
        style Testing Suite stroke-dasharray: 5 5
        GameTest["GameTest"]:::test
        ParserTest["GameParserTest"]:::test
        LoaderTest["GameLoaderTest"]:::test
        MonsterTest["MonsterTest"]:::test
        TrainerTest["TrainerTest"]:::test
        TypeTest["TypeTest"]:::test
        BattleStatsTest["BattleStatsTest"]:::test
    end

    %% Interactions
    CLI -->|"invoke main()"| GameMain
    GameMain -->|"calls Game()"| Game
    Game -->|"parseCommand()"| Parser
    Parser -->|"return command"| Game
    Game -->|"loadData()"| Loader
    Loader -->|"loads Constants & Entities"| Constants
    Loader -->|"instantiate Monster"| Monster
    Loader -->|"instantiate Trainer"| Trainer
    Game -->|"fetch Type data"| Type
    Game -->|"execute attack"| Attack
    Attack -->|"computeDamage()"| BattleStats
    BattleStats -->|"return stats"| Game
    Game -->|"return result"| CLI

    %% Testing relationships
    GameTest -->|tests| Game
    ParserTest -->|tests| Parser
    LoaderTest -->|tests| Loader
    MonsterTest -->|tests| Monster
    TrainerTest -->|tests| Trainer
    TypeTest -->|tests| Type
    BattleStatsTest -->|tests| BattleStats

    %% Click Events Presentation
    click CLI "https://github.com/ziblic/hwr-oop-project-gruppe-3/tree/main//tnp"
    click GameMain "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/Game.kt"

    %% Click Events Application
    click Game "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/Game.kt"
    click Parser "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/GameParser.kt"
    click Loader "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/GameLoader.kt"

    %% Click Events Domain
    click Monster "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/Monster.kt"
    click Trainer "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/Trainer.kt"
    click Type "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/Type.kt"
    click Attack "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/Attack.kt"
    click BattleStats "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/BattleStats.kt"
    click Constants "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/main/kotlin/hwr/oop/tnp/Constants.kt"

    %% Click Events Infrastructure
    click Pom "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/pom.xml"
    click MavenWrap "https://github.com/ziblic/hwr-oop-project-gruppe-3/tree/main/.mvn/wrapper"
    click JustFile "https://github.com/ziblic/hwr-oop-project-gruppe-3/tree/main/justfile"
    click Ktlint "https://github.com/ziblic/hwr-oop-project-gruppe-3/tree/main/ktlint"
    click CI1 "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/.github/workflows/lint_and_format_kt.yml"
    click CI2 "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/.github/workflows/test.yml"

    %% Click Events Testing
    click GameTest "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/test/kotlin/hwr/oop/tnp/GameTest.kt"
    click ParserTest "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/test/kotlin/hwr/oop/tnp/GameParserTest.kt"
    click LoaderTest "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/test/kotlin/hwr/oop/tnp/GameLoaderTest.kt"
    click MonsterTest "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/test/kotlin/hwr/oop/tnp/MonsterTest.kt"
    click TrainerTest "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/test/kotlin/hwr/oop/tnp/TrainerTest.kt"
    click TypeTest "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/test/kotlin/hwr/oop/tnp/TypeTest.kt"
    click BattleStatsTest "https://github.com/ziblic/hwr-oop-project-gruppe-3/blob/main/src/test/kotlin/hwr/oop/tnp/BattleStatsTest.kt"

    %% Styles
    classDef presentation fill:#fef3c7,stroke:#b58900
    classDef application fill:#d4f8d4,stroke:#005f00
    classDef domain fill:#cce5ff,stroke:#003366
    classDef infra fill:#e0e0e0,stroke:#666666
    classDef test fill:#ffffff,stroke:#888888,stroke-dasharray: 5 5
```
