# yonatanahituv/discord-role-bot architecture

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

- Interactive diagram: https://gitdiagram.com/yonatanahituv/discord-role-bot
- Repository: https://github.com/yonatanahituv/discord-role-bot

## Overview

This is a single-guild Discord bot for configurable role assignment and community utilities. Members trigger configured question flows that assign Discord roles; the bot also supports role-database assignment, anonymous complaints, and optional MEE6 level-based assignment. An internal Redis-backed data layer serves bot features and includes an operator console for managing Discord channels and messages. The excerpts show key calls but omit much of both modules, so relationships for unsampled capabilities are included only where documented or visible.

Main entry points: [`main.py`](https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py) (Bot event handler), [`db.py`](https://github.com/yonatanahituv/discord-role-bot/blob/master/db.py) (Role database API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bot["Discord bot"]
  node_main["Bot event handler<br/>[main.py]"]
  node_matchmaking["Question matchmaking<br/>[main.py]"]
  node_role_assignment["Role assignment<br/>[main.py]"]
  node_complaints["Anonymous complaints<br/>[main.py]"]
  node_mee6["MEE6 level assignment<br/>[main.py]"]
end

subgraph group_data["Role data"]
  node_db_api["Role database API<br/>[db.py]"]
  node_redis[("Redis store")]
end

subgraph group_ops["Operator tools"]
  node_admin_console["Admin console<br/>[db.py]"]
end

node_members(("Guild members"))
node_discord["Discord service"]
node_operator(("Bot operator"))
node_mee6_service["MEE6 API"]

node_members -->|"send commands"| node_main
node_main -->|"runs questions"| node_matchmaking
node_matchmaking -->|"assigns roles"| node_discord
node_main -->|"assigns roles"| node_role_assignment
node_role_assignment -->|"reads role data"| node_db_api
node_main -->|"loads database"| node_db_api
node_db_api -->|"reads and writes"| node_redis
node_role_assignment -->|"applies roles"| node_discord
node_main -->|"handles complaints"| node_complaints
node_complaints -->|"sends moderator report"| node_discord
node_main -->|"checks levels"| node_mee6
node_mee6 -->|"fetches leaderboard"| node_mee6_service
node_mee6 -->|"assigns roles"| node_discord
node_operator -->|"operates"| node_admin_console
node_admin_console -->|"manages channels"| node_discord

click node_main "https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py"
click node_matchmaking "https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py"
click node_role_assignment "https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py"
click node_complaints "https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py"
click node_mee6 "https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py"
click node_db_api "https://github.com/yonatanahituv/discord-role-bot/blob/master/db.py"
click node_admin_console "https://github.com/yonatanahituv/discord-role-bot/blob/master/db.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_matchmaking,node_role_assignment,node_complaints,node_mee6 toneBlue
class node_db_api,node_redis toneAmber
class node_admin_console,node_mee6_service toneMint
class node_members,node_discord,node_operator toneIndigo
```

## Components

### Discord bot

- [Bot event handler](https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py): `main.py`
- [Question matchmaking](https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py): `main.py`
- [Role assignment](https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py): `main.py`
- [Anonymous complaints](https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py): `main.py`
- [MEE6 level assignment](https://github.com/yonatanahituv/discord-role-bot/blob/master/main.py): `main.py`

### Role data

- [Role database API](https://github.com/yonatanahituv/discord-role-bot/blob/master/db.py): `db.py`
- **Redis store**

### Operator tools

- [Admin console](https://github.com/yonatanahituv/discord-role-bot/blob/master/db.py): `db.py`

### Other components

- **Guild members**
- **Discord service**
- **Bot operator**
- **MEE6 API**

## Connections

- Guild members → Bot event handler: send commands (evidence: `readme.md`)
- Bot event handler → Question matchmaking: runs questions (evidence: `readme.md`)
- Question matchmaking → Discord service: assigns roles (evidence: `main.py`)
- Bot event handler → Role assignment: assigns roles (evidence: `main.py`)
- Role assignment → Role database API: reads role data (evidence: `main.py`)
- Bot event handler → Role database API: loads database (evidence: `main.py`)
- Role database API → Redis store: reads and writes (evidence: `db.py`)
- Role assignment → Discord service: applies roles (evidence: `main.py`)
- Bot event handler → Anonymous complaints: handles complaints (evidence: `readme.md`)
- Anonymous complaints → Discord service: sends moderator report (evidence: `main.py`)
- Bot event handler → MEE6 level assignment: checks levels (evidence: `main.py`)
- MEE6 level assignment → MEE6 API: fetches leaderboard (evidence: `main.py`)
- MEE6 level assignment → Discord service: assigns roles (evidence: `main.py`)
- Bot operator → Admin console: operates (evidence: `db.py`)
- Admin console → Discord service: manages channels (evidence: `db.py`)
