# 7life/pyxbdo architecture

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

## Overview

##### Project Type and Purpose
- PyxBDO appears to be an automation/botting framework for Black Desert Online (as hinted by “BDO” in the name). Its purpose is to provide a set of Lua-based bots (for combat, fishing, grinding, pet feeding, etc.) that interact with the game.
- The repository includes both scripts that handle specific game activities (CombatAssist, Consumables, Fisher, Grinder, etc.) and a set of shared libraries and common states that encapsulate core functionalities (FSM, navigation, timers, JSON handling, and more).

##### Analyzing the File Structure
- Top-Level Layout:
- Files like .gitignore and README.md are standard.
- Directories such as data, lua_dumps, and lua_mods likely contain configuration files, dumped game data, and mods respectively.
- The main action is in the scripts directory, which houses individual bot modules and supporting libraries.
- Bot Modules:
- Directories such as CombatAssist, Consumables, Fisher, Grinder, LuaConsole, PacketSniffer, and PetFeeder each contain their own main script, configuration data (e.g., Settings.lua/json, script.def files), and often custom GUI components.
- Shared Components:
- The commonstates directory (here with a “v1” version) provides common functionalities (inventory management, navigation, repairing, etc.) to be used across various bots.
- The lib* directories (libbdo, libcombat, libconsumables, libfsm, libjson, libscout, libtable, libtimers) encapsulate reusable functionality such as state machine logic, game-specific helper functions, timer management, and data formatting/parsing.

##### Reading the README
- The README is brief, identifying the repository as “Official repository for Pyx.BDO”. Although there is no deep architecture explanation, the repository name and structure imply that it is a framework for interacting with the game through various automated scripts and utilities.

