# bernatvadell/muonline architecture

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

- Interactive diagram: https://gitdiagram.com/bernatvadell/muonline
- Repository: https://github.com/bernatvadell/muonline

## Overview

##### Main Components
- Data Layer (Client.Data): This directory contains various readers, cryptors, math utilities, and parsers for different game asset files (like BMD, ATT, CAP, MAP, CWS, OBJS, etc.). It abstracts file reading, binary extensions, and encryption functionality.
- Editor Module (Client.Editor): This project appears to be a utility/editor (possibly for textures or other game assets) used to tweak visual assets or debug game data.
- Core Game Client (Client.Main): This is the heart of the game. It contains subdirectories for:
– Content management (assets, texture loaders, BMD loaders).
– Controllers (which manage graphics, camera tours, sound, effects).
– UI and Controls (login UI, in-game UI controls, debug panels, etc.).
– Objects, including players, monsters, effect objects, and environmental objects.
– Scene and World management (different Scenes, Worlds, and game levels).
- Platform-Specific Projects:
– MuWin (for Windows)
– MuAndroid (for Android)
– MuIos (for iOS)
These projects contain specific configuration files, assets (shaders, fonts), and platform-adapted code (e.g. MainActivity.cs on Android, Info.plist on iOS).

##### Understand Data Flow and Component Interactions
- At startup, the game client (Client.Main) reads the game data from disk – based on a path configured in Constants.cs – using functions and utilities provided by the Data Layer.
- The parsed data (from binary asset files, textures, models, and cryptographic files) feeds into the content loaders and controllers of the main client.
- Controllers then manage rendering (MonoGame rendering pipeline), camera control, sound, and UI. The various Scenes and Worlds control the flow of the game (Login, Game, World selection, etc.).
- The Editor module is likely used separately for asset adjustments, feeding back assets into the game during development/testing.
- Platform-specific projects wrap the core functionality so that the client can run on Windows, Android, or iOS. They handle platform-specific concerns (manifest files, SDK configuration, resource management).

##### Key Architectural Patterns and Conventions
- Layered Architecture:
- Data Processing Layer (Client.Data)
- Application Logic and Game Loop (Client.Main)
- Presentation/UI (nested under Client.Main/Controls/UI)
- Separation of Concerns:
- Different modules handle asset parsing, gameplay logic, UI handling, and scene management.
- Data-driven Design: The variety of “Reader” files (BMDReader, CAPReader, etc.) implies the usage of a data-driven approach to read and interpret complex game data.
- Dependency on External Frameworks: MonoGame is the external engine; .NET 9.0 is the runtime environment. These should be indicated as foundational technologies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    ext1[".NET 9.0"]:::external
    ext2["MonoGame Engine"]:::external
    ext3["Game Data Files"]:::external

    %% Data/Asset Processing Layer
    subgraph "Data/Asset Processing Layer"
        direction TB
        dataLayer["Client.Data"]:::data
        att["ATT Parser"]:::dataDetail
        bmd["BMD Reader"]:::dataDetail
        cap["CAP Reader"]:::dataDetail
        cws["CWS Parser"]:::dataDetail
        map["MAP Parser"]:::dataDetail
        objs["OBJS Reader"]:::dataDetail
        modulus["ModulusCryptor"]:::dataDetail
        texture["Texture Handler"]:::dataDetail
    end

    %% Editor Module (Asset/Debug Tool)
    editor["Client.Editor"]:::editor

    %% Core Game Engine Layer
    subgraph "Core Game Engine Layer"
        direction TB
        mainClient["Client.Main"]:::main
        subgraph "Content Management"
            direction TB
            content["Client.Main/Content"]:::mainDetail
        end
        subgraph "Controllers"
            direction TB
            controllers["Client.Main/Controllers"]:::mainDetail
        end
        subgraph "UI and Controls"
            direction TB
            ui["Client.Main/Controls"]:::ui
        end
        subgraph "Scenes & World Management"
            direction TB
            scenes["Client.Main/Scenes"]:::mainDetail
            worlds["Client.Main/Worlds"]:::mainDetail
        end
        subgraph "Game Objects"
            direction TB
            objects["Client.Main/Objects"]:::mainDetail
        end
    end

    %% Deployment/Platform Layer
    subgraph "Deployment/Platform Layer"
        direction TB
        muwin["MuWin"]:::platform
        muandroid["MuAndroid"]:::platform
        muios["MuIos"]:::platform
    end

    %% Relationships / Data Flow
    ext3 -->|"loads"| dataLayer
    ext1 -.->|"runtime"| mainClient
    ext2 -.->|"rendering"| mainClient

    dataLayer --> att
    dataLayer --> bmd
    dataLayer --> cap
    dataLayer --> cws
    dataLayer --> map
    dataLayer --> objs
    dataLayer --> modulus
    dataLayer --> texture

    dataLayer -->|"parsed assets"| content

    editor -->|"adjusts assets"| content
    editor -->|"uses"| dataLayer

    content --> controllers
    controllers --> ui
    controllers --> scenes
    controllers --> objects
    scenes --> worlds

    mainClient --> muwin
    mainClient --> muandroid
    mainClient --> muios

    %% Click Events
    click dataLayer "https://github.com/bernatvadell/muonline/blob/main/Client.Data"
    click editor "https://github.com/bernatvadell/muonline/blob/main/Client.Editor"
    click mainClient "https://github.com/bernatvadell/muonline/blob/main/Client.Main"
    click content "https://github.com/bernatvadell/muonline/tree/main/Client.Main/Content"
    click controllers "https://github.com/bernatvadell/muonline/tree/main/Client.Main/Controllers"
    click ui "https://github.com/bernatvadell/muonline/tree/main/Client.Main/Controls"
    click scenes "https://github.com/bernatvadell/muonline/tree/main/Client.Main/Scenes"
    click worlds "https://github.com/bernatvadell/muonline/tree/main/Client.Main/Worlds"
    click objects "https://github.com/bernatvadell/muonline/tree/main/Client.Main/Objects"
    click muwin "https://github.com/bernatvadell/muonline/tree/main/MuWin"
    click muandroid "https://github.com/bernatvadell/muonline/tree/main/MuAndroid"
    click muios "https://github.com/bernatvadell/muonline/tree/main/MuIos"

    %% Styles
    classDef external fill:#d1c4e9,stroke:#4a148c,stroke-width:2px;
    classDef data fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef dataDetail fill:#e3f2fd,stroke:#1976d2,stroke-width:1px;
    classDef editor fill:#ffcc80,stroke:#e65100,stroke-width:2px;
    classDef main fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef mainDetail fill:#e8f5e9,stroke:#388e3c,stroke-width:1px;
    classDef ui fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px;
    classDef platform fill:#eeeeee,stroke:#424242,stroke-width:2px;
```
