# mrsinho/shengine architecture

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

- Interactive diagram: https://gitdiagram.com/mrsinho/shengine
- Repository: https://github.com/mrsinho/shengine

## Overview

##### Main Components
- Core Engine and Libraries:
– The “collection” directory encompasses the engine’s core functionality. This includes modules such as:
▪ shengine – providing core engine services (rendering, window management, profiling, input, UI integration, etc.).
▪ shapplication-host – acting as a host layer for application logic.
▪ shcomponents – containing utility components like camera, transform, and identity.
▪ shenvironment – for file utilities and environment configuration.
▪ shterminal – for terminal I/O and logging.
▪ sheditor – if there’s any editor or live tweaking of the engine features.
– In addition, the “collection/externals” subfolder contains third-party or dependent libraries (like cglm, glfw, plyimporter, shgui, shserial, shthreads, shvulkan, smd). Represent these as either external dependencies or specialized libraries that the core engine calls upon.

- Sample Applications:
– The “applications” folder contains concrete examples (“noise”, “triangle”) that utilize the engine libraries. These serve to demonstrate and test engine functionalities.
– Each app has its own shaders (SPIR-V binaries, and human-readable shader sources), SMD scripts (for serialization or configuration), and C source files that integrate with the engine’s API.

- Build and CI Process:
– The presence of CMakeLists.txt files (both at the root and in multiple subdirectories) shows that CMake defines the build configuration.
– The “.shci” folder includes CI scripts and build logs for both Linux and Windows builds.

##### Relationships and Interactions
- The build system (CMake, export-application.py and CI scripts) orchestrates the compilation and configuration of all these components. Indicate the flow from build scripts to both engine libraries and sample apps.

##### Architectural Patterns and Design Principles
- Modular Architecture: The engine is designed as a series of loosely coupled libraries. Each module – such as rendering (shengine), application host, UI (via shgui), and utility components – can be joined together depending on the needs of a particular application.
- Clear Separation of Concerns: There is a distinct separation between the core engine functionality and concrete sample applications demonstrating usage.
- Build Automation: The integration of CMake and CI scripts implies a robust continuous integration system across multiple platforms.
- Native Scripting and Serialization: Note the handling of native scripting (C code scripts in SMD files) and serialization techniques which are integral parts of the design.

- Branch out to the “Sample Applications” that depend on these libraries.
- A side section for “External Dependencies” that feed into the core engine’s functionality.
- “Build and CI Infrastructure” as a pipeline that interacts with the entire code base.
- Keep the overall layout clear and not overly cluttered, so each module’s responsibilities and interactions are immediately understandable.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Engine Core Subgraph
    subgraph "Engine Core"
        SEA["shengine"] 
        SAH["shapplication-host"]
        SC["shcomponents"]
        SE["shenvironment"]
        ST["shterminal"]
        SED["sheditor"]
    end

    %% External Dependencies Subgraph
    subgraph "External Dependencies"
        ED["Externals"]
    end

    %% Sample Applications Subgraph
    subgraph "Sample Applications"
        APP_NOISE["Noise"]
        APP_TRIANGLE["Triangle"]
    end

    %% Build and CI Infrastructure Subgraph
    subgraph "Build & CI Infrastructure"
        BUILD_CMAKE["CMakeLists.txt"]
        BUILD_SHCI[".shci"]
        BUILD_PY["export-application.py"]
    end

    %% Relationships: Engine Core modules using External Dependencies
    SEA -->|"uses"| ED
    SAH -->|"uses"| ED
    SC  -->|"uses"| ED
    SE  -->|"uses"| ED
    ST  -->|"uses"| ED
    SED -->|"uses"| ED

    %% Relationships: Sample Applications depend on Engine Core modules
    APP_NOISE -->|"dependsOn"| SEA
    APP_NOISE -->|"dependsOn"| SAH
    APP_NOISE -->|"dependsOn"| SC
    APP_TRIANGLE -->|"dependsOn"| SEA
    APP_TRIANGLE -->|"dependsOn"| SAH
    APP_TRIANGLE -->|"dependsOn"| SC

    %% Relationship: Internal communication within Engine Core (e.g., input flow)
    ST -->|"feedsInput"| SEA

    %% Relationships: Build & CI Infrastructure triggers builds for Engine Core modules
    BUILD_CMAKE -->|"builds"| SEA
    BUILD_CMAKE -->|"builds"| SAH
    BUILD_CMAKE -->|"builds"| SC
    BUILD_CMAKE -->|"builds"| SE
    BUILD_CMAKE -->|"builds"| ST
    BUILD_CMAKE -->|"builds"| SED

    %% Relationships: Build & CI Infrastructure triggers builds for Sample Applications
    BUILD_CMAKE -->|"builds"| APP_NOISE
    BUILD_CMAKE -->|"builds"| APP_TRIANGLE
    BUILD_SHCI -->|"runs"| APP_NOISE
    BUILD_SHCI -->|"runs"| APP_TRIANGLE
    BUILD_PY   -->|"generates"| APP_NOISE
    BUILD_PY   -->|"generates"| APP_TRIANGLE

    %% Styles for different component types
    classDef engineCore fill:#a0d8f1,stroke:#333,stroke-width:2px;
    classDef sampleApp fill:#f7c59f,stroke:#333,stroke-width:2px;
    classDef external fill:#c7ecc7,stroke:#333,stroke-width:2px;
    classDef build fill:#f9e2af,stroke:#333,stroke-width:2px;

    class SEA,SAH,SC,SE,ST,SED engineCore;
    class APP_NOISE,APP_TRIANGLE sampleApp;
    class ED external;
    class BUILD_CMAKE,BUILD_SHCI,BUILD_PY build;

    %% Click Events for Core Engine and Libraries
    click SEA "https://github.com/mrsinho/shengine/tree/main/collection/shengine"
    click SAH "https://github.com/mrsinho/shengine/tree/main/collection/shapplication-host"
    click SC "https://github.com/mrsinho/shengine/tree/main/collection/shcomponents"
    click SE "https://github.com/mrsinho/shengine/tree/main/collection/shenvironment"
    click ST "https://github.com/mrsinho/shengine/tree/main/collection/shterminal"
    click SED "https://github.com/mrsinho/shengine/tree/main/collection/sheditor"

    %% Click Event for External Dependencies
    click ED "https://github.com/mrsinho/shengine/tree/main/collection/externals"

    %% Click Events for Sample Applications
    click APP_NOISE "https://github.com/mrsinho/shengine/tree/main/applications/noise"
    click APP_TRIANGLE "https://github.com/mrsinho/shengine/tree/main/applications/triangle"

    %% Click Events for Build & CI Infrastructure
    click BUILD_CMAKE "https://github.com/mrsinho/shengine/blob/main/CMakeLists.txt"
    click BUILD_SHCI "https://github.com/mrsinho/shengine/blob/main/.shci"
    click BUILD_PY "https://github.com/mrsinho/shengine/blob/main/export-application.py"
```
