# ghashtag/neuro-blogger-telegraf-bot architecture

> Architecture diagram of the GitHub repository ghashtag/neuro-blogger-telegraf-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ghashtag/neuro-blogger-telegraf-bot
- Repository: https://github.com/ghashtag/neuro-blogger-telegraf-bot

## Overview

##### Client Layer
- Telegram Bot Interface
- User Interaction Points (Commands & Scenes)

##### Application Core
- Bot Service Layer
- Command Handler System
- Scene Management System
- Price Management System

##### External Services Integration
- OpenAI Integration
- ElevenLabs Integration
- Replicate Integration
- SyncLabs Integration

##### Data Layer
- Supabase Database
- File Storage System

##### Client Layer
- It to the Command Handler and Scene Management components

- Command Management (/src/commands)
- Scene Management (/src/scenes)
- Price Management (/src/price)
- Service Layer (/src/services)

##### External Services Section
- OpenAI (text and image generation)
- ElevenLabs (voice generation)
- Replicate (video generation)
- SyncLabs (lip sync)

##### Data Layer
- Supabase at the bottom
- Connections to:
- User data management
- Balance management
- Model storage
- File storage

##### Flow Connections
- Blue: User interactions
- Green: Data operations
- Red: External API calls

##### Processing Components
- Image processing
- Voice processing
- Video generation
- Text processing

##### Security Layer
- Authentication handling
- Subscription verification
- Balance checking mechanisms

Specific Implementation Details:

##### Use clear labels for each component
- Command names from /src/commands
- Scene names from /src/scenes
- Service names from /src/services

##### Related functionality
- Image-related features
- Voice-related features
- Video-related features
- Text-related features

##### Error handling paths
- Error handlers from /src/helpers/error
- Retry mechanisms
- Fallback paths

##### Configuration management
- Environment configuration
- Docker configuration
- Deployment settings

- User Interface Layer (Telegram Bot)
- Business Logic Layer (Commands & Scenes)
- Service Layer (External APIs)
- Data Access Layer (Supabase)

Use standardized symbols:
- Rectangles for services and components
- Diamonds for decision points
- Clouds for external services

Remember to:
- Use consistent styling
- Brief descriptions for complex components
- Both synchronous and asynchronous flows
- Scaling points
- Critical paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        TG[Telegram Bot Interface]
        Menu[Menu System]
    end

    subgraph Core
        BotService[Bot Service Layer]
        CommandHandler[Command Management System]
        SceneHandler[Scene Management System]
        PriceManager[Price Management System]
        PriceCalc[Price Calculation System]
        RegCommands[Bot Command Registration]
    end

    subgraph Services
        OpenAI[OpenAI Integration]
        ElevenLabs[ElevenLabs Integration]
        Replicate[Replicate Integration]
        SyncLabs[SyncLabs Integration]
    end

    subgraph Processing
        ImgProc[Image Processing]
        ModelSelect[Model Selection System]
        PaymentHandler[Payment Handling]
        UserBalance[User Balance Management]
    end

    subgraph Security
        Auth[Authentication Middleware]
        APIInterface[API Interfaces]
    end

    subgraph Data
        Supabase[(Supabase Database)]
        ErrorHandler[Error Handling System]
    end

    TG --> BotService
    Menu --> BotService
    BotService --> CommandHandler
    BotService --> SceneHandler
    BotService --> PriceManager
    PriceManager --> PriceCalc
    BotService --> RegCommands

    CommandHandler --> OpenAI
    CommandHandler --> ElevenLabs
    CommandHandler --> Replicate
    CommandHandler --> SyncLabs

    SceneHandler --> ImgProc
    SceneHandler --> ModelSelect
    SceneHandler --> PaymentHandler
    PaymentHandler --> UserBalance

    BotService --> Auth
    Auth --> APIInterface
    APIInterface --> Services

    Services --> ErrorHandler
    ErrorHandler --> Supabase

    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef service fill:#e1f5fe,stroke:#0288d1
    classDef security fill:#ffebee,stroke:#c62828
    classDef processing fill:#e8f5e9,stroke:#2e7d32
    classDef data fill:#fff3e0,stroke:#ef6c00

    class OpenAI,ElevenLabs,Replicate,SyncLabs service
    class Auth,APIInterface security
    class ImgProc,ModelSelect,PaymentHandler,UserBalance processing
    class Supabase,ErrorHandler data

    click TG "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/core/bot/index.ts"
    click CommandHandler "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/commands/index.ts"
    click SceneHandler "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/scenes/index.ts"
    click PriceManager "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/price/index.ts"
    click OpenAI "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/core/openai/index.ts"
    click ElevenLabs "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/core/elevenlabs/index.ts"
    click Replicate "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/core/replicate/index.ts"
    click SyncLabs "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/core/synclabs/index.ts"
    click Supabase "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/core/supabase/index.ts"
    click ErrorHandler "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/helpers/error/index.ts"
    click Menu "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/menu/index.ts"
    click PaymentHandler "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/handlers/paymentHandlers/index.ts"
    click UserBalance "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/commands/balanceCommand/index.ts"
    click ModelSelect "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/commands/selectModelCommand/index.ts"
    click ImgProc "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/helpers/images/index.ts"
    click Auth "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/middlewares/subscription.ts"
    click PriceCalc "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/price/helpers/calculateFinalPrice.ts"
    click RegCommands "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/registerCommands.ts"
    click APIInterface "https://github.com/gHashTag/neuro-blogger-telegraf-bot/blob/main/src/interfaces/api.interface.ts"
```
