# seif-sallam/sfmlengine architecture

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

- Interactive diagram: https://gitdiagram.com/seif-sallam/sfmlengine
- Repository: https://github.com/seif-sallam/sfmlengine

## Overview

##### Main High-Level Components
- SFMLEngine (static library): the core engine
- Subsystems inside SFMLEngine:
– Entity-Component System (ECS)
– Scene/Level Manager (FSM)
– Rendering System
– Physics System (Box2D integration)
– GUI System (ImGui integration)
– Input Manager (Keyboard/Mouse)
– Resource Manager (Textures, Sounds, Fonts)
- External Dependencies: SFML, Box2D, ImGui, CMake/CPM
- Demo Applications (linking SFMLEngine): Sandbox, MazeGenerator, Asteroids
- Resource Repositories (rsc folders under each): settings, textures, sounds, etc.
- Build System: CMake + Makefiles producing a static engine library and executables

##### Relationships & Data Flows
- Demo Apps → link to → SFMLEngine library
- SFMLEngine → calls → SFML API for windowing, graphics, audio
- SFMLEngine → integrates → Box2D for physics bodies & collision
- SFMLEngine → embeds → ImGui for in-editor GUI
- Resource Manager → loads → assets from rsc folders
- Input Manager → polls → Keyboard/Mouse → dispatches events to ECS
- ECS Components (e.g. SpriteRenderer, RigidBody2D, Controller) → register with → Rendering System / Physics System
- Scene Manager → orchestrates → LevelScenes in each demo, swapping scenes via FSM

##### Architectural Patterns & Principles
- Modular, layered architecture: core engine layer + demo layer
- Entity-Component-System for behavioral composition
- Finite-State Machine to manage scenes/transitions
- Dependency inversion: engine subsystems depend on interfaces, not concrete platform APIs
- Resource centralization: single ResourceManager for all asset types

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "External Dependencies"
        SFML["SFML"]:::external
        Box2D["Box2D"]:::external
        ImGuiLib["ImGui"]:::external
        CMakeCPM["CMake/CPM"]:::external
    end

    subgraph "Build System"
        CMakeTop["CMakeLists.txt"]:::build
        EngineCMake["SFMLEngine/CMakeLists.txt"]:::build
        DemoMake["Makefiles"]:::build
    end

    subgraph "SFMLEngine (Core Library)"
        direction TB
        ECS["Entity-Component System"]:::engine
        SceneMgr["Scene/Level Manager (FSM)"]:::engine
        Rendering["Rendering System"]:::engine
        Physics["Physics System"]:::engine
        GUI["GUI System"]:::engine
        Input["Input Manager"]:::engine
        Resource["Resource Manager"]:::engine
    end

    subgraph "Demo Applications"
        direction TB
        SandboxApp["Sandbox"]:::demo
        MazeApp["MazeGenerator"]:::demo
        AsteroidsApp["Asteroids"]:::demo
    end

    subgraph "Assets (rsc)"
        EngineRsc["SFMLEngine/rsc"]:::asset
        SandboxRsc["Sandbox/rsc"]:::asset
        AsteroidsRsc["Asteroids/rsc"]:::asset
    end

    SFML --> Rendering
    Box2D --> Physics
    ImGuiLib --> GUI
    CMakeCPM --> CMakeTop

    CMakeTop --> ECS
    CMakeTop --> SandboxApp
    EngineCMake --> ECS
    DemoMake --> SandboxApp
    DemoMake --> MazeApp
    DemoMake --> AsteroidsApp

    SandboxApp -->|"links to"| ECS
    MazeApp -->|"links to"| ECS
    AsteroidsApp -->|"links to"| ECS

    Resource --> EngineRsc
    Resource --> SandboxRsc
    Resource --> AsteroidsRsc

    Input --> ECS
    ECS --> Physics
    ECS --> Rendering

    classDef external fill:#9f6,stroke:#080
    classDef build fill:#bcb,stroke:#858
    classDef engine fill:#6bf,stroke:#036
    classDef demo fill:#f96,stroke:#a50
    classDef asset fill:#ccc,stroke:#666

    click ECS "https://github.com/seif-sallam/sfmlengine/tree/master/SFMLEngine/headers/Components/"
    click ECS "https://github.com/seif-sallam/sfmlengine/tree/master/SFMLEngine/src/Components/"
    click SceneMgr "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/Scene.h"
    click SceneMgr "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/Scene.cpp"
    click SceneMgr "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/LifeCycleManager.h"
    click SceneMgr "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/LifeCycleManager.cpp"
    click Rendering "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/Components/SpriteRenderer.h"
    click Rendering "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/Components/SpriteRenderer.cpp"
    click Physics "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/Components/BoxCollider.h"
    click Physics "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/Components/CircleCollider.h"
    click Physics "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/Components/RigidBody2D.h"
    click Physics "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/Components/BoxCollider.cpp"
    click Physics "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/Components/CircleCollider.cpp"
    click Physics "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/Components/RigidBody2D.cpp"
    click Physics "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/PhysicsListener.h"
    click Physics "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/PhysicsListener.cpp"
    click GUI "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/Gui/GUI.h"
    click GUI "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/Gui/GUIElement.h"
    click GUI "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/GUI/GUI.cpp"
    click Input "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/Keyboard.h"
    click Input "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/Keyboard.cpp"
    click Input "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/Mouse.h"
    click Input "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/Mouse.cpp"
    click Resource "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/ResourceLoader.h"
    click Resource "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/headers/ResourceManager.h"
    click Resource "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/src/ResourceManager.cpp"
    click ImGuiLib "https://github.com/seif-sallam/sfmlengine/tree/master/Thirdparty/imgui/"
    click CMakeCPM "https://github.com/seif-sallam/sfmlengine/blob/master/cmake/CPM.cmake"
    click CMakeTop "https://github.com/seif-sallam/sfmlengine/blob/master/CMakeLists.txt"
    click EngineCMake "https://github.com/seif-sallam/sfmlengine/blob/master/SFMLEngine/CMakeLists.txt"
    click SandboxApp "https://github.com/seif-sallam/sfmlengine/tree/master/Sandbox/"
    click MazeApp "https://github.com/seif-sallam/sfmlengine/tree/master/MazeGenerator/"
    click AsteroidsApp "https://github.com/seif-sallam/sfmlengine/tree/master/Asteroids/"
    click EngineRsc "https://github.com/seif-sallam/sfmlengine/tree/master/SFMLEngine/rsc/"
    click SandboxRsc "https://github.com/seif-sallam/sfmlengine/tree/master/Sandbox/rsc/"
    click AsteroidsRsc "https://github.com/seif-sallam/sfmlengine/tree/master/Asteroids/rsc/"
```
