# multitheftauto/mtasa-blue architecture

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

- Interactive diagram: https://gitdiagram.com/multitheftauto/mtasa-blue
- Repository: https://github.com/multitheftauto/mtasa-blue

## Overview

##### Main Components
a. Client Subsystem – Contains multiple modules (core, GUI, launcher, loader, mods such as deathmatch, etc.) that perform game engine hooking, implement the GUI extensions, handle resource loading, and provide Lua scripting integration.
b. Server Subsystem – Consists of core server functions, specialized modules (like deathmatch mods), networking components, database connectors (e.g., MySQL), and command handling modules.
c. Shared Libraries and Modules – Includes common code (the “Shared” directory), SDK interfaces, XML handling, resource management code, and public SDKs used by both client and server.
d. Build and Utility Tools – These are the scripts, premake configurations, Dockerfiles, localization tools, installer scripts, and other utilities which manage builds, cross-compiling, and language/localization tasks.

##### Relationships and Interactions
b. Shared modules as a core layer that both the client and server depend on for common functionality (e.g., XML parsing, networking utilities, and SDK interfaces).
c. How specialized mods (especially “mods/deathmatch”) extend both client and server functionalities.
d. Resource system/lua scripting layer where game content (scripts, images, sounds, models) is bundled as “resources” and exchanged between client and server.
e. Integration via build tools and deployment pipelines (e.g., Docker build environments, premake scripts, etc.) indicating external dependencies like DirectX SDK, MySQL libraries, and platform-specific configurations.

##### Architectural Patterns
a. Layered Architecture – Grouping components into layers (e.g., Hooking/Injection, Core/extensibility layer, Scripting, Networking, and Resource Management) helps convey separation of responsibilities.
b. Modular/Plug-in Design – Show how resources and mods can be loaded dynamically; clients and servers support extensibility through Lua scripting and dynamic module loading.
c. Client-Server Communication – Emphasize the network protocol interactions and data synchronization (packets, RPC calls) along with the use of shared protocols defined in the networking modules.

##### Specify Technologies, Frameworks, and Tools
a. C/C++ for core game modifications, hooking, and engine alterations.
b. Lua for scripting integration within both client and server.
c. Networking libraries and custom packet handling (depicted in the “net” folders) to maintain real-time synchronization.
d. Build systems like Premake5 scripts, Docker-based build environments, and platform-dependent configuration (Visual Studio on Windows, GNU/GCC on Linux).
e. Integration with engine-related assets (DirectX SDK, localization catalog generators, etc.).

##### Being Detailed
- Fine-grained internal dependencies. For example, within the client, detail how the “CEFLauncher”, “Loader”, and “GUI” work together to extend functionality.
- In the networking domain, map out the packet modules and RPC handling that reside in both client and server, evidencing the handshake and synchronization protocols.
- Build scripts (premake, Dockerfiles), configuration management, and language/localization generation are shown as external but critical components supporting the main architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Game Engine
    Engine["Game Engine"]:::engine

    %% Client Subsystem
    subgraph "Client Subsystem"
        C_Core["Core Module"]:::client
        C_GUI["GUI Module"]:::client
        C_Loader["Loader Module"]:::client
        C_Launcher["Launcher Module"]:::client
        C_Mods["Mods Module (Deathmatch)"]:::client
        C_Lua["Lua Scripting Integration"]:::client
    end

    %% Server Subsystem
    subgraph "Server Subsystem"
        S_Core["Core Server"]:::server
        S_DB["Database Connector (MySQL)"]:::server
        S_Launcher["Server Launcher"]:::server
        S_Mods["Mods Module (Deathmatch)"]:::server
        S_Net["Networking & RPC Handler"]:::server
        S_Command["Command Handler"]:::server
    end

    %% Shared Libraries and Modules
    subgraph "Shared Libraries and Modules"
        SH_SDK["SDK Interfaces"]:::shared
        SH_XML["XML Handling"]:::shared
        SH_PubSDK["Public SDKs"]:::shared
        SH_Resource["Resource Management"]:::shared
    end

    %% Build and Utility Tools
    subgraph "Build and Utility Tools"
        B_Premake["Premake5 Scripts"]:::tools
        B_Docker["Docker Build Configurations"]:::tools
        B_Utils["Utility Tools (Localization, Installer)"]:::tools
        B_Github["GitHub Workflows"]:::tools
    end

    %% Relationships

    %% Client -> Game Engine via Hooking and Injection
    C_Core -->|"Injection&Hooking"| Engine
    C_Launcher -->|"Launches"| Engine

    %% Client and Server Networking Synchronization
    C_Lua -->|"NetSync"| S_Net
    S_Net -->|"NetSync"| C_Lua

    %% Client Mods extend Server Mods (bidirectional)
    C_Mods -->|"Extends"| S_Mods
    S_Mods -->|"Extends"| C_Mods

    %% Shared libraries usage by Client and Server
    C_Core -->|"Uses"| SH_SDK
    C_Lua -->|"Uses"| SH_Resource
    S_Core -->|"Uses"| SH_XML
    S_Core -->|"Uses"| SH_SDK

    %% Build Tools supporting both Client and Server
    B_Premake -->|"Builds"| C_Core
    B_Premake -->|"Builds"| S_Core
    B_Docker -->|"Deploys"| Engine
    B_Github -->|"Triggers Builds"| B_Premake

    %% Client Loader loads resources managed in Shared
    C_Loader -->|"Loads"| SH_Resource

    %% Server Core uses Database and commands
    S_Core -->|"DB Operations"| S_DB
    S_Core --> S_Command

    %% Styles (Classes)
    classDef client fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef server fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef shared fill:#A9DFBF,stroke:#229954,stroke-width:2px;
    classDef tools fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef engine fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;

    %% Click Events for Component Mapping
    click C_Core "https://github.com/multitheftauto/mtasa-blue/tree/master/Client/"
    click S_Core "https://github.com/multitheftauto/mtasa-blue/tree/master/Server/"
    click SH_SDK "https://github.com/multitheftauto/mtasa-blue/tree/master/Shared/"
    click B_Premake "https://github.com/multitheftauto/mtasa-blue/blob/master/premake5.lua"
```
