# rogermgual/disc-mngmnt architecture

> Architecture diagram of the GitHub repository rogermgual/disc-mngmnt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rogermgual/disc-mngmnt
- Repository: https://github.com/rogermgual/disc-mngmnt

## Overview

##### Project type and purpose
- This is a Python‐based Discord management bot providing slash commands, scheduling and role‐management features.
- It lives as a single service connecting to the Discord Gateway, handling user commands (/hello, /ping, birthdays, reminders, raid plans) and persisting state.

##### File structure
- Top‐level files
- .gitignore
- README.md
- requirements.txt
- app/ directory
- bot.py        ← main entry point, event listeners, command routing
- database/funcs.py  ← CRUD and query helpers for storing birthdays, reminders, raid events
- No separate “frontend”—this is an event‐driven service.

##### README for additional insights
- The README enumerates current and planned features: greetings, ping‐pong, birthdays, reminders, raid planning.
- It implies scheduled tasks (daily, weekly, hourly checks) and role/thread management on Discord.

##### Main components
a. Discord Gateway (external service)
b. Bot Application
- Command Handler module
- Scheduler module (jobs for birthdays, reminders, raid‐start alerts, auto‐cleanup)
- Business logic layer (birthday logic, reminder logic, raid‐plan logic)
- Database access layer (funcs.py)
c. Persistent Storage (e.g. SQLite, Postgres—or whatever is in requirements.txt)
d. Optional: Configuration/Env (bot token, channel IDs)

##### Relationships and interactions
- Bot Command Handler → Business Logic → Database Access → Database
- Scheduler → Business Logic (on timers) → Discord Gateway (outgoing messages)
- Database → Business Logic for reading scheduled items
- Configuration → Bot Application for credentials and channel settings

##### Architectural patterns & key technologies
- Event‐driven pattern: commands and reactions trigger handlers
- Layered architecture:
- Presentation (Discord events)
- Application logic (bot.py)
- Data access (funcs.py)
- Scheduling pattern: periodic jobs (could use APScheduler or a simple loop + sleep)
- Discord.py (or a Discord slash‐commands library)

##### Detail
- Don’t overthink: break the bot down into its natural layers and show how data and events move through them.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Service
    Discord["Discord Gateway"]:::external

    %% Bot Application Modules
    subgraph "Bot Application"
        CH["Command Handler"]:::appmod
        SCH["Scheduler Module"]:::appmod
        BL["Business Logic Layer"]:::appmod
        DAL["Database Access Layer"]:::appmod
        CFG["Configuration / Environment"]:::appmod
    end

    %% Data Store
    DB["Database"]:::datastore

    %% Connections
    Discord -->|"slash_event"| CH
    CH -->|"invoke_logic"| BL
    BL -->|"query_save"| DAL
    DAL -->|"DB operations"| DB
    SCH -->|"trigger_job"| BL
    BL -->|"send_message"| Discord
    CFG -->|"provides_credentials"| CH
    CFG -->|"provides_configuration"| SCH

    %% Click Events
    click CH "https://github.com/rogermgual/disc-mngmnt/blob/master/app/bot.py"
    click SCH "https://github.com/rogermgual/disc-mngmnt/blob/master/app/bot.py"
    click BL "https://github.com/rogermgual/disc-mngmnt/blob/master/app/bot.py"
    click DAL "https://github.com/rogermgual/disc-mngmnt/blob/master/app/database/funcs.py"
    click CFG "https://github.com/rogermgual/disc-mngmnt/blob/master/requirements.txt"

    %% Styles
    classDef external fill:#cfe2f3,stroke:#0366d6,color:#0366d6;
    classDef appmod fill:#d4edda,stroke:#237a28,color:#237a28;
    classDef datastore fill:#fff3cd,stroke:#d39e00,color:#d39e00;
```
