# hobr/multiplayer-v architecture

> Architecture diagram of the GitHub repository hobr/multiplayer-v, 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/hobr/multiplayer-v
- Repository: https://github.com/hobr/multiplayer-v

## Overview

##### Main Components
- Client Component – In the “Client” directory you see various subdirectories and files handling game-specific logic (like Entities such as Player, Vehicle, Ped; GTA-related modules; UI; Network management; Memory; Scripts; and various utility functions). The client side interacts with the GTA V environment using ScriptHookV (found under Libs/ScriptHookV) and integrates with the game engine.
- Shared Component – The “Shared” directory contains common definitions like network message types, enums, structures, an octree (for spatial queries or entity management), and shared utilities. This module is used by both client and server to agree on network protocols and data structures.
- Third-Party Libraries – External libraries like ENet (in Libs/ENet) for reliable UDP networking, glm (a math library for vector math), and inih (configuration parser) play a significant role. ScriptHookV is also utilized to interface with GTA V on the client side.

##### Relationships and Interactions
- The project build configuration uses CMake and Visual Studio (as shown in the file tree and README) but that is primarily relevant for development rather than runtime, so you may show a “Build/Development Tools” auxiliary block.

##### Architectural Patterns and Design Principles
- The separation of Client and Server, along with a Shared module, suggests a layered or component-based architecture. This separation aids in the clear demarcation of responsibilities between game-side logic, server-side world management, and common network abstractions.
- The integration of external libraries (ENet for networking, ScriptHookV for interfacing with GTA V, glm for math operations, inih for configuration) indicates an architecture that reuses specialized modules to keep the core code lean.
- Modular design where the networking aspects of both the Client and Server take advantage of the Shared data structures for consistency.

##### Specific Elements

- The clear segmentation between Client, Server, and Shared modules.
- How the Client integrates with GTA through ScriptHookV and communicates with the server.
- The use of third-party libraries such as ENet for networking.
- The overall modular and layered design of the project.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Custom Modules Subgraphs
    subgraph "Client Module"
        clientEntities("Entities") 
        clientGTA("GTA (UI, Scripts, Memory)")
        clientNetwork("Network")
        clientSystem("System")
        clientUtils("Utils")
    end

    subgraph "Server Module"
        serverEntities("Entities")
        serverWorld("World Management")
        serverNetwork("Network")
        serverGameServer("Game Server")
    end

    subgraph "Shared Module"
        sharedEnums("Enums")
        sharedNetwork("Network")
        sharedOctree("Octree / Data Structures")
    end

    %% Third-Party Libraries
    extENet("ENet Library")
    extScriptHookV("ScriptHookV Library")
    extGLM("GLM Library")
    extINIH("inih Library")

    %% Build and Development Tools
    buildTools("Build Tools (CMake, Visual Studio)")

    %% Connections between Modules
    clientNetwork -->|"Network-using-ENet"| serverNetwork
    serverNetwork -->|"Network-using-ENet"| clientNetwork

    clientNetwork -->|"SharedProtocol"| sharedNetwork
    serverNetwork -->|"SharedProtocol"| sharedNetwork

    %% Client to GTA Integration using ScriptHookV
    clientGTA -->|"GTAIntegration"| extScriptHookV

    %% Example usage of external libraries by Custom Modules
    clientNetwork -->|"Uses"| extENet
    serverNetwork -->|"Uses"| extENet
    clientEntities -->|"MathOps"| extGLM
    serverGameServer -->|"ConfigParsing"| extINIH

    %% Linking Build Tools (development context)
    clientSystem -->|"BuiltWith"| buildTools
    serverGameServer -->|"BuiltWith"| buildTools

    %% Assign Classes for Styling
    class clientEntities,clientGTA,clientNetwork,clientSystem,clientUtils,serverEntities,serverWorld,serverNetwork,serverGameServer,sharedEnums,sharedNetwork,sharedOctree module
    class extENet,extScriptHookV,extGLM,extINIH external
    class buildTools build

    %% Click Events for Component Mapping
    click clientEntities "https://github.com/hobr/multiplayer-v/tree/main/Client/Entities"
    click clientGTA "https://github.com/hobr/multiplayer-v/tree/main/Client/GTA"
    click clientNetwork "https://github.com/hobr/multiplayer-v/tree/main/Client/Network"
    click clientSystem "https://github.com/hobr/multiplayer-v/tree/main/Client/System"
    click clientUtils "https://github.com/hobr/multiplayer-v/tree/main/Client/Utils"

    click serverEntities "https://github.com/hobr/multiplayer-v/tree/main/Server/src/Entities"
    click serverWorld "https://github.com/hobr/multiplayer-v/tree/main/Server/src/World"
    click serverNetwork "https://github.com/hobr/multiplayer-v/tree/main/Server/src/Network"
    click serverGameServer "https://github.com/hobr/multiplayer-v/tree/main/Server/src/GameServer"

    click sharedEnums "https://github.com/hobr/multiplayer-v/tree/main/Shared/Enums"
    click sharedNetwork "https://github.com/hobr/multiplayer-v/tree/main/Shared/Network"
    click sharedOctree "https://github.com/hobr/multiplayer-v/blob/main/Shared/Octree.h"

    click extENet "https://github.com/hobr/multiplayer-v/tree/main/Libs/ENet"
    click extScriptHookV "https://github.com/hobr/multiplayer-v/tree/main/Libs/ScriptHookV"
    click extGLM "https://github.com/hobr/multiplayer-v/tree/main/Libs/glm"
    click extINIH "https://github.com/hobr/multiplayer-v/tree/main/Libs/inih"

    %% Styles for Classes
    classDef module fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef external fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef build fill:#90EE90,stroke:#000,stroke-width:2px;
```
