# scellecs/morpeh architecture

> Architecture diagram of the GitHub repository scellecs/morpeh, 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/scellecs/morpeh
- Repository: https://github.com/scellecs/morpeh

## Overview

##### High-Level Architecture (Main Layer)

- Entities    | --> |   Components   | --> |    Systems     |
- (Identifiers) |     |    (Data)     |     |    (Logic)     |

- ↓                    ↓                     ↓
- World (Container) ---------------+

##### Core Components Layer (Second Layer)

- Filter     |     |    Stash     |     | SystemsGroup  |
- (Query Logic) |     |(Data Storage)|     |(System Mgmt.) |

- ↑                    ↑                    ↑

- World                        |

##### Implementation Details Layer (Third Layer)

Create sections for specific implementations:

- Native Support  | --> | Unity Integration|
- (Jobs & Burst)   |     |(MonoProviders)   |

- ↓                       ↓

- Collections    | --> |    Plugins      |
- (Custom DS Impl.) |     |(Extensions)     |

##### Key Features to Highlight

- Archetype-Based Design |

- Separate Data Store  |
- Filter Optimization  |
- Cache-Friendly      |

- Safety Features     |

- Thread Safety       |
- Component Disposal  |
- Debug Tools        |

##### Additional Elements

- World Browser tool
- Benchmarking components
- Testing infrastructure
- Unity Editor integration

##### Debug and development tools

Remember to include notes about:
- Thread safety considerations
- Performance optimization features
- Unity-specific integration points
- Plugin system architecture
- Debug and development tools

This will provide a complete picture of the framework's architecture while maintaining clarity and readability.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core ECS Pattern"]
        E["Entities"]:::core
        C["Components"]:::core
        S["Systems"]:::core
        W["World"]:::core
        
        E --> C
        C --> S
        E --> W
        C --> W
        S --> W
    end

    subgraph Architecture["Main Architecture"]
        F["Filter"]:::arch
        ST["Stash"]:::arch
        SG["SystemsGroup"]:::arch
        
        F --> W
        ST --> W
        SG --> W
    end

    subgraph Implementation["Implementation Layer"]
        NS["Native Support"]:::impl
        UI["Unity Integration"]:::impl
        COL["Collections"]:::impl
        P["Plugins"]:::impl
        AS["Archetype System"]:::impl
        
        NS --> UI
        COL --> UI
        P --> UI
        AS --> ST
    end

    subgraph Development["Development Tools"]
        WB["World Browser"]:::dev
        BM["Benchmarking"]:::dev
        T["Testing"]:::dev
        DT["Debug Tools"]:::dev
    end

    subgraph Unity["Unity Features"]
        PR["Providers"]:::unity
        US["Unity Systems"]:::unity
        ET["Editor Tools"]:::unity
        
        PR --> UI
        US --> UI
        ET --> UI
    end

    %% Relationships
    W --> DT
    W --> WB
    UI --> PR
    UI --> US
    UI --> ET

    %% Click Events
    click E "https://github.com/scellecs/morpeh/blob/main/Scellecs.Morpeh/Core/Entities/Entity.cs"
    click C "https://github.com/scellecs/morpeh/blob/main/Scellecs.Morpeh/Core/Components/IComponent.cs"
    click S "https://github.com/scellecs/morpeh/blob/main/Scellecs.Morpeh/Core/Systems/ISystem.cs"
    click W "https://github.com/scellecs/morpeh/blob/main/Scellecs.Morpeh/Core/Worlds/World.cs"
    click F "https://github.com/scellecs/morpeh/blob/main/Scellecs.Morpeh/Core/Filters/Filter.cs"
    click ST "https://github.com/scellecs/morpeh/blob/main/Scellecs.Morpeh/Core/Stashes/Stash.cs"
    click SG "https://github.com/scellecs/morpeh/blob/main/Scellecs.Morpeh/Core/Systems/SystemsGroup.cs"
    click NS "https://github.com/scellecs/morpeh/tree/main/Scellecs.Morpeh/Core/Native/"
    click UI "https://github.com/scellecs/morpeh/tree/main/Scellecs.Morpeh/Unity/"
    click COL "https://github.com/scellecs/morpeh/tree/main/Scellecs.Morpeh/Core/Collections/"
    click P "https://github.com/scellecs/morpeh/blob/main/Scellecs.Morpeh/Core/Plugins/IWorldPlugin.cs"
    click AS "https://github.com/scellecs/morpeh/tree/main/Scellecs.Morpeh/Core/Archetypes/"
    click WB "https://github.com/scellecs/morpeh/tree/main/Scellecs.Morpeh/Unity/Utils/Editor/WorldBrowser/"
    click BM "https://github.com/scellecs/morpeh/tree/main/Benchmarks/"
    click T "https://github.com/scellecs/morpeh/tree/main/Tests/"
    click DT "https://github.com/scellecs/morpeh/tree/main/Scellecs.Morpeh/Core/Utils/Debug/"
    click PR "https://github.com/scellecs/morpeh/tree/main/Scellecs.Morpeh/Unity/Providers/"
    click US "https://github.com/scellecs/morpeh/tree/main/Scellecs.Morpeh/Unity/Systems/"
    click ET "https://github.com/scellecs/morpeh/tree/main/Scellecs.Morpeh/Unity/Utils/Editor/"

    %% Styling
    classDef core fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef arch fill:#ff7f50,stroke:#000,stroke-width:2px,color:#fff
    classDef impl fill:#4caf50,stroke:#000,stroke-width:2px,color:#fff
    classDef dev fill:#9c27b0,stroke:#000,stroke-width:2px,color:#fff
    classDef unity fill:#ffd700,stroke:#000,stroke-width:2px,color:#000

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Architecture Components"]:::arch
        L3["Implementation Features"]:::impl
        L4["Development Tools"]:::dev
        L5["Unity Features"]:::unity
    end
```
