# darrenthebozz/gge-bot architecture

> Architecture diagram of the GitHub repository darrenthebozz/gge-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/darrenthebozz/gge-bot
- Repository: https://github.com/darrenthebozz/gge-bot

## Overview

GGE-BOT is a multi-account Goodgame Empire automation bot with optional alliance Discord features. The main runtime manages accounts and bot workers; each worker connects to the game, exposes game commands and state, then loads automation plugins. Event-specific attack plugins share troop/commander logic, while separate plugins handle resource, timer, feast, skip and equipment tasks. Discord capabilities include slash commands and alliance notifications for chat, attacks, fortresses and aqua events; imageGen supplies attack previews. The source excerpts show the worker/game and plugin relationships, but do not expose all main.js routes or every Discord registration path, so uncertain connections are omitted.

Main entry points: [`protocols.js`](https://github.com/darrenthebozz/gge-bot/blob/main/protocols.js) (Game data and commands), [`main.js`](https://github.com/darrenthebozz/gge-bot/blob/main/main.js) (Account service), [`plugins/attack/sharedBarronAttackLogic.js`](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/attack/sharedBarronAttackLogic.js) (Attack strategy), [`ggeBot.js`](https://github.com/darrenthebozz/gge-bot/blob/main/ggeBot.js) (Bot worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_main["Account service<br/>[main.js]"]
  node_accounts[("Account database<br/>[main.js]")]
  node_worker["Bot worker<br/>[ggeBot.js]"]
  node_pluginloader["Plugin loader<br/>[index.js]"]
end

subgraph group_automation["Game automation"]
  node_plugins["Automation plugins"]
  node_attackevents["Event attacks"]
  node_attackshared["Attack strategy"]
  node_fortresslogic["Fortress attacks"]
  node_attacktools["Attack utilities<br/>[attack.js]"]
  node_commander["Commander allocator<br/>[commander.js]"]
  node_skip["Skip management<br/>[skips.js]"]
  node_miscplugins["Support plugins<br/>[misc.js]"]
end

subgraph group_discord["Discord features"]
  node_discordcore["Discord client<br/>[discord.js]"]
  node_slash["Slash commands<br/>[slashCommands.js]"]
  node_discordalerts["Alliance notifications"]
  node_imagegen["Attack previews<br/>[imageGen.js]"]
end

subgraph group_game["Game protocol"]
  node_protocols["Game data and commands<br/>[protocols.js]"]
  node_units["Unit metadata<br/>[units.js]"]
end

node_operator(("Bot operator"))
node_gamehost(("Goodgame Empire"))
node_discordservice(("Discord service"))

node_operator -->|"configures accounts"| node_main
node_main -->|"reads and updates"| node_accounts
node_main -->|"starts workers"| node_worker
node_main -->|"loads plugins"| node_pluginloader
node_pluginloader -->|"discovers plugins"| node_plugins
node_worker -->|"connects by WebSocket"| node_gamehost
node_worker -->|"provides game state"| node_protocols
node_attackevents -->|"uses shared logic"| node_attackshared
node_attackevents -->|"uses fortress logic"| node_fortresslogic
node_attackshared -->|"uses attack utilities"| node_attacktools
node_fortresslogic -->|"uses attack utilities"| node_attacktools
node_attackshared -->|"spends skips"| node_skip
node_attackevents -->|"waits for commander"| node_commander
node_attacktools -->|"issues game commands"| node_protocols
node_attackshared -->|"queries map and units"| node_protocols
node_fortresslogic -->|"queries map"| node_protocols
node_commander -->|"reads commander data"| node_protocols
node_skip -->|"reads skip resources"| node_protocols
node_plugins -.->|"includes support tasks"| node_miscplugins
node_protocols -->|"sends game requests"| node_worker
node_units -.->|"defines unit data"| node_protocols
node_discordcore -->|"logs in and registers"| node_discordservice
node_slash -->|"registers commands"| node_discordcore
node_discordalerts -->|"uses Discord client"| node_discordcore
node_discordalerts -->|"requests previews"| node_imagegen
node_imagegen -->|"uses unit metadata"| node_units

click node_main "https://github.com/darrenthebozz/gge-bot/blob/main/main.js"
click node_accounts "https://github.com/darrenthebozz/gge-bot/blob/main/main.js"
click node_worker "https://github.com/darrenthebozz/gge-bot/blob/main/ggeBot.js"
click node_pluginloader "https://github.com/darrenthebozz/gge-bot/blob/main/plugins/index.js"
click node_plugins "https://github.com/darrenthebozz/gge-bot/tree/main/plugins"
click node_attackevents "https://github.com/darrenthebozz/gge-bot/tree/main/plugins/attack"
click node_attackshared "https://github.com/darrenthebozz/gge-bot/blob/main/plugins/attack/sharedBarronAttackLogic.js"
click node_fortresslogic "https://github.com/darrenthebozz/gge-bot/blob/main/plugins/attack/sharedFortressAttackLogic.js"
click node_attacktools "https://github.com/darrenthebozz/gge-bot/blob/main/plugins/attack/attack.js"
click node_commander "https://github.com/darrenthebozz/gge-bot/blob/main/plugins/commander.js"
click node_skip "https://github.com/darrenthebozz/gge-bot/blob/main/plugins/skips.js"
click node_miscplugins "https://github.com/darrenthebozz/gge-bot/blob/main/plugins/misc.js"
click node_protocols "https://github.com/darrenthebozz/gge-bot/blob/main/protocols.js"
click node_units "https://github.com/darrenthebozz/gge-bot/blob/main/units.js"
click node_discordcore "https://github.com/darrenthebozz/gge-bot/blob/main/plugins/discord/discord.js"
click node_slash "https://github.com/darrenthebozz/gge-bot/blob/main/plugins/discord/slashCommands.js"
click node_discordalerts "https://github.com/darrenthebozz/gge-bot/tree/main/plugins/discord"
click node_imagegen "https://github.com/darrenthebozz/gge-bot/blob/main/imageGen.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_accounts,node_worker,node_pluginloader toneBlue
class node_plugins,node_attackevents,node_attackshared,node_fortresslogic,node_attacktools,node_commander,node_skip,node_miscplugins toneAmber
class node_discordcore,node_slash,node_discordalerts,node_imagegen toneMint
class node_protocols,node_units toneRose
class node_operator,node_gamehost,node_discordservice toneIndigo
```

## Components

### Bot runtime

- [Account service](https://github.com/darrenthebozz/gge-bot/blob/main/main.js): `main.js`
- [Account database](https://github.com/darrenthebozz/gge-bot/blob/main/main.js): `main.js`
- [Bot worker](https://github.com/darrenthebozz/gge-bot/blob/main/ggeBot.js): `ggeBot.js`
- [Plugin loader](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/index.js): `plugins/index.js`

### Game automation

- [Automation plugins](https://github.com/darrenthebozz/gge-bot/tree/main/plugins): `plugins`
- [Event attacks](https://github.com/darrenthebozz/gge-bot/tree/main/plugins/attack): `plugins/attack`
- [Attack strategy](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/attack/sharedBarronAttackLogic.js): `plugins/attack/sharedBarronAttackLogic.js`
- [Fortress attacks](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/attack/sharedFortressAttackLogic.js): `plugins/attack/sharedFortressAttackLogic.js`
- [Attack utilities](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/attack/attack.js): `plugins/attack/attack.js`
- [Commander allocator](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/commander.js): `plugins/commander.js`
- [Skip management](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/skips.js): `plugins/skips.js`
- [Support plugins](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/misc.js): `plugins/misc.js`

### Discord features

- [Discord client](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/discord/discord.js): `plugins/discord/discord.js`
- [Slash commands](https://github.com/darrenthebozz/gge-bot/blob/main/plugins/discord/slashCommands.js): `plugins/discord/slashCommands.js`
- [Alliance notifications](https://github.com/darrenthebozz/gge-bot/tree/main/plugins/discord): `plugins/discord`
- [Attack previews](https://github.com/darrenthebozz/gge-bot/blob/main/imageGen.js): `imageGen.js`

### Game protocol

- [Game data and commands](https://github.com/darrenthebozz/gge-bot/blob/main/protocols.js): `protocols.js`
- [Unit metadata](https://github.com/darrenthebozz/gge-bot/blob/main/units.js): `units.js`

### Other components

- **Bot operator**
- **Goodgame Empire**
- **Discord service**

## Connections

- Bot operator → Account service: configures accounts (evidence: `README`)
- Account service → Account database: reads and updates (evidence: `main.js`)
- Account service → Bot worker: starts workers (evidence: `main.js`)
- Account service → Plugin loader: loads plugins (evidence: `main.js`)
- Plugin loader → Automation plugins: discovers plugins (evidence: `plugins/index.js`)
- Bot worker → Goodgame Empire: connects by WebSocket (evidence: `ggeBot.js`)
- Bot worker → Game data and commands: provides game state (evidence: `protocols.js`)
- Event attacks → Attack strategy: uses shared logic (evidence: `plugins/attack/attackBarronsBurningSands.js`)
- Event attacks → Fortress attacks: uses fortress logic (evidence: `plugins/attack/attackFortressesBurningSands.js`)
- Attack strategy → Attack utilities: uses attack utilities (evidence: `plugins/attack/sharedBarronAttackLogic.js`)
- Fortress attacks → Attack utilities: uses attack utilities (evidence: `plugins/attack/sharedFortressAttackLogic.js`)
- Attack strategy → Skip management: spends skips (evidence: `plugins/attack/sharedBarronAttackLogic.js`)
- Event attacks → Commander allocator: waits for commander (evidence: `plugins/attack/attackKhan.js`)
- Attack utilities → Game data and commands: issues game commands (evidence: `plugins/attack/attack.js`)
- Attack strategy → Game data and commands: queries map and units (evidence: `plugins/attack/sharedBarronAttackLogic.js`)
- Fortress attacks → Game data and commands: queries map (evidence: `plugins/attack/sharedFortressAttackLogic.js`)
- Commander allocator → Game data and commands: reads commander data (evidence: `plugins/commander.js`)
- Skip management → Game data and commands: reads skip resources (evidence: `plugins/skips.js`)
- Automation plugins → Support plugins: includes support tasks
- Game data and commands → Bot worker: sends game requests (evidence: `protocols.js`)
- Unit metadata → Game data and commands: defines unit data
- Discord client → Discord service: logs in and registers (evidence: `plugins/discord/discord.js`)
- Slash commands → Discord client: registers commands (evidence: `plugins/discord/slashCommands.js`)
- Alliance notifications → Discord client: uses Discord client (evidence: `plugins/discord/incomingAttacks.js`)
- Alliance notifications → Attack previews: requests previews (evidence: `plugins/discord/incomingAttacks.js`)
- Attack previews → Unit metadata: uses unit metadata (evidence: `imageGen.js`)
