# luigi3141/aetheria architecture

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

- Interactive diagram: https://gitdiagram.com/luigi3141/aetheria
- Repository: https://github.com/luigi3141/aetheria

## Overview

##### Project type and purpose
- This is a full client-side game (a fantasy RPG) built in JavaScript, employing Phaser 3 for the game engine and leveraging HTML5 and CSS for web presentation.
- Core features include pixel-art graphics, turn-based combat, procedurally generated dungeons, crafting, and character creation.

##### File structure
- Assets: The assets directory holds the game’s images, audio files (combat sounds, background music, UI sounds), and additional media. This is essential for rendering the game’s look and feel.
- Scripts: The scripts directory is subdivided into several key areas:
- scenes: Contains multiple scene files (e.g., StartScene, DungeonScene, CombatResultScene) that likely represent different game states or screens (like main menu, character creation, combat encounters, etc.).
- ui: Contains UI management scripts and components that are used to create and manage buttons, panels, input fields, and layouts.
- encounter: Handles combat-related functionality (combat engine, audio, logs, sprite management) which points to a modular design in managing turn-based combat.
- config, data, navigation, and utils: Suggest modular systems for configuration management (including assets and dungeon settings), game data (such as enemy definitions), navigation and possibly utility functions for state and health management.
- index.html and styles.css: The entry point for loading the game along with style definitions.
- Other files like package.json and node_modules indicate that although the project is relatively simple, it does use some package management (likely for development convenience or additional plugins).

##### Insights from the README
- The README clarifies that the game leverages Phaser 3, covers game state management, scene handling, and has an organized approach to UI and assets.
- There is a clear separation between assets, game logic (via scenes and UI management), and configuration.

a. Main components:
- Game Engine (Phaser 3) at the core, initiating the game loop.
- Asset Manager: Handles loading and managing assets (images, audio, sprites).
- Scene Manager: Coordinates transitions between game scenes (Start, Character Creation, Dungeon, Combat, Inventory, etc.).
- Game State Manager (scripts/gameState.js): Central component managing current state, character data, progression, etc.
- UI Manager: Manages UI elements, buttons, panels, and user inputs.
- Encounter/Combat Module: Contains scripts such as CombatEngine, CombatAudio, CombatLog, etc. representing combat mechanics.
- Data/Config Modules: Reads dungeon configuration, enemy data, and other configuration details.
b. Relationships and data flows:
- The index.html loads the main JavaScript, initializing the Phaser 3 engine.
- The Engine loads assets through the Asset Manager which relies on asset files in the assets directory.
- Scene Manager transitions between different scenes, each scene handling its specific game state.
- Game State Manager communicates with scenes and UI Manager to update the game based on player actions.
- Combat and Encounter modules are invoked from scenes like EncounterScene which drive interactions during battles.
- UI Manager provides interactive elements (using UI components defined in scripts/ui/components) that capture user inputs and send commands to update the game state.
c. Architectural patterns in use:
- Modular design: Components for UI, scenes, combat, and general utilities are separated.
- MVC or State Management: There is a clear distinction between display (scenes and UI), application logic (combat, navigation), and game state management.
- Data-driven design: Configurations, enemy definitions, and dungeon properties are stored and managed separately within data and config folders.
d. Technologies, frameworks, and libraries:
- Phaser 3 as the game engine
- Vanilla JavaScript for game logic
- HTML5 and CSS3 for the presentation layer

## Diagram (Mermaid)

```mermaid
flowchart TD
    Entry["Entry Point (index.html)"]:::external
    Engine["Phaser 3 Engine"]:::engine
    Asset["Asset Manager"]:::asset
    Scene["Scene Manager"]:::scene
    State["Game State Manager"]:::state
    UI["UI Manager"]:::ui
    Combat["Encounter/Combat Module"]:::combat
    Data["Data/Config Modules"]:::data
    Nav["Navigation Manager"]:::nav

    Entry -->|"loads"| Engine
    Engine -->|"loadAssets"| Asset
    Engine -->|"manageScenes"| Scene
    Scene <-->|"stateUpdates"| State
    Scene -->|"uiRequests"| UI
    State -->|"combatTriggers"| Combat
    UI -->|"combatCommands"| Combat
    Asset -->|"usesConfig"| Data
    State -->|"usesConfig"| Data
    Scene -->|"navigate"| Nav

    click Engine "https://github.com/luigi3141/aetheria/blob/master/index.html"
    click Engine "https://github.com/luigi3141/aetheria/blob/master/scripts/main.js"
    click Asset "https://github.com/luigi3141/aetheria/tree/master/assets/"
    click Asset "https://github.com/luigi3141/aetheria/blob/master/scripts/config/AssetConfig.js"
    click Scene "https://github.com/luigi3141/aetheria/tree/master/scripts/scenes/"
    click State "https://github.com/luigi3141/aetheria/blob/master/scripts/gameState.js"
    click UI "https://github.com/luigi3141/aetheria/blob/master/scripts/ui/UIManager.js"
    click UI "https://github.com/luigi3141/aetheria/tree/master/scripts/ui/components"
    click UI "https://github.com/luigi3141/aetheria/tree/master/scripts/ui/layout"
    click Combat "https://github.com/luigi3141/aetheria/tree/master/scripts/encounter/"
    click Data "https://github.com/luigi3141/aetheria/tree/master/scripts/data/"
    click Nav "https://github.com/luigi3141/aetheria/blob/master/scripts/navigation/NavigationManager.js"

    classDef external fill:#e0e0e0,stroke:#333,stroke-width:2px;
    classDef engine fill:#ffcccb,stroke:#333,stroke-width:2px;
    classDef asset fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef scene fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef state fill:#fffacd,stroke:#333,stroke-width:2px;
    classDef ui fill:#f4c2c2,stroke:#333,stroke-width:2px;
    classDef combat fill:#dda0dd,stroke:#333,stroke-width:2px;
    classDef data fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef nav fill:#d0f0c0,stroke:#333,stroke-width:2px;
```
