# nappa85/pokifications architecture

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

- Interactive diagram: https://gitdiagram.com/nappa85/pokifications
- Repository: https://github.com/nappa85/pokifications

## Overview

##### Main Components

a) Webhook Receiver Layer
- Entry point for incoming webhooks from PokéSpawn

b) Core Processing Components
- Bot module (central component based on the file structure)
- Alert system (from alerts.rs)
- Configuration management (from config.rs)
- Database interface (from db.rs)

c) Output Layer
- Telegram integration (from telegram.rs)
- Notification dispatch system

##### Component Relationships

**[WebHook Input] → [Configuration Manager]**
- ↘ [Bot Core] ← [File Cache]
- ← [Map System]
- ← [Message Handler]
- [Database] ↗
**[Alert Manager] ← [Bot Core] → [Telegram API]**

##### Specific Elements

a) Input Processing:
- Webhook endpoint (entry point)
- Configuration validation (pokifications.toml)
- Request parsing and validation

b) Core Processing:
- Bot module components:
- File caching system (file_cache.rs)
- Handling (map.rs)
- Message processing (message.rs)
- Selection logic (select_all.rs)
- Database operations (db.rs)
- Management (lists.rs)

c) Output Handling:
- Alert generation system
- Telegram message formatting and delivery
- Cleanup procedures (cleanup.rs)

##### Technical Details to Highlight

- Rust-specific concurrent processing
- WebHook handling mechanism
- Database interactions
- Telegram API integration points
- Configuration management flow

**┌─────────────────────────────────────────┐**
- External Layer             │
- ┘
- ↓                    ↑
**┌─────────────────────────────────────────┐**
- Processing Layer             │
- [Bot Core]  ←→  [Alert Manager]       │
- ↕            ↕                     │
- [Database]  ←→  [Cache System]        │
- ┘
- ↓                    ↑
**┌─────────────────────────────────────────┐**
- Output Layer                 │
- ┘

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef external fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef config fill:#e67e22,stroke:#d35400,color:white
    classDef processing fill:#95a5a6,stroke:#7f8c8d,color:white

    %% External Layer
    WebhookReceiver["Webhook Receiver"]:::external
    TelegramAPI["Telegram API"]:::external

    %% Configuration Layer
    ConfigManager["Configuration Manager"]:::config
    PokificationsConfig["Pokifications Config"]:::config

    %% Core Processing Layer
    BotCore["Bot Core"]:::core
    AlertSystem["Alert System"]:::core
    MessageHandler["Message Handler"]:::processing
    MapSystem["Map System"]:::processing
    SelectionLogic["Selection Logic"]:::processing

    %% Storage Layer
    Database[(Database)]:::storage
    FileCache[(File Cache)]:::storage

    %% Support Components
    ListManager["List Manager"]:::processing
    CleanupSystem["Cleanup System"]:::processing

    %% Relationships
    WebhookReceiver --> ConfigManager
    WebhookReceiver --> BotCore
    PokificationsConfig --> ConfigManager
    ConfigManager --> BotCore
    
    BotCore --> AlertSystem
    BotCore --> MessageHandler
    BotCore --> MapSystem
    BotCore --> SelectionLogic
    BotCore --> Database
    BotCore --> FileCache
    BotCore --> TelegramAPI
    
    AlertSystem --> TelegramAPI
    ListManager --> BotCore
    CleanupSystem --> Database
    CleanupSystem --> FileCache

    %% Click Events
    click WebhookReceiver "https://github.com/nappa85/pokifications/blob/master/src/main.rs"
    click BotCore "https://github.com/nappa85/pokifications/blob/master/src/bot/mod.rs"
    click AlertSystem "https://github.com/nappa85/pokifications/blob/master/src/alerts.rs"
    click ConfigManager "https://github.com/nappa85/pokifications/blob/master/src/config.rs"
    click Database "https://github.com/nappa85/pokifications/blob/master/src/db.rs"
    click TelegramAPI "https://github.com/nappa85/pokifications/blob/master/src/telegram.rs"
    click FileCache "https://github.com/nappa85/pokifications/blob/master/src/bot/file_cache.rs"
    click MapSystem "https://github.com/nappa85/pokifications/blob/master/src/bot/map.rs"
    click MessageHandler "https://github.com/nappa85/pokifications/blob/master/src/bot/message.rs"
    click SelectionLogic "https://github.com/nappa85/pokifications/blob/master/src/bot/select_all.rs"
    click ListManager "https://github.com/nappa85/pokifications/blob/master/src/lists.rs"
    click CleanupSystem "https://github.com/nappa85/pokifications/blob/master/src/cleanup.rs"
    click PokificationsConfig "https://github.com/nappa85/pokifications/blob/master/pokifications.toml.example"

    %% Legend
    subgraph Legend
        ExtInt["External Interface"]:::external
        CoreComp["Core Component"]:::core
        StorageComp[(Storage)]:::storage
        ConfigComp["Configuration"]:::config
        ProcessingComp["Processing"]:::processing
    end
```
