# staciax/valorant-discord-bot architecture

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

- Interactive diagram: https://gitdiagram.com/staciax/valorant-discord-bot
- Repository: https://github.com/staciax/valorant-discord-bot

## Overview

##### Project type and purpose
- This is an open‑source Discord bot written in Python, designed to surface VALORANT data (store, night market, battlepass, missions, bundles, notifications) inside Discord.
- It leverages Discord.py for the Discord Gateway and a custom Valorant API client (based on HeyM1ke’s ValorantClientAPI and valclient.py) to fetch and cache in‑game data.

##### File structure
- Top‑level bootstrap:
– `bot.py` / `main.py`: entrypoints that load environment variables, configure the Discord client, and register Cogs.
– `pyproject.toml`: dependency and build config.
– Docker files and GitHub Actions workflows: CI/CD and containerization.
- “cogs” folder: each file (admin.py, notify.py, valorant.py, errors.py) implements a set of slash commands or event listeners following Discord.py’s Cog pattern.
- “utils” folder:
– checks.py, errors.py: reusable decorators and exception handlers for command validation.
– locale_v2.py + `languages/*.json`: full i18n/l10n support.
– `utils/valorant`: modular API wrapper with subcomponents for auth, caching, database persistence, endpoints, embed generation, and views.
- “resources”: static screenshots and images for documentation.
- Configuration and environment management: `.env.example`, `.gitignore`, `.python-version`.

