# nikitabyte/simplebox architecture

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

- Interactive diagram: https://gitdiagram.com/nikitabyte/simplebox
- Repository: https://github.com/nikitabyte/simplebox

## Overview

##### Project type and purpose
- SimpleBox is a standalone 2D sandbox simulation/game written in C++17 using the SFML library.
- Its purpose is to simulate and render cellular-automaton–driven physical interactions between pixel-based “materials” (sand, water, soil, etc.) in real time.

##### File structure
- Top-level:
- CMakeLists.txt – build automation
- README.md, LICENSE, CHANGELOG.md – documentation
- / – public headers (Game, Materials, MaterialEnums, UIScaler)
- src/ – implementation (Game.cpp, Materials.cpp, UIScaler.cpp, Main.cpp)
- resources/ – fonts & images for UI and logo
- Patterns & boundaries:
- Entry point/Main.cpp → Game (controller & loop)
- Materials subsystem (model) → rules, enums, behaviors
- UIScaler (utility/view) → window scaling & viewport
- SFML (external library) handles windowing, input, graphics
- No network/microservices; purely a monolithic desktop application with clear module separation.

##### Insights from the README
- “Scalable architecture” – easy to add new materials
- “Optimized simulation” – uses vertex arrays for rendering
- CMake for cross-platform builds
- Features highlight input handling, game loop, simulation, rendering, resource loading.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Main["Main (Entry Point)"]:::core
        Game["Game (Core Loop & Orchestration)"]:::core
    end

    %% Input & UI Layer
    subgraph "Input & UI"
        direction TB
        SFMLInput["SFML Input Handling"]:::view
        UIScaler["UIScaler (View Transforms)"]:::view
    end

    %% Simulation Engine Layer
    subgraph "Simulation Engine"
        direction TB
        Materials["Materials Module (Rules & Behaviors)"]:::sim
        MaterialEnums["MaterialEnums (Types & Config)"]:::sim
        Grid["Grid Data Structure"]:::sim
    end

    %% Rendering Subsystem Layer
    subgraph "Rendering Subsystem"
        direction TB
        VertexArrayBuilder["VertexArray Builder"]:::view
        SFMLWindow["SFML Window & Graphics"]:::view
    end

    %% Resource Manager Layer
    subgraph "Resource Manager"
        direction TB
        ResourceManager["Resource Manager (Fonts & Textures)"]:::resource
    end

    %% External Dependencies
    subgraph "External Dependencies"
        direction TB
        SFML["SFML Library"]:::external
        CMake["CMake (Build System)"]:::external
        Docs["Docs & Meta (README, LICENSE, Changelog)"]:::external
        UML["UML Reference (Class Diagram)"]:::external
    end

    %% Relationships
    Main -->|"initializes"| Game
    Game -->|"polls events"| SFMLInput
    SFMLInput -->|"dispatches input"| Game
    Game -->|"updates"| Materials
    Materials -->|"reads types"| MaterialEnums
    Materials -->|"manipulates"| Grid
    Grid -.->|"data flow"| VertexArrayBuilder
    UIScaler -->|"transforms view"| VertexArrayBuilder
    Game -->|"builds drawables"| VertexArrayBuilder
    VertexArrayBuilder -->|"renders to"| SFMLWindow
    ResourceManager -->|"provides resources to"| SFMLWindow
    ResourceManager -->|"provides resources to"| UIScaler
    Game -->|"loads resources via"| ResourceManager
    SFML -->|"used by"| SFMLInput
    SFML -->|"used by"| SFMLWindow
    CMake -.->|"configures build for"| Main
    Docs -.->|"documents"| Game
    UML -.->|"references design"| Materials

    %% Click Events
    click Main "https://github.com/nikitabyte/simplebox/blob/main/src/Main.cpp"
    click Game "https://github.com/nikitabyte/simplebox/blob/main/include/Game.h"
    click Materials "https://github.com/nikitabyte/simplebox/blob/main/include/Materials.h"
    click MaterialEnums "https://github.com/nikitabyte/simplebox/blob/main/include/MaterialEnums.h"
    click UIScaler "https://github.com/nikitabyte/simplebox/blob/main/include/UIScaler.h"
    click ResourceManager "https://github.com/nikitabyte/simplebox/tree/main/resources/fonts/"
    click CMake "https://github.com/nikitabyte/simplebox/blob/main/CMakeLists.txt"
    click Docs "https://github.com/nikitabyte/simplebox/blob/main/README.md"
    click UML "https://github.com/nikitabyte/simplebox/blob/main/uml/ClassDiagram.cd"

    %% Styles
    classDef core fill:#D0E1FF,stroke:#4A90E2,stroke-width:2px
    classDef view fill:#DFFFD0,stroke:#7FBF3F,stroke-width:2px
    classDef sim fill:#FFF8D0,stroke:#E1A200,stroke-width:2px
    classDef resource fill:#FFF2CC,stroke:#D4A017,stroke-width:2px
    classDef external fill:#F0F0F0,stroke:#A0A0A0,stroke-width:2px
```
