# egametang/et architecture

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

- Interactive diagram: https://gitdiagram.com/egametang/et
- Repository: https://github.com/egametang/et

## Overview

##### Project type and purpose
- This is a Unity-based open-source game framework (ET) that unifies client and server development in C#.
- It provides a modular, component-based architecture for MMO/online games with built-in features like actor messaging, fiber scheduling, multi-protocol networking, 3D recast pathfinding, MongoDB persistence, hot-reload/patching, AI, test cases, etc.

##### File structure
- Top-level directories:
- Assets/ & ProjectSettings/ — standard Unity client project assets and settings (scenes, profiles, input, rendering, URP, etc.)
- Packages/ — Unity packages, including ET.Init (initialization), third-party integrations (MongoDB native plug-ins), tooling (Halodi registry manager), IDE plugins, and manifest.json/packages-lock.json for Unity Package Manager.
- Book/ — markdown documentation and tutorials (running guide, architecture, package creation, coroutine/actor/AI chapters).
- Scripts/ — project-wide utilities (publish scripts).
- .sln.DotSettings, .gitignore, Directory.Build.props — solution and build configuration.
- Key patterns:
- Package-based modularity: nearly all features (Init, networking, ECS, AI, UI) are distributed as self-contained Unity packages.
- Component-based entity system: Entities gain behavior by attaching components (e.g., MailboxComponent for actor messaging, numeric component for attribute sync).
- Network protocols: native KCP/TCP/WebSocket clients supported via plug-ins and .NET Core code.
- Hot-reload & patch: Unity Editor hot-reload via ILRuntime/HybridCLR; server DLL patching at runtime.

##### Insights from README
- Core architecture: component modules + fiber scheduler + async/await ETTask + actor model + multi-protocol reliable UDP + recast 3D pathfinding + MongoDB + test case and AI framework.
- Extensibility: any feature can become its own ET Package (see Book/8.1).
- Deployment: local dev in Unity (hot-reload, debug), production as .NET Core on Linux/Windows (scalable, distributed).
- Server roles: Login, Gate, Map (scene), DBProxy, Robot (test bot), possibly custom roles (chat, battle, etc.).

##### Essential details
- That the same code assemblies live on both client and server (shared folders/packages).
- Hot-reload and ILRuntime blocks in the client pipeline.
- Sequence flows for a sample RPC call or actor message.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Unity Client" 
        UnityClient["Unity Client\n(Editor/Standalone)"]:::client
        subgraph "Client Packages"
            ETInit["ET.Init Package"]:::client
            ILRuntime["ILRuntime/HybridCLR"]:::client
            UGUI["UI Framework\n(UGUI/FGUI/YIUI)"]:::client
        end
        subgraph "Client Configuration"
            Input["Input System"]:::client
            URP["Universal Render Pipeline"]:::client
            NetworkCFG["Network Manager"]:::client
            ILRuntimeSettings["Hot-Reload Settings\n(HybridCLRSettings.asset)"]:::client
        end
    end

    %% Server Layer
    subgraph ".NET Core Server"
        CoreET["ET Server Core\n(shared assemblies)"]:::server
        subgraph "Server Roles"
            Gate["GateServer Component"]:::server
            Login["LoginServer Component"]:::server
            Map["MapServer Component"]:::server
            DBProxy["DBProxyComponent"]:::server
            Robot["RobotServer Component"]:::server
        end
        subgraph "Concurrency & Messaging"
            Fiber["Fiber Scheduler"]:::server
            Actor["Actor Model"]:::server
        end
    end

    %% External Systems
    MongoDB["MongoDB Database"]:::external
    MongoPlugins["MongoDB Native Drivers"]:::external
    PackageRegistry["Package Registry Manager"]:::external
    Documentation["Documentation & Tutorials"]:::external
    CICD["CI/CD & Deployment Scripts"]:::external

    %% Data Flows
    UnityClient -->|"Calls RPC over KCP/TCP/WebSocket"| Gate
    Gate -->|"Authenticate & Create Session"| Login
    Login -->|"Return Token"| Gate
    Gate -->|"Route Traffic"| Map
    Map -->|"DB Queries"| DBProxy
    DBProxy -->|"Read/Write"| MongoDB
    Map -->|"Run Bots"| Robot
    CoreET --> Gate
    CoreET --> Login
    CoreET --> Map
    CoreET --> DBProxy
    CoreET --> Robot
    Fiber --> Gate
    Fiber --> Login
    Fiber --> Map
    Fiber --> DBProxy
    Fiber --> Robot
    Actor --> Gate
    Actor --> Login
    Actor --> Map
    Actor --> DBProxy
    Actor --> Robot
    UnityClient --> ETInit
    UnityClient --> ILRuntime
    UnityClient --> UGUI
    UnityClient --> Input
    UnityClient --> URP
    UnityClient --> NetworkCFG
    UnityClient --> ILRuntimeSettings
    ETInit --> MongoPlugins
    ETInit --> PackageRegistry
    ETInit --> Documentation
    CICD --> Gate
    CICD --> Login
    CICD --> Map
    CICD --> DBProxy
    CICD --> Robot

    %% Click Events
    click UnityClient "https://github.com/egametang/et/tree/release9.0/Assets/"
    click ETInit "https://github.com/egametang/et/tree/release9.0/Packages/com.etetet.init/"
    click MongoPlugins "https://github.com/egametang/et/tree/release9.0/Packages/com.etetet.init/Plugins/MongoDB/runtimes/"
    click PackageRegistry "https://github.com/egametang/et/tree/release9.0/Packages/com.halodi.halodi-unity-package-registry-manager/"
    click Documentation "https://github.com/egametang/et/tree/release9.0/Book/"
    click CICD "https://github.com/egametang/et/blob/release9.0/Scripts/Publish-linux-x64.ps1"
    click Input "https://github.com/egametang/et/blob/release9.0/ProjectSettings/InputManager.asset"
    click URP "https://github.com/egametang/et/blob/release9.0/ProjectSettings/URPProjectSettings.asset"
    click NetworkCFG "https://github.com/egametang/et/blob/release9.0/ProjectSettings/NetworkManager.asset"
    click ILRuntimeSettings "https://github.com/egametang/et/blob/release9.0/ProjectSettings/HybridCLRSettings.asset"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef server fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFD580,stroke:#333,stroke-width:1px
```
