# m24842/coc_bot architecture

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

- Interactive diagram: https://gitdiagram.com/m24842/coc_bot
- Repository: https://github.com/m24842/coc_bot

## Overview

Clash of Clans Bot automates gameplay across configured emulator accounts. The principal workflow starts at the CLI or desktop launcher, initializes an account, then repeatedly checks game state and runs home- and builder-village upgrades and attacks through shared device/screen utilities. Separate control surfaces provide desktop and web status, pause/resume, exclusions, and notifications; the README also documents Telegram notifications, app updates, and emulator lifecycle features. Edges reflect explicit calls and documented capabilities; unsampled subsystems are represented only where their paths are supported.

Main entry points: [`src/coc_bot.py`](https://github.com/m24842/coc_bot/blob/main/src/coc_bot.py) (Bot orchestrator), [`src/utils.py`](https://github.com/m24842/coc_bot/blob/main/src/utils.py) (Device and screen utilities), [`app/app.py`](https://github.com/m24842/coc_bot/blob/main/app/app.py) (Web control app), [`src/launch.py`](https://github.com/m24842/coc_bot/blob/main/src/launch.py) (Launcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_main["CLI entry<br/>[main.py]"]
  node_launcher["Launcher<br/>[launch.py]"]
  node_bot["Bot orchestrator<br/>[coc_bot.py]"]
end

subgraph group_automation["Game automation"]
  node_upgrader["Upgrade automation<br/>[upgrader.py]"]
  node_attacker["Attack automation<br/>[attacker.py]"]
  node_device["Device and screen utilities<br/>[utils.py]"]
end

subgraph group_control["Control surfaces"]
  node_desktop["Desktop GUI<br/>[gui.py]"]
  node_local_server["Local control server<br/>[gui_server.py]"]
  node_web_server["Web control app<br/>[app.py]"]
  node_web_templates["Web interface"]
  node_web_cache[("Instance state cache<br/>[app.py]")]
end

subgraph group_support["Operations"]
  node_logger["Logging<br/>[log.py]"]
  node_updater["Game app updates<br/>[utils.py]"]
end

node_user(("User"))
node_emulator["Android emulator"]
node_game["Clash of Clans"]
node_telegram["Telegram"]

node_user -->|"starts"| node_main
node_main -->|"calls"| node_launcher
node_launcher -->|"starts process"| node_bot
node_launcher -->|"starts GUI"| node_desktop
node_desktop -->|"starts server"| node_local_server
node_local_server -->|"dispatches actions"| node_launcher
node_bot -->|"runs upgrades"| node_upgrader
node_bot -->|"runs attacks"| node_attacker
node_bot -->|"checks game state"| node_device
node_upgrader -->|"uses screen controls"| node_device
node_attacker -->|"uses screen controls"| node_device
node_device -->|"logs activity"| node_logger
node_device -.->|"controls via ADB"| node_emulator
node_emulator -->|"runs"| node_game
node_bot -.->|"updates status"| node_local_server
node_local_server -->|"renders pages"| node_web_templates
node_user -->|"opens controls"| node_web_server
node_web_server -->|"renders pages"| node_web_templates
node_web_server -->|"reads and writes"| node_web_cache
node_bot -->|"sends status and notifications"| node_web_server
node_web_server -.->|"provides exclusions and pause state"| node_bot
node_bot -.->|"sends notifications"| node_telegram
node_device -.->|"supports app updates"| node_updater

click node_main "https://github.com/m24842/coc_bot/blob/main/src/main.py"
click node_launcher "https://github.com/m24842/coc_bot/blob/main/src/launch.py"
click node_bot "https://github.com/m24842/coc_bot/blob/main/src/coc_bot.py"
click node_upgrader "https://github.com/m24842/coc_bot/blob/main/src/upgrader.py"
click node_attacker "https://github.com/m24842/coc_bot/blob/main/src/attacker.py"
click node_device "https://github.com/m24842/coc_bot/blob/main/src/utils.py"
click node_logger "https://github.com/m24842/coc_bot/blob/main/src/log.py"
click node_desktop "https://github.com/m24842/coc_bot/blob/main/src/gui.py"
click node_local_server "https://github.com/m24842/coc_bot/blob/main/src/gui_server/gui_server.py"
click node_web_server "https://github.com/m24842/coc_bot/blob/main/app/app.py"
click node_web_templates "https://github.com/m24842/coc_bot/tree/main/app/templates"
click node_web_cache "https://github.com/m24842/coc_bot/blob/main/app/app.py"
click node_updater "https://github.com/m24842/coc_bot/blob/main/src/utils.py"

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_launcher,node_bot,node_user toneBlue
class node_upgrader,node_attacker,node_device toneAmber
class node_desktop,node_local_server,node_web_server,node_web_templates,node_web_cache toneMint
class node_logger,node_updater toneRose
class node_emulator,node_game,node_telegram toneIndigo
```

## Components

### Bot runtime

- [CLI entry](https://github.com/m24842/coc_bot/blob/main/src/main.py): `src/main.py`
- [Launcher](https://github.com/m24842/coc_bot/blob/main/src/launch.py): `src/launch.py`
- [Bot orchestrator](https://github.com/m24842/coc_bot/blob/main/src/coc_bot.py): `src/coc_bot.py`

### Game automation

- [Upgrade automation](https://github.com/m24842/coc_bot/blob/main/src/upgrader.py): `src/upgrader.py`
- [Attack automation](https://github.com/m24842/coc_bot/blob/main/src/attacker.py): `src/attacker.py`
- [Device and screen utilities](https://github.com/m24842/coc_bot/blob/main/src/utils.py): `src/utils.py`

### Control surfaces

- [Desktop GUI](https://github.com/m24842/coc_bot/blob/main/src/gui.py): `src/gui.py`
- [Local control server](https://github.com/m24842/coc_bot/blob/main/src/gui_server/gui_server.py): `src/gui_server/gui_server.py`
- [Web control app](https://github.com/m24842/coc_bot/blob/main/app/app.py): `app/app.py`
- [Web interface](https://github.com/m24842/coc_bot/tree/main/app/templates): `app/templates`
- [Instance state cache](https://github.com/m24842/coc_bot/blob/main/app/app.py): `app/app.py`

### Operations

- [Logging](https://github.com/m24842/coc_bot/blob/main/src/log.py): `src/log.py`
- [Game app updates](https://github.com/m24842/coc_bot/blob/main/src/utils.py): `src/utils.py`

### Other components

- **User**
- **Android emulator**
- **Clash of Clans**
- **Telegram**

## Connections

- User → CLI entry: starts (evidence: `README.md`)
- CLI entry → Launcher: calls (evidence: `src/main.py`)
- Launcher → Bot orchestrator: starts process (evidence: `src/launch.py`)
- Launcher → Desktop GUI: starts GUI (evidence: `src/launch.py`)
- Desktop GUI → Local control server: starts server (evidence: `src/gui.py`)
- Local control server → Launcher: dispatches actions (evidence: `src/launch.py`)
- Bot orchestrator → Upgrade automation: runs upgrades (evidence: `src/coc_bot.py`)
- Bot orchestrator → Attack automation: runs attacks (evidence: `src/coc_bot.py`)
- Bot orchestrator → Device and screen utilities: checks game state (evidence: `src/coc_bot.py`)
- Upgrade automation → Device and screen utilities: uses screen controls (evidence: `src/upgrader.py`)
- Attack automation → Device and screen utilities: uses screen controls (evidence: `src/attacker.py`)
- Device and screen utilities → Logging: logs activity (evidence: `src/utils.py`)
- Device and screen utilities → Android emulator: controls via ADB
- Android emulator → Clash of Clans: runs (evidence: `README.md`)
- Bot orchestrator → Local control server: updates status
- Local control server → Web interface: renders pages (evidence: `src/gui_server/gui_server.py`)
- User → Web control app: opens controls (evidence: `README.md`)
- Web control app → Web interface: renders pages (evidence: `app/app.py`)
- Web control app → Instance state cache: reads and writes (evidence: `app/app.py`)
- Bot orchestrator → Web control app: sends status and notifications
- Web control app → Bot orchestrator: provides exclusions and pause state
- Bot orchestrator → Telegram: sends notifications
- Device and screen utilities → Game app updates: supports app updates (evidence: `src/utils.py`)
