# lehakrechet/tg_bot_ai architecture

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

- Interactive diagram: https://gitdiagram.com/lehakrechet/tg_bot_ai
- Repository: https://github.com/lehakrechet/tg_bot_ai

## Overview

##### Project type and purpose
- This is a Python‐based backend service—a Telegram AI chatbot (“tg_bot_ai”).
- It integrates with Telegram’s Bot API, a third‐party AI (YandexGPT), and an internal “deepseek” (dsk) library that provides cryptographic or search capabilities via WebAssembly and Python modules.

##### File structure
- Top level:
- deepseek.py – likely a helper wrapper around the dsk package
- tg_bot.py – main entry point for the Telegram bot
- yandexgpt.py – adapter for Yandex GPT API
- file_worker.py – handles file I/O or background file tasks
- test.py/test.txt – ad hoc test harnesses
- recomendation.txt, requirements.txt
- dsk/ directory:
- api.py – core API calls for deepseek functionality
- pow.py – proof‐of‐work or crypto submodule
- wasm/sha3_wasm_bg…wasm – WebAssembly binary for SHA3
- history/ directory: persists session transcripts

##### README
- Only title provided (“tg_bot_ai”).
- No in‐depth architecture notes; inference must come from code structure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    TelClient["Telegram Client"]:::external
    Yandex["YandexGPT API"]:::external
    Bot["Telegram Bot Service"]:::core
    AIAdapter["AI Engine Adapter"]:::core
    DeepseekWrapper["DeepSeek Wrapper Module"]:::helper
    FileWorker["File Worker Service"]:::helper
    History["History Storage"]:::storage
    Config["Dependency Manager"]:::helper

    subgraph "DeepSeek Library"
        DS_API["API Layer (dsk/api.py)"]:::helper
        DS_POW["Proof-of-Work Submodule (dsk/pow.py)"]:::helper
        DS_WASM["WASM Component"]:::helper
    end

    TelClient <-->|"poll/webhook"| Bot
    Bot -->|"process message"| AIAdapter
    AIAdapter -->|"calls Yandex GPT"| Yandex
    Bot -->|"crypto/search tasks"| DeepseekWrapper
    DeepseekWrapper -->|"utilizes"| DS_API
    DS_API -->|"performs PoW"| DS_POW
    DS_POW -->|"hash via WASM"| DS_WASM
    Bot -->|"offload file tasks"| FileWorker
    Bot -->|"read/write transcripts"| History
    Bot -->|"requires deps"| Config

    click Bot "https://github.com/lehakrechet/tg_bot_ai/blob/main/tg_bot.py"
    click AIAdapter "https://github.com/lehakrechet/tg_bot_ai/blob/main/yandexgpt.py"
    click DeepseekWrapper "https://github.com/lehakrechet/tg_bot_ai/blob/main/deepseek.py"
    click DS_API "https://github.com/lehakrechet/tg_bot_ai/blob/main/dsk/api.py"
    click DS_POW "https://github.com/lehakrechet/tg_bot_ai/blob/main/dsk/pow.py"
    click DS_WASM "https://github.com/lehakrechet/tg_bot_ai/blob/main/dsk/wasm/sha3_wasm_bg.7b9ca65ddd.wasm"
    click FileWorker "https://github.com/lehakrechet/tg_bot_ai/blob/main/file_worker.py"
    click History "https://github.com/lehakrechet/tg_bot_ai/tree/main/history/"
    click Config "https://github.com/lehakrechet/tg_bot_ai/blob/main/requirements.txt"

    classDef external fill:#D6EAF8,stroke:#5DADE2
    classDef core fill:#D4EFDF,stroke:#27AE60
    classDef helper fill:#E5E8E8,stroke:#85929E
    classDef storage fill:#FCF3CF,stroke:#F1C40F

    class TelClient,Yandex external
    class Bot,AIAdapter core
    class DeepseekWrapper,DS_API,DS_POW,DS_WASM,FileWorker,Config helper
    class History storage
```