##### README for additional insights
- Confirms use of slash commands (`/store`, `/battlepass`, `/notify`, etc.), global vs. guild syncing, and custom emoji injection.
- Highlights dependency on external services: Discord Gateway, Riot’s in‑game API, Valorant‑API.com for assets, Crowdin for translations.
- Mentions a scheduled “notify” feature that watches for skin availability and pushes messages.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Services
    subgraph "External Services"
        DGateway["Discord Gateway & REST API"]:::external
        RiotAPI["Riot In-Game API"]:::external
        ValAPIcom["Valorant-API.com (Skin Assets)"]:::external
        Crowdin["Crowdin (Localization Pipeline)"]:::external
    end

    %% Bot Core
    subgraph "Bot Core"
        Entry["Entrypoint & Configuration Loader"]:::internal
        Dispatcher["Command Dispatcher (Discord.py Client)"]:::internal

        subgraph "Cogs"
            AdminCog["Admin Cog"]:::internal
            ErrorCog["Error Handling Cog"]:::internal
            NotifyCog["Notification Cog"]:::internal
            ValCog["Valorant Data Cog"]:::internal
        end

        subgraph "Utils"
            Checks["Checks & Decorators"]:::internal
            UtilsErr["Exception Handlers"]:::internal
            LocaleMgr["Localization Manager"]:::internal
            LangFiles["Translation Files"]:::internal
        end

        subgraph "Valorant API Module"
            AuthMgr["Auth Manager"]:::internal
            EndpointClient["HTTP Endpoint Client"]:::internal
            CacheMgr["Cache Manager"]:::internal
            DBPersist["DB Persistence"]:::internal
            EmbedBuilder["Embed Builder"]:::internal
            ViewRenderer["View Renderer"]:::internal
            LocalHelpers["Localization Helpers"]:::internal
            Resources["Static Resources (Assets Mapping)"]:::internal
            UsefulUtils["Misc Utilities"]:::internal
        end

        Scheduler["Scheduler & Notification Service"]:::internal
    end

    %% Data Stores
    subgraph "Data Stores"
        CacheStore[(In-memory/File Cache Store)]:::datastore
        PersistStore[(Persistent Store for Tokens & Settings)]:::datastore
    end

    %% Config & CI/CD
    subgraph "Config & CI/CD"
        PyProj["pyproject.toml"]:::internal
        EnvFile[".env.example"]:::internal
        Dockerfile["Dockerfile"]:::internal
        Workflows["GitHub Actions Workflows"]:::internal
    end

    %% Users
    User["Discord User"]:::external

    %% Connections
    User --> DGateway
    DGateway --> Entry
    Entry --> Dispatcher

    Dispatcher --> AdminCog
    Dispatcher --> ErrorCog
    Dispatcher --> NotifyCog
    Dispatcher --> ValCog

    AdminCog --> Checks
    AdminCog --> UtilsErr
    AdminCog --> LocaleMgr

    ErrorCog --> UtilsErr

    NotifyCog --> Scheduler
    NotifyCog --> DBPersist

    ValCog --> AuthMgr
    ValCog --> EndpointClient
    ValCog --> CacheMgr
    ValCog --> DBPersist
    ValCog --> EmbedBuilder

    Scheduler --> AuthMgr
    Scheduler --> EndpointClient
    Scheduler --> DBPersist

    DBPersist --> PersistStore
    CacheMgr --> CacheStore

    EndpointClient --> RiotAPI
    EndpointClient --> ValAPIcom

    LocaleMgr --> LangFiles
    LocaleMgr --> Crowdin

    EmbedBuilder --> ViewRenderer
    EmbedBuilder --> DGateway
    ViewRenderer --> DGateway

    %% Click Events
    click Entry "https://github.com/staciax/valorant-discord-bot/blob/master/bot.py"
    click Dispatcher "https://github.com/staciax/valorant-discord-bot/blob/master/bot.py"
    click AdminCog "https://github.com/staciax/valorant-discord-bot/blob/master/cogs/admin.py"
    click ErrorCog "https://github.com/staciax/valorant-discord-bot/blob/master/cogs/errors.py"
    click NotifyCog "https://github.com/staciax/valorant-discord-bot/blob/master/cogs/notify.py"
    click ValCog "https://github.com/staciax/valorant-discord-bot/blob/master/cogs/valorant.py"
    click Checks "https://github.com/staciax/valorant-discord-bot/blob/master/utils/checks.py"
    click UtilsErr "https://github.com/staciax/valorant-discord-bot/blob/master/utils/errors.py"
    click LocaleMgr "https://github.com/staciax/valorant-discord-bot/blob/master/utils/locale_v2.py"
    click LangFiles "https://github.com/staciax/valorant-discord-bot/tree/master/languages"
    click AuthMgr "https://github.com/staciax/valorant-discord-bot/blob/master/utils/valorant/auth.py"
    click EndpointClient "https://github.com/staciax/valorant-discord-bot/blob/master/utils/valorant/endpoint.py"
    click CacheMgr "https://github.com/staciax/valorant-discord-bot/blob/master/utils/valorant/cache.py"
    click DBPersist "https://github.com/staciax/valorant-discord-bot/blob/master/utils/valorant/db.py"
    click EmbedBuilder "https://github.com/staciax/valorant-discord-bot/blob/master/utils/valorant/embed.py"
    click ViewRenderer "https://github.com/staciax/valorant-discord-bot/blob/master/utils/valorant/view.py"
    click LocalHelpers "https://github.com/staciax/valorant-discord-bot/blob/master/utils/valorant/local.py"
    click Resources "https://github.com/staciax/valorant-discord-bot/blob/master/utils/valorant/resources.py"
    click UsefulUtils "https://github.com/staciax/valorant-discord-bot/blob/master/utils/valorant/useful.py"
    click PyProj "https://github.com/staciax/valorant-discord-bot/blob/master/pyproject.toml"
    click EnvFile "https://github.com/staciax/valorant-discord-bot/blob/master/.env.example"
    click Dockerfile "https://github.com/staciax/valorant-discord-bot/tree/master/Dockerfile"
    click Workflows "https://github.com/staciax/valorant-discord-bot/tree/master/.github/workflows"

    %% Styles
    classDef internal fill:#e0f7ff,stroke:#0066cc,color:#000
    classDef datastore fill:#e0ffe0,stroke:#00aa00,color:#000
    classDef external fill:#ffead0,stroke:#ff8800,color:#000
```
