# unknownworlds/decoda architecture

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

- Interactive diagram: https://gitdiagram.com/unknownworlds/decoda
- Repository: https://github.com/unknownworlds/decoda

## Overview

##### Main Components

a. Frontend (User Interface Layer)
- Located in the “src/Frontend” directory.
- Implements the graphical user interface (e.g., MainFrame, dialogs for breakpoints, project explorer, file change watchers, settings panels, etc.).
- Built using wxWidgets and wxScintilla for the code editor component.

b. Debug / Injection Module (Debugger Core)
- Found in “src/LuaInject”.
- Responsible for injecting debugging hooks (via Lua injection) into the target process and interfacing with the debug backend.
- Handles low-level operations like hooking functions, managing debug events, and communicating with the rest of the system.

c. Shared Utilities
- Located in “src/Shared”.
- Contains common modules such as Channels, CriticalSection objects, synchronization primitives, and protocol definitions.
- Acts as the foundation for communication between components and for shared low-level functionality.

d. External Libraries and Dependencies
- Third-party libraries included in the “libs” directory:
– wxWidgets and wxScintilla: Provide the UI and code editor support.
– LuaPlus: Facilitates Lua language integration.
– tinyxml: Likely used for configuration or project file parsing.
– dbghelp: Helps with debugging related tasks.

##### Architectural Patterns and Design Principles

- Modularity: Clearly show how the system is partitioned into independent modules that interact via well-defined interfaces.
- Separation of Concerns: Separate UI (Frontend) from Debugging internals (LuaInject) and from common services (Shared).
- Dependency Injection / Layering: Indicate that the Shared utilities provide services to both the UI and Debug components. External libraries are “plugged” into their respective layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Modules
    subgraph "Core Modules"
        FE["Frontend\n(wxWidgets based UI)"]:::internal
        LI["LuaInject\n(Debug/Hooking Module)"]:::internal
        SU["Shared Utilities\n(Sync & Protocols)"]:::internal
    end

    %% External Dependencies
    subgraph "External Dependencies"
        WX["wxWidgets"]:::external
        WS["wxScintilla"]:::external
        LP["LuaPlus"]:::external
        TX["tinyxml"]:::external
        DBG["dbghelp"]:::external
    end

    %% Build/Deployment
    subgraph "Build/Deployment"
        BS["Build System (premake4)"]:::build
        PE["Premake Executable"]:::build
        IS["Install Scripts (NSIS Installer)"]:::build
    end

    %% Inter-module interactions
    FE -->|"DebugCommands/Event"| LI
    LI -->|"DebugOutput/Event"| FE
    LI <--> SU

    %% External Dependencies to Modules
    WX -->|"UI_Support"| FE
    WS -->|"Editor_Support"| FE
    TX -->|"Config_Parsing"| FE
    LP -->|"Lua_Hooks"| LI
    DBG -->|"Debug_Support"| LI

    %% Build/Deployment flows
    BS -->|"Generates_VS_Projects"| FE
    BS -->|"Generates_VS_Projects"| LI
    BS -->|"Generates_VS_Projects"| SU
    BS --> PE
    IS --- BS

    %% Class Definitions
    classDef internal fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef external fill:#FFE082,stroke:#FF8F00,stroke-width:2px;
    classDef build fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;

    %% Click Events
    click FE "https://github.com/unknownworlds/decoda/tree/master/src/Frontend"
    click LI "https://github.com/unknownworlds/decoda/tree/master/src/LuaInject"
    click SU "https://github.com/unknownworlds/decoda/tree/master/src/Shared"
    click WX "https://github.com/unknownworlds/decoda/tree/master/libs/wxWidgets"
    click WS "https://github.com/unknownworlds/decoda/tree/master/libs/wxScintilla"
    click LP "https://github.com/unknownworlds/decoda/tree/master/libs/LuaPlus"
    click TX "https://github.com/unknownworlds/decoda/tree/master/libs/tinyxml"
    click DBG "https://github.com/unknownworlds/decoda/tree/master/libs/dbghelp"
    click BS "https://github.com/unknownworlds/decoda/blob/master/premake4.lua"
    click PE "https://github.com/unknownworlds/decoda/blob/master/utils/premake/premake4.exe"
    click IS "https://github.com/unknownworlds/decoda/blob/master/install/Decoda.nsi"
```