- Main Components to Include:
- Bot Modules: Each bot (CombatAssist, Consumables, Fisher, Grinder, LuaConsole, PacketSniffer, PetFeeder) should be represented as discrete components. For each, include subcomponents such as its Main script, GUI elements, configuration files, and any script definition files.
- Shared Libraries: Represent the lib* directories (e.g., libbdo, libcombat, libfsm, etc.) as a separate layer that all bots leverage. This layer encapsulates common utilities (navigation, timers, JSON parsing, combat assistance) that enable code reuse and consistency.
- Common States: Include a component for commonstates which provides shared state-driven logic like managing inventory, vendor interactions, and in-game actions.
- Data and Configuration: The data, lua_dumps, and lua_mods directories should be depicted as the data/configuration layer that supports the bots with game-specific settings and runtime data.
- Relationships and Interactions:
- Data flow from the configuration/data layer to the bots, possibly indicating that settings in JSON or Lua files are loaded during execution.
- For components like LuaConsole and PacketSniffer, indicate their roles in debugging/monitoring or intercepting game communications, and how they might integrate with the core bot functionalities.
- Architectural Patterns and Design Principles:
- Modularity and separation of concerns; each bot module is self-contained yet leverages common libraries.
- Use of state machines (via libfsm) for managing in-game states and transitions, which is a key design pattern here.
- Extensibility—the design allows adding new game automations/bots by following the established module and common library patterns.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data and Configuration Layer
    subgraph "Data and Configuration"
        Data["\"Data Files\""]:::data
        luaDumps["\"Lua Dumps\""]:::data
        luaMods["\"Lua Mods\""]:::data
    end

    %% Shared Libraries Layer
    subgraph "Shared Libraries"
        libBDO["\"libbdo - BDO Helpers\""]:::lib
        libCombat["\"libcombat - Combat Utilities\""]:::lib
        libConsumables["\"libconsumables - Consumables Utilities\""]:::lib
        libFSM["\"libfsm - FSM State Management\""]:::lib
        libJSON["\"libjson - JSON Parsing\""]:::lib
        libScout["\"libscout - Scout Tools\""]:::lib
        libTable["\"libtable - Table Operations\""]:::lib
        libTimers["\"libtimers - Timers\""]:::lib
    end

    %% Common States Layer
    subgraph "Common States"
        commonStates["\"commonstates/v1 - Reusable Game States\""]:::state
    end

    %% Bot Modules Layer
    subgraph "Bot Modules"
        ca["\"CombatAssist Bot\""]:::bot
        cons["\"Consumables Bot\""]:::bot
        fisher["\"Fisher Bot\""]:::bot
        grinder["\"Grinder Bot\""]:::bot
        pet["\"PetFeeder Bot\""]:::bot
    end

    %% Debug/Monitoring Tools Layer
    subgraph "Debug/Monitoring Tools"
        luaConsole["\"LuaConsole - Debug/Interaction\""]:::debug
        packet["\"PacketSniffer - Monitoring\""]:::debug
    end

    %% Data/Configuration feeds Bot Modules
    Data -->|"configData"| ca
    Data -->|"configData"| cons
    Data -->|"configData"| fisher
    Data -->|"configData"| grinder
    Data -->|"configData"| pet

    luaDumps -->|"initData"| ca
    luaDumps -->|"initData"| cons
    luaDumps -->|"initData"| fisher
    luaDumps -->|"initData"| grinder
    luaDumps -->|"initData"| pet

    luaMods -->|"modConfigs"| ca
    luaMods -->|"modConfigs"| cons
    luaMods -->|"modConfigs"| fisher
    luaMods -->|"modConfigs"| grinder
    luaMods -->|"modConfigs"| pet

    %% Bot Modules interact with Shared Libraries and Common States
    ca -->|"uses"| libBDO
    ca -->|"calls"| libCombat
    ca -->|"executes"| libFSM
    ca -->|"accesses"| commonStates

    cons -->|"uses"| libConsumables
    cons -->|"calls"| libFSM
    cons -->|"accesses"| commonStates

    fisher -->|"uses"| libBDO
    fisher -->|"calls"| libJSON
    fisher -->|"accesses"| commonStates

    grinder -->|"uses"| libCombat
    grinder -->|"calls"| libTimers
    grinder -->|"accesses"| commonStates

    pet -->|"uses"| libBDO
    pet -->|"calls"| libTable
    pet -->|"accesses"| commonStates

    %% Debug/Monitoring Tools interact with Bot Modules
    luaConsole -->|"interfacesWith"| ca
    luaConsole -->|"interfacesWith"| cons
    luaConsole -->|"interfacesWith"| fisher
    luaConsole -->|"interfacesWith"| grinder
    luaConsole -->|"interfacesWith"| pet

    packet -->|"monitors"| ca
    packet -->|"monitors"| cons
    packet -->|"monitors"| fisher
    packet -->|"monitors"| grinder
    packet -->|"monitors"| pet

    %% Internal Shared Libraries Relationships
    libBDO -->|"integratesWith"| libFSM
    libCombat -->|"integratesWith"| libFSM
    libJSON -->|"integratesWith"| libTable
    libScout -->|"assists"| libBDO

    %% Click Events for Components
    click ca "https://github.com/7life/pyxbdo/tree/master/scripts/CombatAssist"
    click cons "https://github.com/7life/pyxbdo/tree/master/scripts/Consumables"
    click fisher "https://github.com/7life/pyxbdo/tree/master/scripts/Fisher"
    click grinder "https://github.com/7life/pyxbdo/tree/master/scripts/Grinder"
    click pet "https://github.com/7life/pyxbdo/tree/master/scripts/PetFeeder"
    click luaConsole "https://github.com/7life/pyxbdo/tree/master/scripts/LuaConsole"
    click packet "https://github.com/7life/pyxbdo/tree/master/scripts/PacketSniffer"
    click libBDO "https://github.com/7life/pyxbdo/tree/master/scripts/libbdo"
    click libCombat "https://github.com/7life/pyxbdo/tree/master/scripts/libcombat"
    click libConsumables "https://github.com/7life/pyxbdo/tree/master/scripts/libconsumables"
    click libFSM "https://github.com/7life/pyxbdo/tree/master/scripts/libfsm"
    click libJSON "https://github.com/7life/pyxbdo/tree/master/scripts/libjson"
    click libScout "https://github.com/7life/pyxbdo/tree/master/scripts/libscout"
    click libTable "https://github.com/7life/pyxbdo/tree/master/scripts/libtable"
    click libTimers "https://github.com/7life/pyxbdo/tree/master/scripts/libtimers"
    click commonStates "https://github.com/7life/pyxbdo/tree/master/scripts/commonstates/v1"
    click Data "https://github.com/7life/pyxbdo/tree/master/data"
    click luaDumps "https://github.com/7life/pyxbdo/tree/master/lua_dumps"
    click luaMods "https://github.com/7life/pyxbdo/tree/master/lua_mods"

    %% Styles
    classDef bot fill:#f9d423,stroke:#333,stroke-width:2px;
    classDef lib fill:#42a5f5,stroke:#333,stroke-width:2px;
    classDef state fill:#66bb6a,stroke:#333,stroke-width:2px;
    classDef data fill:#ffb74d,stroke:#333,stroke-width:2px;
    classDef debug fill:#ab47bc,stroke:#333,stroke-width:2px;
```
