# tychohenzen/searchitbreakher architecture

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

- Interactive diagram: https://gitdiagram.com/tychohenzen/searchitbreakher
- Repository: https://github.com/tychohenzen/searchitbreakher

## Overview

##### Project type and purpose
- This is a desktop voxel‐based game (“BreakerGame”) built on the MonoGame framework.
- It consists of three .NET projects:
- SearchitBreakher: The main game application, containing the game loop, input handling, and orchestration of rendering.
- SearchitLibrary: A shared library encapsulating core voxel data structures, chunk management, and low-level graphics primitives.
- SearchitTest: A unit test suite validating library functionality (voxel parsing, chunk management, camera math, etc.).

##### File structure
- Top‐level solution (SearchitBreakher.sln) ties together the three projects.
- SearchitBreakher/
- Program.cs, BreakerGame.cs: Entry point & game core.
- Graphics/: High-level renderers (VoxelRenderer, TriangleRenderer, ChunkRendererManager, MonoGameCamera).
- Content/: MGCB pipeline assets (fonts, .gox voxel chunks).
- SearchitLibrary/
- Graphics/: Core data types and utilities (Voxel, ChunkLoader, VoxelChunkManager, VoxelShader).
- Constants.cs, Helpers.cs: Shared constants and math/helper functions.
- SearchitTest/: Unit tests targeting SearchitLibrary classes and behaviors.

##### README (empty)
- .csproj references MonoGame.Framework for SearchitBreakher.
- MGCB content pipeline file → assets feeding into renderers.
- SearchitLibrary is referenced by both the game and the tests.

