# fyroxengine/fyrox architecture

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

- Interactive diagram: https://gitdiagram.com/fyroxengine/fyrox
- Repository: https://github.com/fyroxengine/fyrox

## Overview

##### Main Components
- Engine Core: Represent it with components such as fyrox-core and fyrox-impl. This includes the primary engine loop, type traits, task management, and resource management.
- Graphics Subsystem: Include fyrox-graphics along with related modules such as shaders, GPU textures, framebuffers, and uniform management.
- Audio Subsystem: Illustrate fyrox-sound and its related parts like audio buffers, decoders, DSP, and streaming.
- Animation System: Represent fyrox-animation where animation graphs, blend spaces, state machines, and spritesheet animations reside.
- Tools & Editors: Separate components for the Scene Editor (e.g., the “editor” crate and its resources like shaders and plugins) and stand-alone editor utilities.
- Scripting, Resource, and Plugin Systems: Include fyrox-scripts, fyrox-resource, and plugin architecture (the “plugins” folder inside editor) that allow for extensibility.
- Additional Modules: Don’t forget the build tools (fyrox-build-tools), math libraries (fyrox-math), auto-tiling (fyrox-autotile), and any domain-specific elements (such as fyrox-graph and fyrox-dylib).

##### Component Relationships and Interactions
- How the Editor interfaces with the Engine Core to modify scene data, invoke resource loaders, and leverage the UI system.
- More specifically, illustrate directional data flows such as:
- The Editor (or editor-standalone) sending scene change commands to the core.
- The Core interacting with the Graphics, Audio, and Physics subsystems during game loop execution.
- Communication between the Resource Manager and individual systems (graphics textures, sounds, models).
- Plugin integration into the editor and runtime, indicating extension points.

##### Architectural Patterns and Design Principles
- Modular, layered architecture. Organize layers into “Engine Core” (low-level systems, math, resource management, and fundamental engine services), “Subsystems” (graphics, sound, animation), and “Tools & Editors” (scene editor, plugins, UI).
- Separation of concerns that is evident in the distinct Cargo crates. For instance, the separation between fyrox-core, fyrox-impl, fyrox-ui, etc., reflects a clear modular design.
- A layer or annotation for extensibility—indicate plugin interfaces and how external modules can integrate.

##### Relevant Technologies, Frameworks, or Libraries
- Since Fyrox is in Rust, label components with “Rust Crate” where applicable.
- Functionalities like the “scene graph”, “rendering pipeline”, “resource loader”, and “animation state machines.”
- Optionally, note that configuration (e.g., Cargo.toml files) and build/deployment automation (e.g., .github/workflows CI) support continuous integration and module management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Engine Core & Utilities Layer
    subgraph "Engine Core & Utilities"
        fc1["fyrox-core (Engine Core)"]
        fi["fyrox-impl (Engine Implementation)"]
        fm["fyrox-math (Math Libraries)"]
        fr["fyrox-resource (Resource System)"]
        fb["fyrox-build-tools (Build Tools)"]
    end

    %% Subsystems Layer
    subgraph "Subsystems"
        fg["fyrox-graphics (Graphics Subsystem)"]
        fs["fyrox-sound (Audio Subsystem)"]
        fa["fyrox-animation (Animation System)"]
        fscene["Scene Modules (Physics/Collision & Scene Management)"]
    end

    %% Editor/UI & Tools Layer
    subgraph "Editor/UI & Tools"
        fu["fyrox-ui (UI Components)"]
        ed["Editor (UI & Inspectors)"]
        eds["Editor-Standalone (Standalone Editor)"]
        fscripts["fyrox-scripts (Scripting System)"]
        fplugins["Editor Plugins (Plugin Architecture)"]
    end

    %% Additional Modules Layer
    subgraph "Additional Modules"
        fauto["fyrox-autotile (Auto-Tiling Module)"]
        fgraph["fyrox-graph (Graph Module)"]
        fdylib["fyrox-dylib (Dynamic Libraries)"]
    end

    %% Connections between Layers
    %% Editor sends scene updates to Engine Implementation
    ed -->|"scene_updates"| fi
    eds -->|"scene_updates"| fi

    %% Core Engine interacts with Subsystems
    fc1 -->|"render_commands"| fg
    fc1 -->|"audio_commands"| fs
    fc1 -->|"animation_states"| fa
    fi -->|"scene_management"| fscene

    %% Resource and Math integrations
    fr -->|"texture_assets"| fg
    fr -->|"sound_assets"| fs
    fm -->|"math_calculations"| fc1
    fb -->|"build_assets"| fr

    %% Scripting and Plugin integrations
    fscripts -->|"script_commands"| fi
    fplugins -->|"extensibility"| ed

    %% UI interactions
    ed -->|"renders_UI"| fu
    fu -->|"UI_input"| fc1

    %% Additional Modules interactions
    fscene -->|"auto_tile"| fauto
    fi -->|"graph_data"| fgraph
    ed -->|"dynamic_extension"| fdylib

    %% Styles
    class fc1,fi,fm,fr,fb coreStyle
    class fg,fs,fa,fscene subsysStyle
    class fu,ed,eds,fscripts,fplugins editorStyle
    class fauto,fgraph,fdylib additionalStyle

    %% Class Definitions with Colors
    classDef coreStyle fill:#FFCCCC,stroke:#CC0000,stroke-width:2px;
    classDef subsysStyle fill:#CCFFCC,stroke:#009900,stroke-width:2px;
    classDef editorStyle fill:#CCCCFF,stroke:#0000CC,stroke-width:2px;
    classDef additionalStyle fill:#FFFFCC,stroke:#CCCC00,stroke-width:2px;

    %% Click Events
    click fc1 "https://github.com/fyroxengine/fyrox/tree/master/fyrox-core"
    click fi "https://github.com/fyroxengine/fyrox/tree/master/fyrox-impl"
    click fm "https://github.com/fyroxengine/fyrox/tree/master/fyrox-math"
    click fr "https://github.com/fyroxengine/fyrox/tree/master/fyrox-resource"
    click fb "https://github.com/fyroxengine/fyrox/tree/master/fyrox-build-tools"
    click fg "https://github.com/fyroxengine/fyrox/tree/master/fyrox-graphics"
    click fs "https://github.com/fyroxengine/fyrox/tree/master/fyrox-sound"
    click fa "https://github.com/fyroxengine/fyrox/tree/master/fyrox-animation"
    click fscene "https://github.com/fyroxengine/fyrox/tree/master/fyrox-impl/src/scene"
    click fu "https://github.com/fyroxengine/fyrox/tree/master/fyrox-ui"
    click ed "https://github.com/fyroxengine/fyrox/tree/master/editor"
    click eds "https://github.com/fyroxengine/fyrox/tree/master/editor-standalone"
    click fscripts "https://github.com/fyroxengine/fyrox/tree/master/fyrox-scripts"
    click fplugins "https://github.com/fyroxengine/fyrox/tree/master/editor/src/plugins"
    click fauto "https://github.com/fyroxengine/fyrox/tree/master/fyrox-autotile"
    click fgraph "https://github.com/fyroxengine/fyrox/tree/master/fyrox-graph"
    click fdylib "https://github.com/fyroxengine/fyrox/tree/master/fyrox-dylib"
```
