# triangletech/maplesyrup architecture

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

- Interactive diagram: https://gitdiagram.com/triangletech/maplesyrup
- Repository: https://github.com/triangletech/maplesyrup

## Overview

##### Project Type & Purpose
- MapleSyrup is a client emulator for MapleStory, meaning it replicates the behavior of the MapleStory client. It is built in C# and is modularized into various domains like Actors, Avatar, GUI, Network, Map, etc.
- The README indicates that the project is complex and in transition, so flexibility and clear modular boundaries are key when drawing the architecture.

##### File Structure & Identify Main Components
- The entire logic is placed under the “Client” directory. This directory is broken down into submodules, each representing a distinct aspect of a game client:
- Actors: Contains various classes (ActorCompare.cs, ActorLayer.cs, ActorType.cs, IActor.cs) handling game entities/components.
- Avatar: Manages player-related data such as looks, state, stats, and parts. This module suggests dynamics for character customization.
- GUI: Organized into further subdirectories (Components, Buttons, Panels, Enums) that indicate a comprehensive, component-based UI system.
- Managers: Includes multiple managers such as ActorManager, InputManager, NetworkManager, UIManager, WorldManager, etc. They serve as the functional brains to manage respective domains.
- Deals with the game environment (Background, MapLoader, MapObject).
- NX: Likely handling MapleStory-specific file formats or configurations (NxFile, NxNode, NxReader).
- Net: Contains classes for network communications (InPacket, OutPacket, PacketProcessor, RequestOps, ResponseOps), suggesting a packet-based, request/response flow.
- Scene: Manages game state transitions like Login, WorldInfo, WorldState and provides an interface with IWorld.
- Additionally, the “Client” directory contains configuration and startup files (e.g., AppConfig.cs, Application.cs, Program.cs) which indicate the initialization and global behavior of the application.

##### Relationships & Interactions
- Application Flow: The execution starts in Program.cs, which initiates the Client/Application and loads configurations via AppConfig.cs.
- Managers are central to the architecture; for instance:
- The ActorManager handles interactions with the Actors module.
- The UIManager interacts with the GUI components to render game visuals.
- The NetworkManager binding with Net facilitates the communication of In/Out packets and coordinates with the PacketProcessor.
- The WorldManager likely interacts with both the Map module (for environment rendering) and the Scene module (for game state management).
- UI components (Buttons, Panels, Labels, etc.) react to both input (via InputManager) and network or state changes (mediated by UIManager, Scene updates).
- The NX module is used for specialized reading/parsing (NxReader) of resource files, suggestions that it feeds into rendering or data loading by other modules.

##### Architectural Patterns & Design Principles
- There is a clear separation of concerns with domain-specific directories (Actors, Avatar, GUI, etc.) suggesting a component-based and possibly an MVC-like pattern.
- Managers act as coordinators and service locators, potentially following the Dependency Injection and Service Locator patterns.
- The use of discrete modules for networking, UI, and domain logic speaks to good modularization and the single-responsibility principle.
- Given the heavy use of interfaces (IActor, IUIComponent, IManager, IUIPanel, IWorld) the design emphasizes abstraction and extensibility.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Core Application
    subgraph "Core Application"
        Prog["Program.cs"]:::core
        App["Application.cs"]:::core
        Conf["AppConfig.cs"]:::core
    end

    %% Managers Module
    subgraph "Managers Module"
        ServiceLocator["ServiceLocator"]:::manager
        AManager["ActorManager"]:::manager
        IManager["InputManager"]:::manager
        NManager["NetworkManager"]:::manager
        NxManager["NxManager"]:::manager
        UIManager["UIManager"]:::manager
        WManager["WorldManager"]:::manager
    end

    %% Domain Modules
    subgraph "Domain Modules"
        Actors["Actors Module"]:::domain
        Avatar["Avatar Module"]:::domain
        GUI["GUI Module"]:::domain
        MapMod["Map Module"]:::domain
        SceneMod["Scene Module"]:::domain
    end

    %% Communication Modules
    subgraph "Communication Modules"
        NetMod["Net Module"]:::communication
    end

    %% Resource Module
    subgraph "Resource Module"
        NXMod["NX Module"]:::communication
    end

    %% Containerization & Build Configuration
    subgraph "Container & Build Config"
        Docker["Dockerfile & .dockerignore"]:::external
        ConfigFiles["Configuration Files"]:::external
    end

    %% Relationships between Core Application and Managers
    Prog -->|"calls"| App
    App -->|"loads"| Conf
    App -->|"initializes"| ServiceLocator

    %% Service Locator provides managers
    ServiceLocator -->|"provides"| AManager
    ServiceLocator -->|"provides"| IManager
    ServiceLocator -->|"provides"| NManager
    ServiceLocator -->|"provides"| NxManager
    ServiceLocator -->|"provides"| UIManager
    ServiceLocator -->|"provides"| WManager

    %% Managers interactions with Domain and Communication modules
    AManager -->|"manages"| Actors
    UIManager -->|"updates"| GUI
    GUI -->|"sendsInput"| IManager
    IManager -->|"affects"| Actors
    NManager -->|"handles"| NetMod
    WManager -->|"integrates"| MapMod
    WManager -->|"integrates"| SceneMod
    NxManager -->|"parses"| NXMod
    NXMod -->|"supplies"| Avatar
    NXMod -->|"supplies"| GUI

    %% Core Application Configuration with external build files
    App -->|"configuredWith"| Docker
    App -->|"configuredWith"| ConfigFiles

    %% Styles
    classDef core fill:#FFA,stroke:#333,stroke-width:2px;
    classDef domain fill:#AAF,stroke:#333,stroke-width:2px;
    classDef manager fill:#FBA,stroke:#333,stroke-width:2px;
    classDef communication fill:#AFA,stroke:#333,stroke-width:2px;
    classDef external fill:#DDD,stroke:#333,stroke-width:2px;

    %% Click Events
    click Prog "https://github.com/triangletech/maplesyrup/blob/master/Client/Program.cs"
    click App "https://github.com/triangletech/maplesyrup/blob/master/Client/Application.cs"
    click Conf "https://github.com/triangletech/maplesyrup/blob/master/Client/AppConfig.cs"
    click Actors "https://github.com/triangletech/maplesyrup/tree/master/Client/Actors"
    click Avatar "https://github.com/triangletech/maplesyrup/tree/master/Client/Avatar"
    click GUI "https://github.com/triangletech/maplesyrup/tree/master/Client/Gui"
    click ServiceLocator "https://github.com/triangletech/maplesyrup/tree/master/Client/Managers"
    click MapMod "https://github.com/triangletech/maplesyrup/tree/master/Client/Map"
    click NXMod "https://github.com/triangletech/maplesyrup/tree/master/Client/NX"
    click NetMod "https://github.com/triangletech/maplesyrup/tree/master/Client/Net"
    click SceneMod "https://github.com/triangletech/maplesyrup/tree/master/Client/Scene"
    click Docker "https://github.com/triangletech/maplesyrup/tree/master/Client/Dockerfile"
    click ConfigFiles "https://github.com/triangletech/maplesyrup/blob/master/MapleSyrup.sln"
```
