# pawel-szajna/schron architecture

> Architecture diagram of the GitHub repository pawel-szajna/schron, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pawel-szajna/schron
- Repository: https://github.com/pawel-szajna/schron

## Overview

##### Main Components

a) Core Engine Layer:
- Engine Module (src/engine)
- World Module (src/world)
- SDL Wrapper Module (src/sdlwrapper)
- Utility Module (src/util)

b) Game Logic Layer:
- Game Module (src/game)
- UI Module (src/ui)
- Scripting Module (src/scripting)

c) External Dependencies:
- SDL (Graphics, Input)
- Lua (Scripting)
- Sol2 (Lua Integration)
- SPDLog (Logging)

**[External Libraries Layer]**
- SDL | Lua | Sol2 | SPDLog
- ↑
**[Core Engine Layer]**
- SDL Wrapper → Engine Core ← World System
- ↑          ↑            ↑
**[Game Logic Layer]**
- UI System → Game Logic ← Scripting System
- ↑          ↑
**[Resource Layer]**
- Assets | Scripts | Levels

##### Component Relationships

- SDL Wrapper abstracts SDL functionality for the engine
- Engine Core coordinates between World System and Game Logic
- Scripting System interfaces with both Game Logic and World System
- UI System depends on SDL Wrapper for rendering
- Game Logic orchestrates UI, World, and Scripting systems

##### Additional Details

Annotations for:
- Parallel execution capabilities
- Build system dependencies
- Platform-specific considerations
- Key configuration files

##### Implementation Notes

- The modular architecture (separate CMake files per component)
- The clear separation between engine and game logic
- The extensive use of scripting for game behavior
- The abstraction layers (especially SDL wrapper)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style definitions
    classDef core fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef game fill:#90EE90,stroke:#333,stroke-width:2px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:2px
    classDef script fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef resource fill:#FFA07A,stroke:#333,stroke-width:2px

    %% External Libraries Layer
    subgraph ExternalLibs["External Libraries Layer"]
        SDL["SDL Library"]:::external
        SDL_Image["SDL Image"]:::external
        SDL_TTF["SDL TTF"]:::external
        Lua["Lua"]:::external
        Sol2["Sol2"]:::external
        SPDLog["SPDLog"]:::external
    end

    %% Core Engine Layer
    subgraph CoreEngine["Core Engine Layer"]
        Engine["Engine Core"]:::core
        World["World System"]:::core
        SDLWrapper["SDL Wrapper"]:::core
        Util["Utility Module"]:::core
    end

    %% Game Logic Layer
    subgraph GameLogic["Game Logic Layer"]
        Game["Game Logic"]:::game
        UI["UI System"]:::game
        UIEditor["UI Editor"]:::game
        UIWidgets["UI Widgets"]:::game
        Scripting["Scripting System"]:::script
    end

    %% Resource Layer
    subgraph Resources["Resource Layer"]
        Assets["Assets"]:::resource
        Scripts["Scripts"]:::script
        Levels["Levels"]:::script
        Graphics["Graphics"]:::resource
        Fonts["Fonts"]:::resource
        MenuScripts["Menu Scripts"]:::script
        DialogScripts["Dialog Scripts"]:::script
    end

    %% Relationships
    SDL --> SDLWrapper
    SDL_Image --> SDLWrapper
    SDL_TTF --> SDLWrapper
    Lua --> Scripting
    Sol2 --> Scripting
    SPDLog --> Util

    SDLWrapper --> Engine
    World --> Engine
    Engine --> Game
    
    UI --> SDLWrapper
    UI --> Game
    UIEditor --> UI
    UIWidgets --> UI
    
    Scripting --> Game
    Scripting --> World
    
    Assets --> Game
    Scripts --> Scripting
    Levels --> Game
    Graphics --> UI
    Fonts --> UI
    MenuScripts --> UI
    DialogScripts --> Game

    %% Click events for component mapping
    click Engine "https://github.com/pawel-szajna/schron/tree/master/src/engine/"
    click World "https://github.com/pawel-szajna/schron/tree/master/src/world/"
    click SDLWrapper "https://github.com/pawel-szajna/schron/tree/master/src/sdlwrapper/"
    click Util "https://github.com/pawel-szajna/schron/tree/master/src/util/"
    click Game "https://github.com/pawel-szajna/schron/tree/master/src/game/"
    click UI "https://github.com/pawel-szajna/schron/tree/master/src/ui/"
    click Scripting "https://github.com/pawel-szajna/schron/tree/master/src/scripting/"
    click SDL "https://github.com/pawel-szajna/schron/tree/master/lib/SDL/"
    click SDL_Image "https://github.com/pawel-szajna/schron/tree/master/lib/SDL_image/"
    click SDL_TTF "https://github.com/pawel-szajna/schron/tree/master/lib/SDL_ttf/"
    click Sol2 "https://github.com/pawel-szajna/schron/tree/master/lib/sol2/"
    click SPDLog "https://github.com/pawel-szajna/schron/tree/master/lib/spdlog/"
    click Assets "https://github.com/pawel-szajna/schron/tree/master/res/"
    click Scripts "https://github.com/pawel-szajna/schron/tree/master/scripts/levels/"
    click MenuScripts "https://github.com/pawel-szajna/schron/tree/master/scripts/menu/"
    click Graphics "https://github.com/pawel-szajna/schron/tree/master/res/gfx/"
    click Fonts "https://github.com/pawel-szajna/schron/tree/master/res/font/"
    click Levels "https://github.com/pawel-szajna/schron/tree/master/scripts/levels/1/"
    click DialogScripts "https://github.com/pawel-szajna/schron/tree/master/scripts/levels/1/talk/"
    click UIEditor "https://github.com/pawel-szajna/schron/tree/master/src/ui/include/ui/editor/"
    click UIWidgets "https://github.com/pawel-szajna/schron/tree/master/src/ui/include/ui/widgets/"

    %% Legend
    subgraph Legend
        CoreComponent["Core Engine"]:::core
        GameComponent["Game Logic"]:::game
        ExternalComponent["External Dependency"]:::external
        ScriptComponent["Scripting"]:::script
        ResourceComponent["Resource"]:::resource
    end
```
