# jameshduffield/ascii-rust architecture

> Architecture diagram of the GitHub repository jameshduffield/ascii-rust, 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/jameshduffield/ascii-rust
- Repository: https://github.com/jameshduffield/ascii-rust

## Overview

##### Specific Elements

a) Plugin System
- Enemy Plugin (with sub-components for different enemy types)
- HUD Plugin
- Menu Plugin
- Turret Plugin (with various turret implementations)
- Selection Plugin
- Upgrade Plugin

b) Resource Management
- Resource.rs as a central component connecting to various systems

c) Utility Layer

##### Data Flow Representation

- Component interactions with systems
- Plugin communication paths
- Resource access patterns
- Event propagation routes

##### Important Relationships to Highlight

- How the ECS (Entity Component System) pattern is implemented
- Demonstrate the relationship between turret components and their systems
- How enemy plugins interact with the combat system
- Resource sharing between different systems

##### Technical Details

- Bevy Engine integration points
- WASM compilation pipeline
- Component dependencies
- System execution order

Remember to:
- Keep the main game loop flow visible
- Clear boundaries between major systems
- Notes about critical performance paths
- Async operations and event handlers

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef engine fill:#2b4b6b,color:white
    classDef system fill:#3c9561,color:white
    classDef plugin fill:#c66a3d,color:white
    classDef component fill:#5c9bd1,color:white
    classDef resource fill:#e8c547,color:black
    classDef utility fill:#a569bd,color:white

    %% Core Engine Layer
    BevyEngine["Bevy Game Engine"]:::engine

    %% Game Systems Layer
    subgraph Systems
        PhysicsSystem["Physics System"]:::system
        CombatSystem["Combat System"]:::system
        RenderSystem["Rendering Systems"]:::system
        PlayerSystem["Player System"]:::system
        CameraSystem["Camera System"]:::system
        HitSystem["Hit System"]:::system
        DeathSystem["Death System"]:::system
        LootSystem["Loot System"]:::system
        FloatingTextSystem["Floating Text System"]:::system
    end

    %% Component Layer
    subgraph Components
        HealthComp["Health Component"]:::component
        PhysicsComp["Physics Component"]:::component
        RotatorComp["Rotator Component"]:::component
        EngineComp["Engine Component"]:::component
        BulletComp["Bullet Component"]:::component
        LootComp["Loot Component"]:::component
        PointsComp["Points Component"]:::component
    end

    %% Plugin Layer
    subgraph Plugins
        EnemyPlugin["Enemy Plugin"]:::plugin
        HUDPlugin["HUD Plugin"]:::plugin
        MenuPlugin["Menu Plugin"]:::plugin
        TurretPlugin["Turret Plugin"]:::plugin
        SelectionPlugin["Selection Plugin"]:::plugin
        UpgradePlugin["Upgrade Plugin"]:::plugin
    end

    %% Resource Management
    ResourceMgr["Resource Manager"]:::resource

    %% Utility Layer
    subgraph Utilities
        ColorUtil["Color Utilities"]:::utility
        LayerUtil["Layer Management"]:::utility
        MathUtil["Math Utilities"]:::utility
    end

    %% Relationships
    BevyEngine --> Systems
    BevyEngine --> Components
    BevyEngine --> Plugins

    ResourceMgr --> Systems
    ResourceMgr --> Components
    ResourceMgr --> Plugins

    Utilities --> Systems
    Utilities --> Components
    Utilities --> Plugins

    %% Click Events
    click PhysicsSystem "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/system/physics.rs"
    click CombatSystem "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/system/combat.rs"
    click PlayerSystem "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/system/player.rs"
    click CameraSystem "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/system/camera.rs"
    click HitSystem "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/system/hit_flash.rs"
    click DeathSystem "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/system/death.rs"
    click FloatingTextSystem "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/system/floating_text.rs"
    click RenderSystem "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/system/explosion_render.rs"
    
    click HealthComp "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/component/health.rs"
    click PhysicsComp "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/component/physics.rs"
    click RotatorComp "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/component/rotator.rs"
    click EngineComp "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/component/engine.rs"
    click BulletComp "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/component/bullet.rs"
    click LootComp "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/component/loot.rs"
    click PointsComp "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/component/worth_points.rs"
    
    click EnemyPlugin "https://github.com/JamesHDuffield/ascii-rust/tree/master/src/plugin/enemy"
    click HUDPlugin "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/plugin/hud.rs"
    click MenuPlugin "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/plugin/menu.rs"
    click TurretPlugin "https://github.com/JamesHDuffield/ascii-rust/tree/master/src/plugin/turret"
    click SelectionPlugin "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/plugin/selection.rs"
    click UpgradePlugin "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/plugin/upgrade.rs"
    
    click ResourceMgr "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/resource.rs"
    
    click ColorUtil "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/util/colour.rs"
    click LayerUtil "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/util/layer.rs"
    click MathUtil "https://github.com/JamesHDuffield/ascii-rust/blob/master/src/util/math.rs"

    %% Legend
    subgraph Legend
        L1["Engine"]:::engine
        L2["System"]:::system
        L3["Plugin"]:::plugin
        L4["Component"]:::component
        L5["Resource"]:::resource
        L6["Utility"]:::utility
    end
```