##### Main components & interactions
a. Components
1. Game Application (SearchitBreakher)
– Game loop & input subsystem
– High-level rendering controllers
2. Core Library (SearchitLibrary)
– Voxel data model
– Chunk loading & management
– Camera math & transformation utilities
3. Content Pipeline
– MGCB tool processing .vox (.gox) files & spritefonts
4. Rendering Subsystem
– MonoGame.Graphics (underlying framework)
– Custom shaders (VoxelShader)
5. Unit Test Suite (SearchitTest)
– Validates library correctness
b. Relationships / Data Flow
- Game App → loads assets via Content Pipeline → passes raw data to Library’s ChunkLoader.
- Library builds VoxelChunks, manages them via VoxelChunkManager.
- Game App’s renderers (ChunkRenderer, VoxelRenderer, TriangleRenderer) consume chunk data + shaders.
- MonoGameCamera transforms world coordinates to screen space for the renderer.
- Tests invoke Library APIs in isolation: no MonoGame dependency.
c. Architectural patterns
– Modular separation: core logic in a class library, UI/render loop in the executable.
– Dependency inversion: game depends on abstractions in SearchitLibrary.
– Content pipeline separation: assets precompiled at build time.
d. Key technologies
– .NET Core / .NET Framework
– MonoGame.Framework
– MGCB content pipeline
– Custom HLSL shaders (VoxelShader)
– NUnit/xUnit/MSTest (depending on csproj) for unit tests

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Layer: Game Application
    subgraph "SearchitBreakher (Game App)" 
        direction TB
        Prog["Program.cs"]:::runtime
        click Prog "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/Program.cs"
        GameCore["BreakerGame.cs"]:::runtime
        click GameCore "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/BreakerGame.cs"
        subgraph "Renderers & Camera"
            direction TB
            ChunkR["ChunkRenderer.cs"]:::runtime
            click ChunkR "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/Graphics/ChunkRenderer.cs"
            ChunkRM["ChunkRendererManager.cs"]:::runtime
            click ChunkRM "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/Graphics/ChunkRendererManager.cs"
            MonoCam["MonoGameCamera.cs"]:::runtime
            click MonoCam "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/Graphics/MonoGameCamera.cs"
            TriR["TriangleRenderer.cs"]:::runtime
            click TriR "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/Graphics/TriangleRenderer.cs"
            VoxR["VoxelRenderer.cs"]:::runtime
            click VoxR "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/Graphics/VoxelRenderer.cs"
        end
        CSProjGame["SearchitBreakher.csproj"]:::runtime
        click CSProjGame "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/SearchitBreakher.csproj"
    end

    %% Middle Layer: Core Library
    subgraph "SearchitLibrary (Core DLL)"
        direction TB
        CSProjLib["SearchitLibrary.csproj"]:::runtime
        click CSProjLib "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/SearchitLibrary.csproj"
        Constants["Constants.cs"]:::runtime
        click Constants "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/Constants.cs"
        Helpers["Helpers.cs"]:::runtime
        click Helpers "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/Graphics/Helpers.cs"
        Voxel["Voxel.cs"]:::runtime
        click Voxel "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/Graphics/Voxel.cs"
        VoxelChunk["VoxelChunk.cs"]:::runtime
        click VoxelChunk "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/Graphics/VoxelChunk.cs"
        Triangle["Triangle.cs"]:::runtime
        click Triangle "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/Graphics/Triangle.cs"
        ChunkLoader["ChunkLoader.cs"]:::runtime
        click ChunkLoader "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/Graphics/ChunkLoader.cs"
        VoxelCM["VoxelChunkManager.cs"]:::runtime
        click VoxelCM "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/Graphics/VoxelChunkManager.cs"
        CameraUtil["Camera.cs"]:::runtime
        click CameraUtil "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/Graphics/Camera.cs"
        VoxelShader["VoxelShader.cs"]:::runtime
        click VoxelShader "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitLibrary/Graphics/VoxelShader.cs"
    end

    %% Side: Content Pipeline & Assets
    subgraph "MGCB Content Pipeline" 
        direction TB
        MGCB["Content.mgcb"]:::buildtime
        click MGCB "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/Content/Content.mgcb"
        subgraph Assets ["Assets (.gox, .spritefont)"]
            direction TB
            Font["Font.spritefont"]:::asset
            click Font "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/Content/Font.spritefont"
            Gox["Chunk_0_0_0.gox"]:::asset
            click Gox "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitBreakher/Content/voxels/Chunk_0_0_0.gox"
        end
    end

    %% Bottom Layer: Framework & Graphics API
    MonoGame["MonoGame.Framework"]:::runtime
    GraphicsAPI["Graphics API (DirectX/OpenGL)"]:::runtime

    %% Tests Side
    subgraph "SearchitTest (Unit Tests)" 
        direction TB
        CSProjTest["SearchitTest.csproj"]:::test
        click CSProjTest "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/SearchitTest.csproj"
        CamTest["CameraTests.cs"]:::test
        click CamTest "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/CameraTests.cs"
        ConstTest["ConstantsTests.cs"]:::test
        click ConstTest "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/ConstantsTests.cs"
        TriTest["TriangleTests.cs"]:::test
        click TriTest "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/TriangleTests.cs"
        GoxTests["GoxFileTests.cs"]:::test
        click GoxTests "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/GoxFileTests.cs"
        GoxFmtTest["GoxFileFormatTests.cs"]:::test
        click GoxFmtTest "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/GoxFileFormatTests.cs"
        VoxTest["VoxelTests.cs"]:::test
        click VoxTest "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/VoxelTests.cs"
        VoxChunkTest["VoxelChunkTests.cs"]:::test
        click VoxChunkTest "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/VoxelChunkTests.cs"
        VCMTest["VoxelChunkManagerTests.cs"]:::test
        click VCMTest "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/VoxelChunkManagerTests.cs"
        ShaderTest["VoxelShaderTests.cs"]:::test
        click ShaderTest "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/VoxelShaderTests.cs"
        subgraph "Test Assets"
            direction TB
            TestGox["Test.gox"]:::asset
            click TestGox "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/TestVoxels/Test.gox"
            TestTxt["Test.txt"]:::asset
            click TestTxt "https://github.com/tychohenzen/searchitbreakher/blob/master/SearchitTest/TestVoxels/Test.txt"
        end
    end

    %% Relationships
    Prog -->|loads & orchestrates| ChunkR
    Prog -->|uses GameCore| GameCore
    GameCore -->|calls renderers & camera| ChunkR
    GameCore -->|calls renderers & camera| VoxR
    GameCore -->|calls renderers & camera| TriR
    GameCore -->|calls camera utils| MonoCam

    ChunkR -->|depends on| VoxelCM
    VoxR -->|depends on| VoxelCM
    TriR -->|depends on| Triangle
    MonoCam -->|depends on| CameraUtil

    Prog -->|"loads assets"| MGCB
    MGCB -->|"provides assets"| Font
    MGCB -->|"provides assets"| Gox

    Prog -->|references| CSProjLib
    ChunkR -->|references| CSProjLib

    CSProjLib -->|builds| Constants
    CSProjLib -->|builds| Helpers
    CSProjLib -->|builds| Voxel
    CSProjLib -->|builds| VoxelChunk
    CSProjLib -->|builds| Triangle
    CSProjLib -->|builds| ChunkLoader
    CSProjLib -->|builds| VoxelCM
    CSProjLib -->|builds| CameraUtil
    CSProjLib -->|builds| VoxelShader

    VoxelShader -->|invokes| GraphicsAPI
    Helpers -->|invokes| GraphicsAPI
    ChunkLoader -->|uses| GraphicsAPI

    MonoGame -->|provides| GraphicsAPI
    Prog -->|runs on| MonoGame

    %% Tests relationships
    CamTest -->|tests| CameraUtil
    ConstTest -->|tests| Constants
    TriTest -->|tests| Triangle
    GoxTests -->|tests| ChunkLoader
    GoxFmtTest -->|tests| ChunkLoader
    VoxTest -->|tests| Voxel
    VoxChunkTest -->|tests| VoxelChunk
    VCMTest -->|tests| VoxelCM
    ShaderTest -->|tests| VoxelShader

    %% Styles
    classDef runtime fill:#bbdefb,stroke:#0d47a1,color:#0d47a1
    classDef buildtime fill:#c8e6c9,stroke:#2e7d32,color:#2e7d32
    classDef asset fill:#ffe0b2,stroke:#ef6c00,color:#e65100
    classDef test fill:#e0e0e0,stroke:#424242,color:#424242
```
