# ao-libre/ao-cliente architecture

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

- Interactive diagram: https://gitdiagram.com/ao-libre/ao-cliente
- Repository: https://github.com/ao-libre/ao-cliente

## Overview

##### Main Components
- Game Client Core – This is the heart of the application. It includes the “CODIGO” folder with subdirectories such as:
- Aplicacion: general game logic (e.g., Application.bas, ProtocolCmdParse.bas, etc.).
- Motor: contains the game engine modules that handle rendering, particles, lighting, drawing, and utilities (e.g., clsBatch, clsTextureManager, mDx8_Engine.bas).
- Red: the networking layer with protocols, TCP, socket management, and communication functions.
- IO: handles file input/output (JSON parsing, INI management, byte buffering).
- User Interface Layer – Located in “CODIGO/Formularios” and “CODIGO/Dialogos” as well as in “uControls”. This layer manages all forms (VB forms and FRX files) that comprise the client’s GUI (menus, chat windows, character creation, settings, etc.).
- Asset Management – Several top-level folders (AUDIO, Graficos, Mapas, Lenguajes, INIT) contain resources:
- AUDIO holds various audio assets (MIDI, MP3, WAV).
- Graficos includes assets for buttons, interfaces, skins, and maps for UI elements.
- Mapas has the definition files for game maps.
- INIT and Lenguajes supply configuration data, language strings, and initialization parameters (e.g., Config.ini, messages.txt, etc.).
- Update and Integration Components – As described in the README:
- The autoupdate mechanism compares the current version (from INIT/Config.ini) with the latest release from Github. That process then launches the external updater executable (ao-autoupdate). There’s also linkage to online logs and version checking.
- External/Supporting Tools – Additional utilities like AdminLibSetup.exe, GenerarFK.exe, and some scripts for git or encoding fixes.

##### Relationships and Interactions
- The Core Engine is further divided into modules: the Game Engine (Motor), the Networking layer (Red), and the IO functions.
- Assets (Audio, Graphics, Maps, etc.) interface with the engine and forms for rendering and gameplay feedback.
- The update mechanism interacts with the core on startup to check for version discrepancies and launch the updater.
- From UI to Core Engine, and from Core Engine to assets.
- From Networking module to external servers.
- From the autoupdate component back to the core application.

##### Architectural Patterns and Design Principles
- Separation of concerns: while the code is spread over many modules, each folder (e.g., Motor for rendering, Red for communication) has a distinct responsibility.
- Use of external configuration and version files (e.g., INIT/Config.ini) for update control.
- The update engine shows a pattern for self-updating architecture based on external endpoints (GitHub releases).

##### Detail Level
- The key is to be very explicit about the relationships – splitting the monolithic VB6 code into logical subsystems.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD

    subgraph "User Interface Layer"
        ui1["VB Forms"]:::ui
        ui2["Dialogs"]:::ui
        ui3["Custom Controls"]:::ui
    end

    subgraph "Game Client Core"
        core1["General Game Logic"]:::core
        core2["Game Engine (Motor)"]:::core
        core3["Networking (Red)"]:::core
        core4["Input/Output"]:::core
    end

    subgraph "Asset Management"
        asset1["Audio Resources"]:::asset
        asset2["Graphics/Interfaces"]:::asset
        asset3["Game Maps"]:::asset
        asset4["Configuration (INIT)"]:::asset
        asset5["Languages"]:::asset
    end

    subgraph "Update & Integration"
        update1["Version Config / Updater"]:::update
    end

    subgraph "External Services"
        external1["GitHub Releases"]:::external
    end

    subgraph "External/Supporting Tools"
        tool1["AdminLibSetup"]:::external
        tool2["GenerarFK"]:::external
    end

    %% Connections between layers
    ui1 -->|"sends_commands"| core1
    ui2 -->|"sends_commands"| core1
    ui3 -->|"sends_commands"| core1

    core2 -->|"renders_to"| asset2
    core2 -->|"plays_audio"| asset1
    core2 -->|"loads_maps"| asset3

    core4 -->|"reads_config"| asset4
    core4 -->|"loads_languages"| asset5

    core3 -->|"connects_to"| external1

    update1 -->|"checks_version"| core1

    ui1 -->|"triggers"| tool1
    ui1 -->|"triggers"| tool2

    %% Styling classes
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef core fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef asset fill:#ABEBC6,stroke:#1D8348,stroke-width:2px;
    classDef update fill:#F5CBA7,stroke:#B03A2E,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;

    %% Click Events for User Interface Layer
    click ui1 "https://github.com/ao-libre/ao-cliente/tree/master/CODIGO/Formularios"
    click ui2 "https://github.com/ao-libre/ao-cliente/tree/master/CODIGO/Dialogos"
    click ui3 "https://github.com/ao-libre/ao-cliente/tree/master/CODIGO/uControls"

    %% Click Events for Game Client Core
    click core1 "https://github.com/ao-libre/ao-cliente/tree/master/CODIGO/Aplicacion"
    click core2 "https://github.com/ao-libre/ao-cliente/tree/master/CODIGO/Motor"
    click core3 "https://github.com/ao-libre/ao-cliente/tree/master/CODIGO/Red"
    click core4 "https://github.com/ao-libre/ao-cliente/tree/master/CODIGO/IO"

    %% Click Events for Asset Management
    click asset1 "https://github.com/ao-libre/ao-cliente/tree/master/AUDIO"
    click asset2 "https://github.com/ao-libre/ao-cliente/tree/master/Graficos"
    click asset3 "https://github.com/ao-libre/ao-cliente/tree/master/Mapas"
    click asset4 "https://github.com/ao-libre/ao-cliente/tree/master/INIT"
    click asset5 "https://github.com/ao-libre/ao-cliente/tree/master/Lenguajes"

    %% Click Event for Update & Integration
    click update1 "https://github.com/ao-libre/ao-cliente/blob/master/INIT/Config.ini"

    %% Click Events for External/Supporting Tools
    click tool1 "https://github.com/ao-libre/ao-cliente/blob/master/AdminLibSetup.exe"
    click tool2 "https://github.com/ao-libre/ao-cliente/blob/master/GenerarFK.exe"
```
