# profpantoja/chongame architecture

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

- Interactive diagram: https://gitdiagram.com/profpantoja/chongame
- Repository: https://github.com/profpantoja/chongame

## Overview

##### Project type and purpose
- This is a standalone Java desktop application (JavaFX game) designed to teach object-oriented programming concepts.
- It is *not* a client/server or web app, but a single process that includes a game engine, domain model, messaging layer, rendering (JavaFX), and resource management.

##### File structure
- Top-level folders:
- **game/** – Maven module with source code and resources.
- **course/** and **documentation/** – teaching/materials.
- **presentation/** – slide decks.
- Under **game/src/main/java/chon/group/game/**:
- **core/** – base Entity class.
- **domain/** – game objects (agents like Cannon, Fireball; environment).
- **drawer/** – rendering layer (EnvironmentDrawer, JavaFxDrawer, JavaFxMediator).
- **messaging/** – Message class (in-process event bus).
- **Engine.java** – orchestrates game loop and interactions.
- **SystemInfo.java** – utility/service (system metrics or configuration).
- Resources under **game/src/main/resources/images/** for sprites.

##### README for additional insights
- Confirms purpose: JavaFX game for OOP teaching.
- No external services or back end – purely a local application.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    subgraph "Game Core" 
        direction TB
        Engine["Engine"]:::core
        DomainModel["Domain Model"]:::core
        Messaging["Messaging (Event Bus)"]:::messaging
        ResourceManager["Resource Manager"]:::core
        SystemInfo["SystemInfo"]:::util
    end

    subgraph "UI Layer" 
        direction TB
        Mediator["JavaFxMediator"]:::ui
        Drawer["JavaFxDrawer"]:::ui
        EnvDrawer["EnvironmentDrawer"]:::ui
    end

    %% Domain Model breakdown
    DomainModel --> CoreEntity["Entity"]:::core
    CoreEntity --> Agents["Agents"]:::core
    CoreEntity --> Environment["Environment"]:::core

    %% Game loop flow
    Engine -->|"update() each tick"| DomainModel
    DomainModel -->|"emit Message"| Messaging
    Messaging -->|"dispatch"| Engine

    Engine -->|"loadImage()"| ResourceManager
    Engine -->|"queryMetrics()"| SystemInfo

    Engine -->|"pass entities"| Mediator
    Mediator -->|"use JavaFX API"| Drawer
    Drawer -->|"render entities"| EnvDrawer
    EnvDrawer -->|"draw environment"| Drawer

    Drawer -->|"queryMetrics()"| SystemInfo

    %% Click events
    click Engine "https://github.com/profpantoja/chongame/blob/main/game/src/main/java/chon/group/Engine.java"
    click SystemInfo "https://github.com/profpantoja/chongame/blob/main/game/src/main/java/chon/group/SystemInfo.java"
    click Module "https://github.com/profpantoja/chongame/blob/main/game/src/main/java/module-info.java"
    click CoreEntity "https://github.com/profpantoja/chongame/blob/main/game/src/main/java/chon/group/game/core/Entity.java"
    click Agents "https://github.com/profpantoja/chongame/tree/main/game/src/main/java/chon/group/game/domain/agent/"
    click Environment "https://github.com/profpantoja/chongame/blob/main/game/src/main/java/chon/group/game/domain/environment/Environment.java"
    click Messaging "https://github.com/profpantoja/chongame/blob/main/game/src/main/java/chon/group/game/messaging/Message.java"
    click Mediator "https://github.com/profpantoja/chongame/blob/main/game/src/main/java/chon/group/game/drawer/JavaFxMediator.java"
    click Drawer "https://github.com/profpantoja/chongame/blob/main/game/src/main/java/chon/group/game/drawer/JavaFxDrawer.java"
    click EnvDrawer "https://github.com/profpantoja/chongame/blob/main/game/src/main/java/chon/group/game/drawer/EnvironmentDrawer.java"
    click ResourceManager "https://github.com/profpantoja/chongame/tree/main/game/src/main/resources/images/"

    %% Styles
    classDef core fill:#cce5ff,stroke:#336699,stroke-width:2px
    classDef ui fill:#d4edda,stroke:#22863a,stroke-width:2px
    classDef messaging fill:#fff3cd,stroke:#856404,stroke-width:2px
    classDef util fill:#e2e3e5,stroke:#6c757d,stroke-width:2px

    %% Legend
    subgraph "Legend"
        direction TB
        CoreLegend["Core Logic"]:::core
        UILegend["UI Layer"]:::ui
        MsgLegend["Messaging"]:::messaging
        UtilLegend["Utilities"]:::util
    end
```
