# narekmynell/splinter architecture

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

- Interactive diagram: https://gitdiagram.com/narekmynell/splinter
- Repository: https://github.com/narekmynell/splinter

## Overview

##### Project type and purpose
- This is a Unity‐based real‐time and baked mesh fracture simulation system (“Splinter”).
- It’s a full Unity project (demo scene, assets, settings) with a service‐based C# architecture using VContainer for DI.

##### File structure
- Top‐level directories:
- Assets – Unity assets (Scenes, Materials, Models, Prefabs, Scripts, Settings, TextMesh Pro)
- Packages – Unity package manifests
- ProjectSettings – Unity editor/project configuration
- Key script folders under Assets/Scripts:
- Core – application bootstrap (GameScope)
- Data – ScriptableObjects for fracture parameters
- Services – fracture algorithm implementations + interfaces
- Factories – GameObject instantiation abstractions
- Gameplay – MonoBehaviours that drive runtime fracturing
- Editor, Extensions, Debugging, Utilities – support code

##### README for additional insights
- Two fracture modes: Realtime vs. Baked
- Service interfaces: IRealtimeFractureService, IBakedFractureService
- DI container (VContainer) registers singletons and injects into components
- DemoScene shows both fracture approaches, FPS counter for perf.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Unity Engine Layer
    subgraph "Unity Engine (Runtime)"
        Physics["Physics Engine"]:::engine
        Render["Render Pipeline"]:::engine
        SceneMgr["Scene Manager"]:::engine
    end

    %% Core & DI Initialization
    subgraph "Core & DI Initialization"
        GameScope["GameScope"]:::core
        DIContainer["VContainer (DI Container)"]:::di
    end

    %% Factories Layer
    subgraph "Factories"
        IObjFactory["IObjectFactory"]:::factory
        IGameObjFactory["IGameObjectFactory"]:::factory
        GameFactory["GameFactory"]:::factory
    end

    %% Services Layer
    subgraph "Services"
        IRealtimeSvc["IRealtimeFractureService"]:::services
        IBakedSvc["IBakedFractureService"]:::services
        RealtimeSvcImpl["RealtimeFractureService"]:::services
        BakedSvcImpl["BakedFractureService"]:::services
        BaseSvc["FractureService"]:::services
    end

    %% Data Layer
    subgraph "Data (ScriptableObjects)"
        FractureSettingsDef["FractureSettings (Definition)"]:::data
        RealtimeSettingsDef["RealtimeFractureSettings (Definition)"]:::data
        BakedSettingsDef["BakedFractureSettings (Definition)"]:::data
        RealtimeSettingsAsset["RealtimeFractureSettings.asset"]:::data
        BakedSettingsAsset["BakedFractureSettings.asset"]:::data
    end

    %% Gameplay Layer
    subgraph "Gameplay"
        FracturableObj["FracturableObject"]:::gameplay
        RealtimeObj["RealtimeFracturableObject"]:::gameplay
        BakedObj["BakedFracturableObject"]:::gameplay
        CameraCtrl["SimpleCameraController"]:::gameplay
        DemoMgr["SimpleDemoManager"]:::gameplay
    end

    %% Debug/UI
    subgraph "Debug / UI"
        FPSCounter["FPSCounter"]:::debug
    end

    %% Scene & Prefabs
    subgraph "Scene & Prefabs"
        SampleScene["SampleScene.unity"]:::assets
        PrefabRT["Fracturer Realtime.prefab"]:::assets
        PrefabBaked["Fracturer Baked.prefab"]:::assets
    end

    %% Connections
    GameScope -->|initializes| DIContainer
    DIContainer -->|registers| IObjFactory
    DIContainer -->|registers| IGameObjFactory
    DIContainer -->|registers| IRealtimeSvc
    DIContainer -->|registers| IBakedSvc
    DIContainer -->|registers| BaseSvc
    DIContainer -->|registers| GameFactory

    SampleScene -->|loads| GameFactory
    GameFactory -->|instantiates| PrefabRT
    GameFactory -->|instantiates| PrefabBaked
    PrefabRT -->|has component| RealtimeObj
    PrefabBaked -->|has component| BakedObj

    RealtimeObj -->|injects| IRealtimeSvc
    BakedObj -->|injects| IBakedSvc
    FracturableObj -->|base class| RealtimeObj
    FracturableObj -->|base class| BakedObj

    RealtimeObj -->|onCollision| IRealtimeSvc
    BakedObj -->|onCollision| IBakedSvc

    IRealtimeSvc -->|reads| RealtimeSettingsAsset
    IBakedSvc -->|reads| BakedSettingsAsset
    BaseSvc -->|uses definitions| FractureSettingsDef
    RealtimeSvcImpl -->|implements| IRealtimeSvc
    BakedSvcImpl -->|implements| IBakedSvc
    BaseSvc -->|base for| RealtimeSvcImpl
    BaseSvc -->|base for| BakedSvcImpl

    IRealtimeSvc -->|applies| Physics
    IBakedSvc -->|applies| Physics

    DemoMgr -->|controls| RealtimeObj
    DemoMgr -->|controls| BakedObj
    CameraCtrl -->|attached to| SampleScene

    FPSCounter -->|monitors| Physics
    FPSCounter -->|displays on| SampleScene

    SceneMgr -->|manages| SampleScene
    Render -->|renders| SampleScene

    %% Click Events
    click GameScope "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Core/GameScope.cs"
    click GameFactory "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Factories/GameFactory.cs"
    click IObjFactory "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Factories/IObjectFactory.cs"
    click IGameObjFactory "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Factories/IGameObjectFactory.cs"
    click IRealtimeSvc "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Services/IRealtimeFractureService.cs"
    click IBakedSvc "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Services/IBakedFractureService.cs"
    click RealtimeSvcImpl "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Services/RealtimeFractureService.cs"
    click BakedSvcImpl "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Services/BakedFractureService.cs"
    click BaseSvc "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Services/FractureService.cs"
    click RealtimeSettingsAsset "https://github.com/narekmynell/splinter/blob/master/Assets/Data/RealtimeFractureSettings.asset"
    click BakedSettingsAsset "https://github.com/narekmynell/splinter/blob/master/Assets/Data/BakedFractureSettings.asset"
    click RealtimeSettingsDef "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Data/RealtimeFractureSettings.cs"
    click BakedSettingsDef "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Data/BakedFractureSettings.cs"
    click FractureSettingsDef "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Data/FractureSettings.cs"
    click RealtimeObj "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Gameplay/RealtimeFracturableObject.cs"
    click BakedObj "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Gameplay/BakedFracturableObject.cs"
    click FracturableObj "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Gameplay/FracturableObject.cs"
    click CameraCtrl "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Gameplay/SimpleCameraController.cs"
    click DemoMgr "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/SimpleDemoManager.cs"
    click FPSCounter "https://github.com/narekmynell/splinter/blob/master/Assets/Scripts/Debuging/UI/FPSCounter.cs"
    click SampleScene "https://github.com/narekmynell/splinter/blob/master/Assets/Scenes/SampleScene.unity"
    click PrefabRT "https://github.com/narekmynell/splinter/blob/master/Assets/Prefabs/Fracturer Realtime.prefab"
    click PrefabBaked "https://github.com/narekmynell/splinter/blob/master/Assets/Prefabs/Fracturer Baked.prefab"

    %% Styles
    classDef engine fill:#eeeeee,stroke:#333,stroke-width:1px
    classDef core fill:#d1c4e9,stroke:#333,stroke-width:1px
    classDef di fill:#f5f5f5,stroke:#333,stroke-width:1px
    classDef factory fill:#ffccbc,stroke:#333,stroke-width:1px
    classDef services fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef data fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef gameplay fill:#ffe0b2,stroke:#333,stroke-width:1px
    classDef debug fill:#f8bbd0,stroke:#333,stroke-width:1px
    classDef assets fill:#fff9c4,stroke:#333,stroke-width:1px
```
