# ellanjiang/unitygameframework architecture

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

- Interactive diagram: https://gitdiagram.com/ellanjiang/unitygameframework
- Repository: https://github.com/ellanjiang/unitygameframework

## Overview

##### Core Project Components
- Editor vs. Runtime: Notice from the file structure the Scripts directory is divided into “Editor” (tools to assist during development like custom inspectors, resource analyzers, build settings, and resource editors) as well as “Runtime” (the actual game modules used during game execution). Mark these two as separate blocks.
- Libraries and Prefab: There’s a “Libraries” directory (which may include core XML libraries and link configuration files) and a “GameFramework.prefab” which likely serves as a pre-configured Unity asset to bootstrap the framework.

##### Built-in Modules (as per the README’s 19 modules)
Module mentioned in the README to its corresponding implementation in the file tree structure under the “Scripts/Runtime” directory. They include:
- Config
- Data Node
- Data Table
- Debugger
- Download
- Entity
- Event
- File System
- FSM (Finite State Machine)
- Localization
- Network
- Object Pool
- Procedure
- Resource
- Scene
- Setting
- Sound
- UI
- Web Request

##### Architectural Patterns and Key Design Principles
- Modular and Extensible Structure: Every module is designed to plug into the central framework, following the dependency inversion and decoupling principles.
- Editor vs. Runtime Separation: Clearly demarcate areas of the framework meant for tool support (Editor) versus the code deployed in runtime.

##### Incorporate Technical Details
- Labels for file types or assets (e.g., “Prefab” for GameFramework.prefab, “XML” under Libraries) to provide context.
- Framework’s integration with Unity: tag elements that are specific to the Unity engine (such as Inspector tools in Editor or asynchronous resource loaders in Runtime).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Game Framework"
        Prefab["GameFramework Prefab"]:::asset
        Libraries["Libraries (XML & Link)"]:::database

        subgraph "Editor Layer"
            Editor["Editor Module"]:::editor
        end

        subgraph "Runtime Layer"
            GEntry["GameEntry (Core)"]:::core
            Config["Config Module"]:::runtime
            DataNode["Data Node Module"]:::runtime
            DataTable["Data Table Module"]:::runtime
            Debugger["Debugger Module"]:::runtime
            Download["Download Module"]:::runtime
            Entity["Entity Module"]:::runtime
            Event["Event Module"]:::runtime
            FileSystem["File System Module"]:::runtime
            FSM["FSM Module"]:::runtime
            Localization["Localization Module"]:::runtime
            Network["Network Module"]:::runtime
            ObjectPool["Object Pool Module"]:::runtime
            Procedure["Procedure Module"]:::runtime
            Resource["Resource Module"]:::runtime
            Scene["Scene Module"]:::runtime
            Setting["Setting Module"]:::runtime
            Sound["Sound Module"]:::runtime
            UI["UI Module"]:::runtime
            WebRequest["Web Request Module"]:::runtime
        end
    end

    %% Initialization from GameEntry to each runtime module
    GEntry -->|"init"| Config
    GEntry -->|"init"| DataNode
    GEntry -->|"init"| DataTable
    GEntry -->|"init"| Debugger
    GEntry -->|"init"| Download
    GEntry -->|"init"| Entity
    GEntry -->|"init"| Event
    GEntry -->|"init"| FileSystem
    GEntry -->|"init"| FSM
    GEntry -->|"init"| Localization
    GEntry -->|"init"| Network
    GEntry -->|"init"| ObjectPool
    GEntry -->|"init"| Procedure
    GEntry -->|"init"| Resource
    GEntry -->|"init"| Scene
    GEntry -->|"init"| Setting
    GEntry -->|"init"| Sound
    GEntry -->|"init"| UI
    GEntry -->|"init"| WebRequest

    %% Resource module dependencies and asynchronous load flow
    Resource -->|"async_load"| Download
    Resource -->|"async_load"| FileSystem
    Resource -->|"update"| ObjectPool
    Resource -->|"update"| Scene

    %% UI relationships with Entity and Sound modules
    UI -->|"loads"| Entity
    UI -->|"triggers"| Sound

    %% Event-driven communications from Event module
    Event -->|"broadcast"| Procedure
    Event -->|"broadcast"| Debugger
    Event -->|"broadcast"| Resource

    %% Click Events
    click Editor "https://github.com/ellanjiang/unitygameframework/tree/master/Scripts/Editor"
    click GEntry "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Base/GameEntry.cs"
    click Prefab "https://github.com/ellanjiang/unitygameframework/blob/master/GameFramework.prefab"
    click Libraries "https://github.com/ellanjiang/unitygameframework/blob/master/Libraries/GameFramework.xml"
    click Config "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Config/ConfigComponent.cs"
    click DataNode "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/DataNode/DataNodeComponent.cs"
    click DataTable "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/DataTable/DataTableComponent.cs"
    click Debugger "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Debugger/DebuggerComponent.cs"
    click Download "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Download/DownloadComponent.cs"
    click Entity "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Entity/EntityComponent.cs"
    click Event "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Event/EventComponent.cs"
    click FileSystem "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/FileSystem/FileSystemComponent.cs"
    click FSM "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Fsm/FsmComponent.cs"
    click Localization "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Localization/LocalizationComponent.cs"
    click Network "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Network/NetworkComponent.cs"
    click ObjectPool "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/ObjectPool/ObjectPoolComponent.cs"
    click Procedure "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Procedure/ProcedureComponent.cs"
    click Resource "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Resource/ResourceComponent.cs"
    click Scene "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Scene/SceneComponent.cs"
    click Setting "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Setting/SettingComponent.cs"
    click Sound "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/Sound/SoundComponent.cs"
    click UI "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/UI/UIComponent.cs"
    click WebRequest "https://github.com/ellanjiang/unitygameframework/blob/master/Scripts/Runtime/WebRequest/WebRequestComponent.cs"
    click Libraries "https://github.com/ellanjiang/unitygameframework/blob/master/Libraries/link.xml"

    %% Class Styles
    classDef core fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef runtime fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef editor fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef asset fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef database fill:#f9c0c0,stroke:#c0392b,stroke-width:2px;
```
