# openblack/openblack architecture

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

- Interactive diagram: https://gitdiagram.com/openblack/openblack
- Repository: https://github.com/openblack/openblack

## Overview

##### Main Components Overview

a) Core Engine Layer:
- Graphics System (src/Graphics/)
- Audio System (src/Audio/)
- Input System (src/Input/)
- File System (src/FileSystem/)
- Windowing System (src/Windowing/)

b) Game Logic Layer:
- Entity Component System (src/ECS/)
- Scripting System (src/LHScriptX/)
- Resource Management (src/Resources/)
- Game State Management (src/Game.h, src/Level.h)

c) Asset Processing Layer:
- Various file format handlers (components/*)
- Resource loaders and managers

##### Component Relationships

**Game Core**
- Graphics Pipeline
- Renderer Interface
- Shader Management
- Resource Management
- Audio Pipeline
- Audio Manager
- Sound Decoders
- ECS Framework
- Components
- Systems
- Archetypes
- Game Systems
- Scripting Engine
- Physics/Dynamics
- Input Management

##### Specific Implementation Details

- Interfaces (rounded rectangles)
- Concrete implementations (solid rectangles)

##### Cross-Platform Support
Platform-specific implementations:
- Android support
- iOS support
- Desktop (Windows/Linux/macOS)

##### Key Architectural Patterns

Emphasize:
- Component-based architecture (ECS)
- Interface-based design (multiple *Interface.h files)
- Resource management system
- Plugin architecture for different rendering backends

##### External Dependencies
Integration with:
- SDL2
- OpenGL/Vulkan
- spdlog
- Other third-party libraries

**[Platform Layer]**
- ↓
**[Core Systems]**
- ↓
**[Game Logic]**
- ↓
**[Resource Management]**
- ↓
**[Asset Processing]**

Important Considerations:

##### Clear labels for
- System boundaries
- Interface points
- Data flow directions
- Component relationships

##### Modular architecture
- How components can be swapped
- Demonstrate platform abstraction
- Resource management flow

- Hierarchical layouts
- Grouping and containment

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Platform
        Windows["Windows"]:::platform
        Linux["Linux"]:::platform
        MacOS["macOS"]:::platform
        Android["Android"]:::platform
        iOS["iOS"]:::platform
    end

    subgraph Core
        Graphics["Graphics System"]:::core
        click Graphics "https://github.com/openblack/openblack/tree/master/src/Graphics/"
        Audio["Audio System"]:::core
        click Audio "https://github.com/openblack/openblack/tree/master/src/Audio/"
        Input["Input System"]:::core
        click Input "https://github.com/openblack/openblack/tree/master/src/Input/"
        FileSystem["File System"]:::core
        click FileSystem "https://github.com/openblack/openblack/tree/master/src/FileSystem/"
        Windowing["Windowing System"]:::core
        click Windowing "https://github.com/openblack/openblack/tree/master/src/Windowing/"

        GraphicsComponents["Graphics Components"]:::core
        Renderer["Renderer"]:::core
        click Renderer "https://github.com/openblack/openblack/blob/master/src/Graphics/Renderer.h"
        ShaderMgr["Shader Manager"]:::core
        click ShaderMgr "https://github.com/openblack/openblack/blob/master/src/Graphics/ShaderManager.h"

        AudioComponents["Audio Components"]:::core
        AudioMgr["Audio Manager"]:::core
        click AudioMgr "https://github.com/openblack/openblack/blob/master/src/Audio/AudioManager.h"
        AudioPlayer["Audio Player"]:::core
        click AudioPlayer "https://github.com/openblack/openblack/blob/master/src/Audio/AudioPlayer.h"

        InputMap["Game Action Map"]:::core
        click InputMap "https://github.com/openblack/openblack/blob/master/src/Input/GameActionMap.h"
        FSInterface["FileSystem Interface"]:::core
        click FSInterface "https://github.com/openblack/openblack/blob/master/src/FileSystem/FileSystemInterface.h"
        WinInterface["Windowing Interface"]:::core
        click WinInterface "https://github.com/openblack/openblack/blob/master/src/Windowing/WindowingInterface.h"
    end

    subgraph GameLogic
        ECS["Entity Component System"]:::logic
        click ECS "https://github.com/openblack/openblack/tree/master/src/ECS/"
        Scripting["Scripting System"]:::logic
        click Scripting "https://github.com/openblack/openblack/tree/master/src/LHScriptX/"
        GameState["Game State"]:::logic
        click GameState "https://github.com/openblack/openblack/blob/master/src/Game.h"
        LevelState["Level State"]:::logic
        click LevelState "https://github.com/openblack/openblack/blob/master/src/Level.h"

        ECSComponents["ECS Components"]:::logic
        click ECSComponents "https://github.com/openblack/openblack/tree/master/src/ECS/Components/"
        ECSSystems["ECS Systems"]:::logic
        click ECSSystems "https://github.com/openblack/openblack/tree/master/src/ECS/Systems/"
        ECSArchetypes["ECS Archetypes"]:::logic
        click ECSArchetypes "https://github.com/openblack/openblack/tree/master/src/ECS/Archetypes/"
        
        ScriptEngine["Script Engine"]:::logic
        click ScriptEngine "https://github.com/openblack/openblack/blob/master/src/LHScriptX/Script.h"
    end

    subgraph ResourceManagement
        ResMgr["Resource Manager"]:::resource
        click ResMgr "https://github.com/openblack/openblack/blob/master/src/Resources/ResourceManager.h"
        Debug["Debug Tools"]:::resource
        click Debug "https://github.com/openblack/openblack/tree/master/src/Debug/"
        DebugConsole["Debug Console"]:::resource
        click DebugConsole "https://github.com/openblack/openblack/blob/master/src/Debug/Console.h"
        DebugGui["Debug GUI"]:::resource
        click DebugGui "https://github.com/openblack/openblack/blob/master/src/Debug/Gui.h"
    end

    subgraph AssetProcessing
        AnimHandler["Animation Handler"]:::asset
        click AnimHandler "https://github.com/openblack/openblack/tree/master/components/anm/"
        ModelHandler["3D Model Handler"]:::asset
        click ModelHandler "https://github.com/openblack/openblack/tree/master/components/l3d/"
        LandHandler["Land Handler"]:::asset
        click LandHandler "https://github.com/openblack/openblack/tree/master/components/lnd/"
        PackageHandler["Package Handler"]:::asset
        click PackageHandler "https://github.com/openblack/openblack/tree/master/components/pack/"
        ScriptHandler["Script Handler"]:::asset
        click ScriptHandler "https://github.com/openblack/openblack/tree/master/components/ScriptLibrary/"
    end

    %% Relationships
    Platform --> Core
    Graphics --> GraphicsComponents
    GraphicsComponents --> Renderer & ShaderMgr
    Audio --> AudioComponents
    AudioComponents --> AudioMgr & AudioPlayer
    Input --> InputMap
    FileSystem --> FSInterface
    Windowing --> WinInterface
    
    Core --> GameLogic
    ECS --> ECSComponents & ECSSystems & ECSArchetypes
    Scripting --> ScriptEngine
    GameState --> LevelState
    
    GameLogic --> ResourceManagement
    Debug --> DebugConsole & DebugGui
    
    ResourceManagement --> AssetProcessing

    %% Styling
    classDef platform fill:#ff9999,stroke:#333,stroke-width:2px
    classDef core fill:#99ccff,stroke:#333,stroke-width:2px
    classDef logic fill:#99ff99,stroke:#333,stroke-width:2px
    classDef resource fill:#ffff99,stroke:#333,stroke-width:2px
    classDef asset fill:#ff99ff,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        Platform_["Platform Layer"]:::platform
        Core_["Core Systems"]:::core
        Logic_["Game Logic"]:::logic
        Resource_["Resource Management"]:::resource
        Asset_["Asset Processing"]:::asset
    end
```
