# gazebosim/gz-sim architecture

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

- Interactive diagram: https://gitdiagram.com/gazebosim/gz-sim
- Repository: https://github.com/gazebosim/gz-sim

## Overview

##### Main Components (Core Layer)
- EntityComponentManager (for entity management)
- EventManager (for event handling)
- SystemLoader (for plugin management)
- SimulationRunner (for simulation execution)

##### Plugin Systems Layer (arranged in a circular pattern around the core)
- Physics Systems
- Sensor Systems
- Rendering Systems
- GUI Systems
- Network Systems
- Control Systems

##### External Dependencies Layer (top level)
- Gazebo Physics (physics engines)
- Gazebo Rendering (rendering engines)
- Gazebo Transport (communication)
- Gazebo GUI (user interface)
- Gazebo Sensors (sensor simulation)
- SDF (simulation description format)

##### Integration Layer (bottom level)
- Python Bindings
- Command Line Interface
- Network Interfaces
- Plugin APIs

Use the following visual elements:

##### Connection Types
- Double lines: Data flow paths

##### Plugin Architecture
- How the SystemLoader enables dynamic loading of various plugins
- Plugin categories (GUI, Physics, Sensors, etc.)

##### Entity-Component System
- Demonstrate how the EntityComponentManager manages simulation entities
- Component relationships and data flow

##### Event-Driven Architecture
- EventManager's role in communication
- Event flow between components

##### Distributed Architecture
- Network communication paths
- Server-client relationship

- Component groupings
- Common abbreviations

Special Considerations:

##### Integration Points (bottom)

This will create a comprehensive visualization of Gazebo Sim's architecture while maintaining clarity and usefulness for development purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef plugin fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef integration fill:#9b59b6,stroke:#8e44ad,color:white
    
    %% External Dependencies Layer
    subgraph External
        GZPhys["Gazebo Physics"]:::external
        GZRender["Gazebo Rendering"]:::external
        GZTransport["Gazebo Transport"]:::external
        GZGUI["Gazebo GUI"]:::external
        GZSensors["Gazebo Sensors"]:::external
        SDF["SDF Format"]:::external
    end

    %% Core Layer
    subgraph Core
        ECM["Entity Component Manager"]:::core
        EM["Event Manager"]:::core
        SL["System Loader"]:::core
        SR["Simulation Runner"]:::core
        Server["Server Core"]:::core
        CompSys["Component System"]:::core
        TestFW["Test Framework"]:::core
    end

    %% Plugin Systems Layer
    subgraph Plugins
        PhysSys["Physics Systems"]:::plugin
        SensorSys["Sensor Systems"]:::plugin
        RenderSys["Rendering Systems"]:::plugin
        GUISys["GUI Systems"]:::plugin
        NetSys["Network Systems"]:::plugin
        ControlSys["Control Systems"]:::plugin
    end

    %% Integration Layer
    subgraph Integration
        PythonBind["Python Bindings"]:::integration
        CLI["Command Line Interface"]:::integration
        NetInt["Network Interfaces"]:::integration
        PluginAPI["Plugin APIs"]:::integration
    end

    %% Relationships
    GZPhys --> PhysSys
    GZRender --> RenderSys
    GZTransport --> NetSys
    GZGUI --> GUISys
    GZSensors --> SensorSys
    SDF -.-> ECM

    ECM --> SR
    EM --> SR
    SL --> SR
    Server --> SR

    SL --> PhysSys
    SL --> SensorSys
    SL --> RenderSys
    SL --> GUISys
    SL --> NetSys
    SL --> ControlSys

    CompSys --> ECM
    TestFW -.-> Server

    Server --> PythonBind
    Server --> CLI
    Server --> NetInt
    PluginAPI --> SL

    %% Click Events
    click ECM "https://github.com/gazebosim/gz-sim/blob/gz-sim9/include/gz/sim/EntityComponentManager.hh"
    click EM "https://github.com/gazebosim/gz-sim/blob/gz-sim9/include/gz/sim/EventManager.hh"
    click SL "https://github.com/gazebosim/gz-sim/blob/gz-sim9/include/gz/sim/SystemLoader.hh"
    click SR "https://github.com/gazebosim/gz-sim/blob/gz-sim9/src/SimulationRunner.hh"
    click PhysSys "https://github.com/gazebosim/gz-sim/tree/gz-sim9/src/systems/physics/"
    click SensorSys "https://github.com/gazebosim/gz-sim/tree/gz-sim9/src/systems/sensors/"
    click RenderSys "https://github.com/gazebosim/gz-sim/tree/gz-sim9/src/rendering/"
    click GUISys "https://github.com/gazebosim/gz-sim/tree/gz-sim9/src/gui/"
    click NetSys "https://github.com/gazebosim/gz-sim/tree/gz-sim9/src/network/"
    click PythonBind "https://github.com/gazebosim/gz-sim/tree/gz-sim9/python/src/gz/sim/"
    click CLI "https://github.com/gazebosim/gz-sim/tree/gz-sim9/src/cmd/"
    click PluginAPI "https://github.com/gazebosim/gz-sim/blob/gz-sim9/include/gz/sim/System.hh"
    click CompSys "https://github.com/gazebosim/gz-sim/tree/gz-sim9/include/gz/sim/components/"
    click Server "https://github.com/gazebosim/gz-sim/blob/gz-sim9/include/gz/sim/Server.hh"
    click TestFW "https://github.com/gazebosim/gz-sim/blob/gz-sim9/include/gz/sim/TestFixture.hh"

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Plugin System"]:::plugin
        L3["External Dependency"]:::external
        L4["Integration Point"]:::integration
        L5[" "] --->|"Direct Dependency"| L6[" "]
        L7[" "] -.->|"Optional Relationship"| L8[" "]
    end
```
