# wivexx/azi-3 architecture

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

- Interactive diagram: https://gitdiagram.com/wivexx/azi-3
- Repository: https://github.com/wivexx/azi-3

## Overview

##### Project Type & Purpose
- This is an open-source Discord bot (AZI-3) written in Python using the discord.py library.
- It listens to Discord events, routes commands to specialized modules (e.g., bf2 moderation, games, utility), maintains small JSON files for state (logs, reports, banned members), and interacts directly with the Discord API.

##### File-Structure Analysis
- Top-level scripts:
- azi_3.py – entry point that instantiates the Discord client and loads commands/events
- bot_token.py – configuration (Discord token, constants)
- requirements.txt – lists discord.py and other dependencies
- hidden_script/leave.py – auxiliary script (e.g., leave-server logic)
- . json files (log_channel_ids.json, reports.json) – flat-file data stores
- “script/” directory:
- commands/ – organized by domain (bf2, games, uncategorized, useful)
- events/ – centralized event-listener definitions + banned_member_folder storage
- No database or external microservices—state is held in JSON files.

##### Key Components
a. Bot Client
- Connects to Discord API via WebSocket
- Loads command modules and event handlers
b. Event Dispatcher
- Receives raw events (e.g., on_message, on_member_join)
- Delegates to script/events/events.py or hidden_script modules
c. Command Handler
- Parses commands (prefix based)
- Routes to the correct module inside script/commands/**
d. Command Modules
- bf2/ moderation (ban, kick, blacklist management, reporting)
- bf2/ regiment, sessions, specialites (role assignments, session launches)
- useful/ (user_info, server_info, password utilities)
- uncategorized/ (ping, say, display_commands)
e. Data Stores
- JSON files: log_channel_ids.json, reports.json, banned_member lists
f. External Service
- Discord API (chat messages, guild membership, reactions, etc.)

##### Relationships & Data Flows
- Bot Client → Discord API: authenticate, subscribe to events, send/receive messages
- Discord API → Event Dispatcher → Command Handler (for “message” events)
- Command Handler ↔ Command Modules: invoke handlers based on prefix and command name
- Command Modules ↔ JSON Data Stores: read/write file state (reports, logs, ban lists)
- Command Modules → Discord API: send messages, embed responses, assign roles
- Hidden Script Module (leave.py) may be triggered on a specific event (e.g., on_guild_remove)

##### Architectural Patterns & Principles
- Event-driven architecture using discord.py’s callback model
- Modular command registration—for each file under script/commands/**
- Flat-file storage pattern for simplicity (no external DB)
- Separation of concerns: commands vs events vs configuration vs data

##### Detail Level
- Bot_token.py as a configuration loader used by the Bot Client

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Service
    DiscordAPI["Discord API"]:::external

    %% Core Runtime
    subgraph "Core Runtime"
        BotClient["Bot Client"]:::core
        ConfigLoader["Configuration Loader"]:::core
        DependencyList["Dependency List"]:::core
        EventDispatcher["Event Dispatcher"]:::core
        CommandHandler["Command Handler"]:::core
    end

    %% Auxiliary
    HiddenScript["Hidden Script\n(leave.py)"]:::core

    %% Command Modules
    subgraph "Command Modules"
        BF2Mod["bf2 Moderation Module"]:::module
        BlackList["Blacklist Submodule"]:::module
        HautStaff["Haut Staff Submodule"]:::module
        SecuMod["Secu Moderation Submodule"]:::module
        OtherMod["Other Moderation Commands"]:::module
        Regiment["bf2 Regiment Module"]:::module
        ServerStats["bf2 Server Stats Command"]:::module
        Sessions["bf2 Sessions Module"]:::module
        Specialites["bf2 Specialites Module"]:::module
        Games["Games Module"]:::module
        Useful["Useful Commands Module"]:::module
        Uncategorized["Uncategorized Commands Module"]:::module
    end

    %% Data Stores
    subgraph "Data Stores"
        BannedMembers["Banned Member Data Store"]:::datastore
        LogChannels["log_channel_ids.json"]:::datastore
        Reports["reports.json"]:::datastore
    end

    %% Relationships
    DiscordAPI -->|"events"| EventDispatcher
    BotClient -->|"loads"| EventDispatcher
    BotClient -->|"loads"| CommandHandler
    BotClient -->|"uses"| ConfigLoader
    BotClient -->|"requires"| DependencyList
    EventDispatcher -->|"parses commands"| CommandHandler
    EventDispatcher -->|"on_guild_remove"| HiddenScript
    CommandHandler -->|"invoke on prefix '!' "| BF2Mod
    CommandHandler -->|"invoke on prefix '!' "| Regiment
    CommandHandler -->|"invoke on prefix '!' "| ServerStats
    CommandHandler -->|"invoke on prefix '!' "| Sessions
    CommandHandler -->|"invoke on prefix '!' "| Specialites
    CommandHandler -->|"invoke on prefix '!' "| Games
    CommandHandler -->|"invoke on prefix '!' "| Useful
    CommandHandler -->|"invoke on prefix '!' "| Uncategorized
    BF2Mod --> BlackList
    BF2Mod --> HautStaff
    BF2Mod --> SecuMod
    BF2Mod --> OtherMod
    BF2Mod -->|"reads/writes"| LogChannels
    BF2Mod -->|"reads/writes"| Reports
    BF2Mod -->|"reads/writes"| BannedMembers
    Regiment -->|"reads/writes"| Reports
    Sessions -->|"reads/writes"| Reports
    Specialites -->|"reads/writes"| Reports
    Games -->|"reads/writes"| Reports
    Useful -->|"reads/writes"| Reports
    Uncategorized -->|"reads/writes"| Reports
    BF2Mod -->|"send_message()"| DiscordAPI
    Regiment -->|"send_message()"| DiscordAPI
    ServerStats -->|"send_message()"| DiscordAPI
    Sessions -->|"send_message()"| DiscordAPI
    Specialites -->|"send_message()"| DiscordAPI
    Games -->|"send_message()"| DiscordAPI
    Useful -->|"send_message()"| DiscordAPI
    Uncategorized -->|"send_message()"| DiscordAPI

    %% Click Events
    click BotClient "https://github.com/wivexx/azi-3/blob/main/azi_3.py"
    click ConfigLoader "https://github.com/wivexx/azi-3/blob/main/bot_token.py"
    click DependencyList "https://github.com/wivexx/azi-3/blob/main/requirements.txt"
    click HiddenScript "https://github.com/wivexx/azi-3/blob/main/hidden_script/leave.py"
    click EventDispatcher "https://github.com/wivexx/azi-3/blob/main/script/events/events.py"
    click BannedMembers "https://github.com/wivexx/azi-3/tree/main/script/events/banned_member_folder/"
    click CommandHandler "https://github.com/wivexx/azi-3/blob/main/script/commands/__init__.py"
    click BF2Mod "https://github.com/wivexx/azi-3/tree/main/script/commands/bf2/moderation/"
    click BlackList "https://github.com/wivexx/azi-3/blob/main/script/commands/bf2/moderation/black_list/black_list.py"
    click HautStaff "https://github.com/wivexx/azi-3/tree/main/script/commands/bf2/moderation/haut_staff/"
    click SecuMod "https://github.com/wivexx/azi-3/tree/main/script/commands/bf2/moderation/secu_moderation/"
    click Regiment "https://github.com/wivexx/azi-3/blob/main/script/commands/bf2/regiment/candidature_regiment.py"
    click ServerStats "https://github.com/wivexx/azi-3/blob/main/script/commands/bf2/server_stats.py"
    click Sessions "https://github.com/wivexx/azi-3/tree/main/script/commands/bf2/sessions/"
    click Specialites "https://github.com/wivexx/azi-3/tree/main/script/commands/bf2/specialites/"
    click Games "https://github.com/wivexx/azi-3/tree/main/script/commands/games/"
    click Useful "https://github.com/wivexx/azi-3/tree/main/script/commands/useful/"
    click Uncategorized "https://github.com/wivexx/azi-3/tree/main/script/commands/uncategorized/"
    click LogChannels "https://github.com/wivexx/azi-3/blob/main/log_channel_ids.json"
    click Reports "https://github.com/wivexx/azi-3/blob/main/reports.json"

    %% Styles
    classDef core fill:#E3F2FD,stroke:#1E88E5,color:#0D47A1
    classDef module fill:#E8F5E9,stroke:#43A047,color:#1B5E20
    classDef datastore fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef external fill:#F3E5F5,stroke:#8E24AA,color:#4A148C
```
