# vascocosta/gluon_bot architecture

> Architecture diagram of the GitHub repository vascocosta/gluon_bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vascocosta/gluon_bot
- Repository: https://github.com/vascocosta/gluon_bot

## Overview

##### Main Components Identification
The system should be represented with these key components:

a) Core Bot Engine:
- Represented by the main.rs and api.rs components
- Should be shown as the central hub that coordinates all other components

b) Command Handler System:
- Commands/ directory as a major subsystem
- Individual command modules (weather.rs, news.rs, f1*.rs, etc.) as connected modules
- Use a common interface pattern as shown by base.rs

c) Task Management System:
- Tasks/ directory as a parallel subsystem to commands
- Task modules (feeds.rs, train_game.rs, next.rs) connected to the task manager
- Async nature of these tasks

d) External Services Integration:
- OpenWeatherMap
- News API
- OMDB API
- Currency API
- RSS/Atom feeds

e) Data Storage:
- Database.rs component
- Connection to the data/ directory for persistent storage
- Events.csv and other data files

##### Relationships and Data Flow

a) Primary Data Flow:
**IRC Server <-> Core Bot Engine <-> Command Handler**
- <-> Task Manager

b) Secondary Flows:
**Command Handler <-> External Services**
**Task Manager <-> External Services**
**Both <-> Database Layer**

##### Design Elements

Use these visual elements:

- Blue rectangles: Core components (Bot Engine, Command Handler, Task Manager)
- Green rectangles: External services
- Yellow rectangles: Data storage components
- Purple rectangles: Plugin system components

##### Technical Details

Technical annotations:

- Rust-specific features (memory safety, concurrency)
- External crate dependencies
- Configuration system (config.toml)
- IRC protocol handling

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        BE[Bot Engine]:::core
        API[API Interface]:::core
        Utils[Utilities]:::core
    end

    subgraph "Command System"
        CM[Command Manager]:::command
        CI[Command Interface]:::command
        subgraph "Command Modules"
            First[First Command]:::plugin
            Weather[Weather Service]:::plugin
            News[News Service]:::plugin
            OMDB[Movie Database]:::plugin
            Currency[Currency Service]:::plugin
            F1Bet[F1 Betting]:::plugin
            F1Results[F1 Results]:::plugin
            F1Stand[F1 Standings]:::plugin
            Plugin[Plugin Handler]:::plugin
        end
    end

    subgraph "Task System"
        TM[Task Manager]:::task
        TI[Task Interface]:::task
        subgraph "Task Modules"
            RSS[RSS Feed Handler]:::async
            TrainGame[Train Game]:::async
            NextTask[Next Handler]:::async
        end
    end

    subgraph "External Services"
        OWM[OpenWeatherMap API]:::external
        NewsAPI[News API]:::external
        OMDBAPI[OMDB API]:::external
        CurrencyAPI[Currency API]:::external
        RSSFeeds[RSS/Atom Feeds]:::external
    end

    subgraph "Storage"
        DB[(Database)]:::storage
        Data[Data Files]:::storage
    end

    IRC[IRC Server]:::external

    %% Core Connections
    IRC <-.->|async| BE
    BE -->|async| API
    BE --> Utils

    %% Command System
    BE -->|async| CM
    CM --> CI
    CI --> First
    CI --> Weather
    CI --> News
    CI --> OMDB
    CI --> Currency
    CI --> F1Bet
    CI --> F1Results
    CI --> F1Stand
    CI --> Plugin

    %% Task System
    BE -->|async| TM
    TM -->|async| TI
    TI -->|async| RSS
    TI -->|async| TrainGame
    TI -->|async| NextTask

    %% External Service Connections
    Weather -->|async| OWM
    News -->|async| NewsAPI
    OMDB -->|async| OMDBAPI
    Currency -->|async| CurrencyAPI
    RSS -->|async| RSSFeeds

    %% Database Connections
    BE -->|async| DB
    DB --> Data

    %% Styling
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef command fill:#d4f0a8,stroke:#333,stroke-width:2px
    classDef task fill:#f0d1a8,stroke:#333,stroke-width:2px
    classDef plugin fill:#d1a8f0,stroke:#333,stroke-width:2px
    classDef external fill:#f0a8a8,stroke:#333,stroke-width:2px
    classDef storage fill:#f0f0a8,stroke:#333,stroke-width:2px
    classDef async fill:#a8f0d1,stroke:#333,stroke-width:2px

    %% Click Events
    click BE "https://github.com/vascocosta/gluon_bot/blob/main/src/main.rs"
    click API "https://github.com/vascocosta/gluon_bot/blob/main/src/api.rs"
    click Utils "https://github.com/vascocosta/gluon_bot/blob/main/src/utils.rs"
    click CM "https://github.com/vascocosta/gluon_bot/blob/main/src/commands.rs"
    click CI "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/base.rs"
    click First "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/first.rs"
    click Weather "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/weather.rs"
    click News "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/news.rs"
    click OMDB "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/omdb.rs"
    click Currency "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/rates.rs"
    click F1Bet "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/f1bet.rs"
    click F1Results "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/f1results.rs"
    click F1Stand "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/f1standings.rs"
    click Plugin "https://github.com/vascocosta/gluon_bot/blob/main/src/commands/plugin.rs"
    click TM "https://github.com/vascocosta/gluon_bot/blob/main/src/tasks.rs"
    click TI "https://github.com/vascocosta/gluon_bot/blob/main/src/tasks/base.rs"
    click RSS "https://github.com/vascocosta/gluon_bot/blob/main/src/tasks/feeds.rs"
    click TrainGame "https://github.com/vascocosta/gluon_bot/blob/main/src/tasks/train_game.rs"
    click DB "https://github.com/vascocosta/gluon_bot/blob/main/src/database.rs"
```
