# ellanjiang/gameframework architecture

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

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

## Overview

##### Project Type and Purpose
- This is a client-side Unity game framework library (written in C#) that provides 19 built-in modules (e.g., Resource, UI, Entity, Network, etc.) to standardize and accelerate Unity game development.
- It is not a traditional front-end/back-end web app or microservices suite, but rather a monolithic, modular, extensible SDK integrated into a Unity project.

##### Directory Structure Analysis
- Top-level “GameFramework” folder contains dozens of subfolders, each named for one of the 19 modules plus “Base,” “Utility,” and other cross-cutting concerns.
- Each module folder contains a Manager class (e.g., ResourceManager.cs), interfaces (e.g., IResourceManager.cs, IResourceHelper.cs), event args, and callback types.
- “Base” houses core services: entry point (GameFrameworkEntry), module registration (GameFrameworkModule), event bus (EventPool), task pool, reference pool, logging, serialization, data providers, etc.
- “Utility” contains helpers for JSON, encryption, compression, random, path, text, verification—common routines used across modules.

##### Key Architectural Patterns
- Modular architecture: each feature is its own “GameFramework/ModuleName” with a Manager, interfaces for helpers, and events/callbacks.
- Event-driven: central EventPool facilitates decoupled communication—modules publish events (e.g., DownloadSuccessEventArgs) and game logic subscribes.
- Asynchronous pipelines: Resource → Download/WebRequest → FileSystem → DataTable/DataNode → Entity/UI/Scene.
- Factory/provider pattern: DataProviderCreator, IResourceHelper, IWebRequestAgentHelper allow swapping platform-specific implementations.
- Finite State Machines: FSM and Procedure modules manage in-game state transitions.
- Object pooling: ObjectPool module reuses GameObject or data instances to reduce GC and Instantiate/Destroy overhead.

##### Main Components
A. Core Foundation
- GameFrameworkEntry (bootstrap)
- GameFrameworkModule registry
- EventPool (event bus)
- TaskPool (background tasks)
- ReferencePool, Serializer, Logger
B. Feature Modules (grouped by concern)
1. Data & Configuration: ConfigManager, DataTableManager, DataNodeManager
2. Resource Management: ResourceManager (async loader), DownloadManager, WebRequestManager, FileSystemManager
3. Runtime Logic: EntityManager, UIManager, SceneManager, SoundManager, ProcedureManager, FsmManager
4. Utilities & Services: LocalizationManager, SettingManager, NetworkManager, DebuggerManager, ObjectPoolManager
C. External Integration
- Unity Engine (MonoBehaviour entry, Update loop)
- Platform-specific helpers (IResourceHelper, IFileSystemHelper, IWebRequestAgentHelper, etc.)
- User-provided modules (custom ProcedureBase, UIFormLogic, Packet subclasses)

##### Relationships and Interactions
- At startup, Unity invokes GameFrameworkEntry → registers modules via GameFrameworkModule → each Manager.Initialize().
- Game logic triggers operations (e.g., LoadScene) → calls SceneManager → ResourceManager → Download/WebRequest → FileSystem → ResourceLoader → EventPool publishes load completion → SceneManager spawns scene.
- EntityManager and UIManager also request assets via ResourceManager, subscribe to progress and completion events.
- NetworkManager manages socket channels, dispatches incoming packets via EventPool.
- DebuggerManager hooks into EventPool to display runtime logs and custom debug windows.
- FSM and ProcedureManager use EventPool and TaskPool to tick and transition states asynchronously.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Foundation
    subgraph "Core Foundation"
        direction TB
        GFE["GameFrameworkEntry"]:::core
        GFM["GameFrameworkModule"]:::core
        EP["EventPool"]:::core
        TP["TaskPool"]:::core
        RP["ReferencePool"]:::core
        SER["Serializer"]:::core
        LOG["Logger"]:::core
        DPC["DataProviderCreator"]:::core
    end

    %% Data & Configuration
    subgraph "Data & Configuration"
        direction TB
        CM["ConfigManager"]:::data
        DTM["DataTableManager"]:::data
        DNM["DataNodeManager"]:::data
        IDC["IDataProvider & DataProviderCreator"]:::data
        ICH["IConfigHelper"]:::data
    end

    %% Resource Management
    subgraph "Resource Management"
        direction TB
        RM["ResourceManager"]:::data
        DM["DownloadManager"]:::data
        WRM["WebRequestManager"]:::data
        FSMgr["FileSystemManager"]:::data
        IRH["IResourceHelper"]:::data
        IFH["IFileSystemHelper"]:::data
        IWRH["IWebRequestAgentHelper"]:::data
    end

    %% Runtime Logic
    subgraph "Runtime Logic"
        direction TB
        EM["EntityManager"]:::runtime
        UIM["UIManager"]:::runtime
        SM["SceneManager"]:::runtime
        SoM["SoundManager"]:::runtime
        PM["ProcedureManager"]:::runtime
        FSM["FsmManager"]:::runtime
        IP["IProcedure"]:::runtime
        IUI["IUIForm"]:::runtime
    end

    %% Services
    subgraph "Utilities & Services"
        direction TB
        LM["LocalizationManager"]:::service
        SSM["SettingManager"]:::service
        NM["NetworkManager"]:::service
        DMG["DebuggerManager"]:::service
        OPM["ObjectPoolManager"]:::service
    end

    %% External Integration
    subgraph "External Integration"
        direction TB
        UE["Unity Engine"]:::external
        CH["Custom Helpers & Modules"]:::external
    end

    %% Relationships
    UE -->|invokes| GFE
    GFE -->|registers modules| GFM
    GFM -->|initializes| CM & DTM & DNM & RM & DM & WRM & FSMgr & EM & UIM & SM & SoM & PM & FSM & LM & SSM & NM & DMG & OPM

    RM -->|calls| DM
    DM -->|uses| WRM
    WRM -->|accesses| FSMgr
    FSMgr -->|triggers| EP
    EP -->|notifies| SM
    RM -->|publishes| EP
    EP -->|notifies| EM & UIM

    NM -->|dispatches packets via| EP
    PM -->|uses| EP & TP
    FSM -->|uses| EP & TP
    DMG -->|subscribes to| EP

    CM -->|provides data to| DTM
    DTM -->|provides| DNM

    CH -->|implements| IRH & IFH & IWRH & ICH & IP & IUI
    IRH & IFH & IWRH -->|adapts into| RM & WRM & FSMgr
    ICH -->|extends| CM
    IP -->|extends| PM
    IUI -->|extends| UIM

    %% Click Events
    click GFE "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Base/GameFrameworkEntry.cs"
    click GFM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Base/GameFrameworkModule.cs"
    click EP "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Base/EventPool/EventPool.cs"
    click TP "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Base/TaskPool/TaskPool.cs"
    click RP "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Base/ReferencePool/ReferencePool.cs"
    click SER "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Base/GameFrameworkSerializer.cs"
    click LOG "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Base/Log/GameFrameworkLog.cs"
    click CM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Config/ConfigManager.cs"
    click DTM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/DataTable/DataTableManager.cs"
    click DNM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/DataNode/DataNodeManager.cs"
    click RM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Resource/ResourceManager.cs"
    click DM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Download/DownloadManager.cs"
    click WRM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/WebRequest/WebRequestManager.cs"
    click FSMgr "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/FileSystem/FileSystemManager.cs"
    click EM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Entity/EntityManager.cs"
    click UIM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/UI/UIManager.cs"
    click SM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Scene/SceneManager.cs"
    click SoM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Sound/SoundManager.cs"
    click PM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Procedure/ProcedureManager.cs"
    click FSM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Fsm/FsmManager.cs"
    click LM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Localization/LocalizationManager.cs"
    click SSM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Setting/SettingManager.cs"
    click NM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Network/NetworkManager.cs"
    click DMG "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Debugger/DebuggerManager.cs"
    click OPM "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/ObjectPool/ObjectPoolManager.cs"
    click DPC "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Base/DataProvider/DataProviderCreator.cs"
    click IRH "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Resource/IResourceHelper.cs"
    click IFH "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/FileSystem/IFileSystemHelper.cs"
    click IWRH "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/WebRequest/IWebRequestAgentHelper.cs"
    click ICH "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Config/IConfigHelper.cs"
    click IP "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/Procedure/ProcedureBase.cs"
    click IUI "https://github.com/ellanjiang/gameframework/blob/master/GameFramework/UI/IUIForm.cs"

    %% Styles
    classDef core fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef data fill:#c6f5c6,stroke:#333,stroke-width:1px
    classDef runtime fill:#c6dfff,stroke:#333,stroke-width:1px
    classDef service fill:#ffd9a6,stroke:#333,stroke-width:1px
    classDef external fill:#ffffff,stroke-dasharray: 5 5,stroke:#888,stroke-width:1px
```
