# benjamin051000/mahjongg architecture

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

- Interactive diagram: https://gitdiagram.com/benjamin051000/mahjongg
- Repository: https://github.com/benjamin051000/mahjongg

## Overview

##### Project Type Analysis
This is a game project built using the Godot Engine, specifically implementing the American National Mah Jongg League ruleset. The project structure indicates it's a standalone game application with various game components and add-on integrations.

##### Main Components

Core Game Components:
- Game Manager (mahjongg.gd)
- Title Screen System (titlescreen.gd)
- Tile Management System (tile.gd, physics_tile.gd)
- Hand Management (hand.gd)
- Dice System (dice.gd, physics_dice.gd)
- Drop Zone System (drop_zone.gd)
- Signal Bus (signal_bus.gd) for event management
- Common Utilities (common.gd)

Asset Management:
- RiichiAsset System
- Sprite Management (spritesheet_data.json)

-ons Integration:
- Todo Manager
- Git Plugin
- Script IDE

**┌─────────────────────────────────────┐**
- User Interface           │
- (titlescreen, game view, UI/HUD)   │
- ┤
- Game Logic Layer            │
- (mahjongg.gd, hand.gd, etc.)      │
- ┤
- Physics System              │
- (physics_tile.gd, physics_dice.gd) │
- ┤
- Core Systems                │
- (signal_bus.gd, common.gd)        │
- ┘

##### Component Relationships

- Signal Bus connections to all game components
- Physics system interaction with game objects
- Hand management system connection to tile system
- Drop zone interaction with physics and tile systems

##### Specific Elements

a) Core Game Flow:
**Title Screen → Game Initialize → Game Loop**
- ↓
- Player Input
- ↓
- Physics Simulation
- ↓
- State Management
- ↓
- Scene Rendering

b) Component Communication:
- Signal connections between components
- Data flow for game state changes
- Asset loading paths

##### Technical Details to Note

- Scene tree hierarchy where relevant
- Addon integration points
- Signal connections between components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        Title["Title Screen"]:::ui
        GameView["Game View"]:::ui
        HUD["HUD Elements"]:::ui
    end

    subgraph GameLogic["Game Logic Layer"]
        GameManager["Game Manager"]:::core
        HandManager["Hand Management"]:::core
        TileManager["Tile Management"]:::core
        DiceManager["Dice System"]:::core
        DropZone["Drop Zone System"]:::core
    end

    subgraph Physics["Physics System Layer"]
        PhysicsTile["Physics Tile"]:::physics
        PhysicsDice["Physics Dice"]:::physics
    end

    subgraph Core["Core Systems Layer"]
        SignalBus["Signal Bus"]:::core
        Common["Common Utilities"]:::core
    end

    subgraph Assets["Asset Management"]
        RiichiAsset["RiichiAsset System"]:::asset
        SpriteManager["Sprite Management"]:::asset
    end

    subgraph Addons["Add-ons"]
        TodoManager["Todo Manager"]:::addon
        GitPlugin["Git Plugin"]:::addon
        ScriptIDE["Script IDE"]:::addon
    end

    %% Relationships
    Title --> GameManager
    GameManager --> HandManager
    GameManager --> TileManager
    GameManager --> DiceManager
    GameManager --> DropZone
    
    TileManager --> PhysicsTile
    DiceManager --> PhysicsDice
    DropZone --> PhysicsTile
    
    SignalBus --> GameManager
    SignalBus --> HandManager
    SignalBus --> TileManager
    SignalBus --> DiceManager
    SignalBus --> DropZone
    
    RiichiAsset --> GameManager
    SpriteManager --> GameManager

    %% Click Events
    click GameManager "https://github.com/benjamin051000/mahjongg/blob/main/mahjongg.gd"
    click Title "https://github.com/benjamin051000/mahjongg/blob/main/titlescreen.gd"
    click HandManager "https://github.com/benjamin051000/mahjongg/blob/main/hand.gd"
    click TileManager "https://github.com/benjamin051000/mahjongg/blob/main/tile.gd"
    click DiceManager "https://github.com/benjamin051000/mahjongg/blob/main/dice.gd"
    click DropZone "https://github.com/benjamin051000/mahjongg/blob/main/drop_zone.gd"
    click PhysicsTile "https://github.com/benjamin051000/mahjongg/blob/main/physics_tile.gd"
    click PhysicsDice "https://github.com/benjamin051000/mahjongg/blob/main/physics_dice.gd"
    click SignalBus "https://github.com/benjamin051000/mahjongg/blob/main/signal_bus.gd"
    click Common "https://github.com/benjamin051000/mahjongg/blob/main/common.gd"
    click RiichiAsset "https://github.com/benjamin051000/mahjongg/tree/main/assets/RiichiAsset/RiichiAssetByGambleMountain"
    click SpriteManager "https://github.com/benjamin051000/mahjongg/blob/main/assets/spritesheet_data.json"
    click TodoManager "https://github.com/benjamin051000/mahjongg/tree/main/addons/Todo_Manager"
    click GitPlugin "https://github.com/benjamin051000/mahjongg/tree/main/addons/godot-git-plugin"
    click ScriptIDE "https://github.com/benjamin051000/mahjongg/tree/main/addons/script-ide"

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef physics fill:#2ecc71,stroke:#27ae60,color:white
    classDef ui fill:#f1c40f,stroke:#f39c12,color:black
    classDef addon fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef asset fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        CoreSystem["Core System"]:::core
        PhysicsSystem["Physics System"]:::physics
        UIElement["UI Element"]:::ui
        AddonSystem["Add-on"]:::addon
        AssetSystem["Asset System"]:::asset
    end
```
