# dsuriano/mathverse architecture

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

- Interactive diagram: https://gitdiagram.com/dsuriano/mathverse
- Repository: https://github.com/dsuriano/mathverse

## Overview

##### Main Components

A. Client-Side Architecture (Primary Focus)
- Game Engine Layer (Phaser 3)
- Scene Management System
- Game Logic Layer
- Asset Management
- User Interface Layer

**┌─────────────────────────────────────────────┐**
- Browser Layer                │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Phaser 3 Engine               │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Scene Management               │
- ┬──────────────┬───────────────┤
- MainMenu   │   Game       │  LevelSelect  │
- Scene     │   Scene      │    Scene      │
- ┴──────────────┴───────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Game Components                │
- ┬──────────────┬───────────────┤
- Player    │   Problem    │    Score      │
- Controls   │  Generator   │   System      │
- ┴──────────────┴───────────────┘

##### Component Relationships to Highlight

A. Scene Flow:
- MainMenuScene → TopicSelectScene → LevelSelectScene → GameScene

B. Data Flow:
- How game state flows between components
- Score updates and problem generation flow

##### Technical Details

- Phaser 3 Game Configuration (from game.js)
- Scene Management System
- Asset Loading Pipeline
- Input Management System
- Physics System (for shooting mechanics)

##### Additional Elements

- Scene types and their purposes
- Game component responsibilities
- Data flow indicators
- Input/Output mechanisms

Remember to use standard UML or similar notation where appropriate, but prioritize clarity and understanding over strict adherence to any particular diagramming standard.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser
        HTML[HTML Entry Point]
        CSS[CSS Styling]
    end

    subgraph "Phaser Engine Layer"
        GameConfig[Game Configuration]
        Physics[Physics System]
        Input[Input Management]
    end

    subgraph "Scene Management"
        SceneManager[Scene Manager]
        MainMenu[Main Menu Scene]
        TopicSelect[Topic Select Scene]
        LevelSelect[Level Select Scene]
        GameScene[Game Scene]
    end

    subgraph "Game Components"
        AssetManager[Asset Generator]
        ProblemGen[Problem Generator]
        Score[Score System]
        PlayerControls[Player Controls]
    end

    %% Relationships
    HTML --> GameConfig
    CSS --> HTML
    GameConfig --> SceneManager
    SceneManager --> MainMenu
    SceneManager --> TopicSelect
    SceneManager --> LevelSelect
    SceneManager --> GameScene
    MainMenu --> TopicSelect
    TopicSelect --> LevelSelect
    LevelSelect --> GameScene
    GameScene --> Score
    GameScene --> ProblemGen
    GameScene --> PlayerControls
    AssetManager --> SceneManager
    Physics --> GameScene
    Input --> PlayerControls

    %% Click Events
    click HTML "https://github.com/dsuriano/mathverse/blob/main/index.html"
    click CSS "https://github.com/dsuriano/mathverse/blob/main/styles.css"
    click GameConfig "https://github.com/dsuriano/mathverse/blob/main/js/game.js"
    click SceneManager "https://github.com/dsuriano/mathverse/tree/main/js/scenes/"
    click MainMenu "https://github.com/dsuriano/mathverse/blob/main/js/scenes/MainMenuScene.js"
    click TopicSelect "https://github.com/dsuriano/mathverse/blob/main/js/scenes/TopicSelectScene.js"
    click LevelSelect "https://github.com/dsuriano/mathverse/blob/main/js/scenes/LevelSelectScene.js"
    click GameScene "https://github.com/dsuriano/mathverse/blob/main/js/scenes/GameScene.js"
    click AssetManager "https://github.com/dsuriano/mathverse/blob/main/js/utils/assetGenerator.js"

    %% Styling
    classDef browser fill:#f5f5f5,stroke:#333
    classDef engine fill:#b3e0ff,stroke:#333
    classDef scene fill:#98fb98,stroke:#333
    classDef component fill:#ffd700,stroke:#333
    classDef ui fill:#dda0dd,stroke:#333

    class HTML,CSS browser
    class GameConfig,Physics,Input engine
    class SceneManager,MainMenu,TopicSelect,LevelSelect,GameScene scene
    class AssetManager,ProblemGen,Score,PlayerControls component

    %% Legend
    subgraph Legend
        L1[Browser Components]:::browser
        L2[Engine Components]:::engine
        L3[Scene Components]:::scene
        L4[Game Components]:::component
    end
```
