# torhal/frenemy architecture

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

- Interactive diagram: https://gitdiagram.com/torhal/frenemy
- Repository: https://github.com/torhal/frenemy

## Overview

##### Main Components

A. Core Module Layer:
- Main "Frenemy.lua" as the core controller
- "DataObject.lua" as it appears to be a crucial data management component
- "_Main.lua" files as entry points for each major module

B. Feature Modules:
1. TooltipHandler Module:
- Specialized handling for Battle.net, Guild, and WoW Friends
- SpecializedCells submodule
- To the Render.lua component

2. Common Module:
- MapHandler for zone management
- Sorting component for list management
- Debugger for development support

3. Preferences Module:
- DataObject and Tooltip components
- Configuration management flow

C. Localization Layer:
- Supported languages
- Connection to other modules

**[Core Layer]**
- ↓
**[Feature Modules] ← → [Localization Layer]**
- ↓
**[WoW API Integration]**

##### Specific Design Elements

- Use rectangles for main modules
- Use rounded rectangles for submodules
- Use diamonds for data objects
- Blue: Core components
- Green: Feature modules
- Yellow: Data management
- Purple: UI components
- Gray: External interfaces (WoW API)

##### Data Flow Representation

Following key interactions:
- Data flow from WoW API to the core module
- Information processing through the TooltipHandler
- User preference management flow
- Localization integration points

##### Important Architectural Patterns to Highlight

- Module Pattern: Show how each major component is self-contained
- Observer Pattern: For tooltip and UI updates
- Command Pattern: For handling user interactions
- Facade Pattern: For WoW API interactions

##### Technical Details

- XML embedding system (reference embeds.xml)
- Manifest files relationships
- Type definitions from @types directory
- Configuration management through .pkgmeta

- Line styles
- Abbreviations used
- Module relationships

This will create a comprehensive visualization of how Frenemy works as a WoW addon while maintaining clarity about its architecture and component interactions.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Layer
    subgraph Core
        FC[Frenemy Controller]:::core
        DO[Data Object]:::data
    end

    %% Feature Modules Layer
    subgraph Features
        subgraph TooltipHandler
            TM["TooltipHandler Main"]:::module
            BN["Battle.net Handler"]:::handler
            GH["Guild Handler"]:::handler
            WF["WoW Friends Handler"]:::handler
            RD["Render"]:::ui
            SC["Specialized Cells"]:::ui
        end

        subgraph Common
            CM["Common Main"]:::module
            MH["Map Handler"]:::handler
            ST["Sorting"]:::util
            DB["Debugger"]:::util
        end

        subgraph Preferences
            PM["Preferences Main"]:::module
            PD["Preferences Data"]:::data
            PT["Tooltip Preferences"]:::config
        end
    end

    %% Localization Layer
    subgraph Localization
        LM["Locales Manifest"]:::config
        EN["English (US)"]:::locale
        DEV["Development Locale"]:::locale
    end

    %% External Layer
    subgraph External
        WA["WoW API"]:::external
        ED["External Dependencies"]:::external
        TC["TOC Configuration"]:::config
        TD["Type Definitions"]:::util
    end

    %% Relationships
    FC --> DO
    FC --> TM
    FC --> CM
    FC --> PM

    TM --> |manages| BN
    TM --> |manages| GH
    TM --> |manages| WF
    TM --> |uses| RD
    RD --> |uses| SC

    CM --> |uses| MH
    CM --> |uses| ST
    CM --> |uses| DB

    PM --> |manages| PD
    PM --> |manages| PT

    LM --> EN
    LM --> DEV

    WA --> FC
    ED --> FC
    TC --> FC
    TD --> FC

    %% Component Mappings
    click FC "https://github.com/Torhal/Frenemy/blob/main/Frenemy.lua"
    click DO "https://github.com/Torhal/Frenemy/blob/main/DataObject.lua"
    click TM "https://github.com/Torhal/Frenemy/blob/main/TooltipHandler/_Main.lua"
    click BN "https://github.com/Torhal/Frenemy/blob/main/TooltipHandler/BattleNet.lua"
    click GH "https://github.com/Torhal/Frenemy/blob/main/TooltipHandler/Guild.lua"
    click WF "https://github.com/Torhal/Frenemy/blob/main/TooltipHandler/WoWFriends.lua"
    click RD "https://github.com/Torhal/Frenemy/blob/main/TooltipHandler/Render.lua"
    click SC "https://github.com/Torhal/Frenemy/blob/main/TooltipHandler/SpecializedCells/SectionHeaderCell.lua"
    click CM "https://github.com/Torhal/Frenemy/blob/main/Common/_Main.lua"
    click MH "https://github.com/Torhal/Frenemy/blob/main/Common/MapHandler.lua"
    click ST "https://github.com/Torhal/Frenemy/blob/main/Common/Sorting.lua"
    click DB "https://github.com/Torhal/Frenemy/blob/main/Common/Debugger.lua"
    click PM "https://github.com/Torhal/Frenemy/blob/main/Preferences/_Main.lua"
    click PD "https://github.com/Torhal/Frenemy/blob/main/Preferences/DataObject.lua"
    click PT "https://github.com/Torhal/Frenemy/blob/main/Preferences/Tooltip.lua"
    click LM "https://github.com/Torhal/Frenemy/blob/main/Locales/Manifest.xml"
    click EN "https://github.com/Torhal/Frenemy/blob/main/Locales/enUS.lua"
    click DEV "https://github.com/Torhal/Frenemy/blob/main/Locales/devel-enUS.lua"
    click TD "https://github.com/Torhal/Frenemy/blob/main/@types/Utility.lua"
    click TC "https://github.com/Torhal/Frenemy/blob/main/Frenemy.toc"
    click ED "https://github.com/Torhal/Frenemy/blob/main/embeds.xml"

    %% Styles
    classDef core fill:#2374ab
    classDef data fill:#ffd400
    classDef module fill:#48a9a6
    classDef handler fill:#4ea5d9
    classDef ui fill:#9370db
    classDef util fill:#a4a9ad
    classDef config fill:#d4b483
    classDef locale fill:#c1666b
    classDef external fill:#808080
```
