# simulationcraft/simc architecture

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

- Interactive diagram: https://gitdiagram.com/simulationcraft/simc
- Repository: https://github.com/simulationcraft/simc

## Overview

##### Main Components
- Core Simulation Engine – This is found mostly in the “engine” directory. It includes modules such as the event manager (engine/sim/event_manager.cpp), simulation logic (engine/sim/*.cpp), cooldown, proc, and more. This component essentially drives the simulation of combat events.
- Data & DBC Modules – The “engine/dbc” directory (plus the generated subdirectories) handles parsing and managing game data (spells, items, talents, etc). SpellDataDump is also dedicated to dumping and processing “spell” data.
- Reporting and Output – The “engine/report” subdirectory contains modules responsible for creating charts, text, and JSON reports.
- External Interfaces – The “engine/interfaces” folder handles network and external communications (e.g. with Wowhead or HTTP APIs) as well as interfacing with Armory data.
- Administrative & Build Infrastructure – This includes directories like “cli”, “gui” (with Qt) for the user interfaces, the “tests” directory, various CI scripts and build configurations (CMakeLists.txt, GitHub workflows, and Visual Studio project files).

##### Their Relationships and Interactions
- The CLI and GUI components serve as the front-end, allowing the user to set up simulations and view reports.
- Once a simulation is initiated, the simulation controller (likely in engine/sim) triggers the event system and distributes tasks – this engine will query the DBC/Data subsystem for game parameters and constructs the “player” models.
- The simulation loop uses an event manager to process combat events (buffs, debuffs, cooldowns, APL actions, etc.) where the “player” module interacts with the “action priority list” files and class-specific modules in “engine/class_modules.”
- Reporting modules then take processed simulation data and generate outputs (graphs, text-based reports, JSON files).
- External libraries (RapidJSON, RapidXML, fmt, etc.) and network interfaces are integrated throughout to parse input, format output, and handle asynchronous data (via interfaces like sc_http).

##### Architectural Patterns and Key Design Principles
- Modular Design: The clear separation between simulation logic, player modeling, data ingestion, reporting, and interfaces allows independent modification and testing.
- Event-Driven Architecture: The engine drives the simulation through a series of events (e.g., time ticks, procs, cooldown events), where components communicate using callbacks (see engine/sim/event.hpp and related files).
- Platform Separation: There are distinct components for CLI vs. GUI (with Qt) and platform-specific release scripts (e.g., Dockerfile, Windows release scripts).
- Layered Architecture: With an underlying core simulation layer, a data/DBC layer for game mechanics, and a top presentation layer (CLI/GUI/reporting), the design follows layered architecture principles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        CLI["CLI Interface"]:::input
        GUI["GUI Interface"]:::input
    end

    subgraph "Core Simulation Engine"
        engineCore["Simulation Engine Core"]:::engine
        eventMgr["Event Manager"]:::engine
        simLogic["Simulation Logic"]:::engine
        playerAPL["Player Component"]:::player
        aplGlobal["Action PriorityLists"]:::player
        aplClass["Class-specific APL"]:::player

        engineCore --> eventMgr
        eventMgr --> simLogic
        simLogic --> playerAPL
        playerAPL --> aplGlobal
        playerAPL --> aplClass
    end

    subgraph "Data & Ingestion Layer"
        dbc["Data & DBC Module"]:::data
        spellDump["Spell Data Processing"]:::data
    end

    subgraph "Reporting Layer"
        report["Reporting & Output"]:::report
    end

    subgraph "External Interfaces"
        extInt["External Interfaces"]:::external
    end

    subgraph "Administrative & Build"
        cliInfra["CLI Infrastructure"]:::infra
        guiInfra["GUI Infrastructure"]:::infra
        tests["Tests"]:::infra
        buildConf["Build Config"]:::infra
    end

    %% Layer Interactions
    CLI --> engineCore
    GUI --> engineCore
    engineCore --> dbc
    dbc --> spellDump
    engineCore --> report
    engineCore --> extInt

    cliInfra --> CLI
    guiInfra --> GUI
    tests --> engineCore
    buildConf --> engineCore

    %% Style Definitions
    classDef engine fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef data fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef report fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef external fill:#90caf9,stroke:#333,stroke-width:2px;
    classDef player fill:#f94144,stroke:#333,stroke-width:2px;
    classDef infra fill:#9e7676,stroke:#333,stroke-width:2px;
    classDef input fill:#80ed99,stroke:#333,stroke-width:2px;

    %% Click Events
    click engineCore "https://github.com/simulationcraft/simc/blob/thewarwithin/engine/sim/event_manager.cpp"
    click dbc "https://github.com/simulationcraft/simc/tree/thewarwithin/engine/dbc"
    click spellDump "https://github.com/simulationcraft/simc/tree/thewarwithin/SpellDataDump"
    click playerAPL "https://github.com/simulationcraft/simc/tree/thewarwithin/engine/player"
    click aplGlobal "https://github.com/simulationcraft/simc/tree/thewarwithin/ActionPriorityLists"
    click aplClass "https://github.com/simulationcraft/simc/tree/thewarwithin/engine/class_modules/apl"
    click CLI "https://github.com/simulationcraft/simc/tree/thewarwithin/cli"
    click GUI "https://github.com/simulationcraft/simc/tree/thewarwithin/gui"
    click tests "https://github.com/simulationcraft/simc/tree/thewarwithin/tests"
    click buildConf "https://github.com/simulationcraft/simc/blob/thewarwithin/CMakeLists.txt"
```
