# sudoskys/openaibot architecture

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

- Interactive diagram: https://gitdiagram.com/sudoskys/openaibot
- Repository: https://github.com/sudoskys/openaibot

## Overview

##### Main System Components

The system should be represented as a microservices architecture with these key components:

a) Message Processing Services:
- Sender Service (start_sender.py)
- Receiver Service (start_receiver.py)
- Message Queue (RabbitMQ) as the central communication hub

b) Platform Adapters:
- Telegram
- Discord
- Kook
- Slack
Each with their specific event handlers and HTTP clients

c) Core Components:
- LLM Integration (OpenAI compatible)
- Plugin System
- Authentication System
- Cache System
- Memory Management
- Task Management

##### Component Relationships

**[Platform Clients] → [Receiver Service] → [Message Queue] → [Sender Service] → [Platform Clients]**
- ↕
- [Core Processing Layer]

##### Detailed Architecture Elements

a) External Services (Hexagons):
- RabbitMQ (Message Queue)
- OpenAI API (or compatible endpoints)
- Platform APIs (Telegram, Discord, etc.)

b) Internal Components (Rectangles):
- App Components (/app directory)
- LLMKira Core (/llmkira directory)
- Plugin System (/llmkira/extra/plugins)

- Cache Stores (Redis/Local)
- Memory Management
- Document Management

##### Key Interactions to Highlight

- Message flow between platforms and services
- Plugin execution paths
- Authentication flows
- Tool call processing

##### Important Notes

Annotations for:
- Required Python version (>=3.9)
- Supported platforms
- Authentication methods
- Plugin system capabilities
- Hook system integration points

Keep the abstraction level high enough to be understandable but detailed enough to show the sophisticated plugin and hook systems that make this project unique.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef platform fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#4169E1,stroke:#333,stroke-width:2px,color:white
    classDef queue fill:#FFD700,stroke:#333,stroke-width:2px
    classDef plugin fill:#9370DB,stroke:#333,stroke-width:2px
    classDef auth fill:#FFA500,stroke:#333,stroke-width:2px
    classDef storage fill:#A9A9A9,stroke:#333,stroke-width:2px

    %% Client Layer
    subgraph Platforms
        TG["Telegram"]:::platform
        DC["Discord"]:::platform
        KK["Kook"]:::platform
        SL["Slack"]:::platform
    end

    %% Gateway Layer
    RS["Receiver Service"]:::core
    SS["Sender Service"]:::core

    %% Message Queue Layer
    MQ{{"Message Queue<br/>(RabbitMQ)"}}:::queue

    %% Core Processing Layer
    subgraph Core
        LLM["LLM Integration"]:::core
        TS["Tool System"]:::core
        MM["Memory Management"]:::core
        TM["Task Management"]:::core
    end

    %% Plugin Layer
    subgraph Plugins
        PS["Plugin System"]:::plugin
        VP["Voice Processing"]:::plugin
        HS["Hook System"]:::plugin
    end

    %% Storage Layer
    subgraph Storage
        CS[(Cache System)]:::storage
        DM[(Document Management)]:::storage
    end

    %% Authentication
    AUTH["Authentication"]:::auth
    UM["User Management"]:::auth

    %% Relationships
    Platforms --> RS
    RS --> MQ
    MQ --> SS
    SS --> Platforms
    MQ <--> Core
    Core <--> Plugins
    Core <--> Storage
    Core <--> AUTH
    AUTH <--> UM

    %% Click events
    click RS "https://github.com/sudoskys/Openaibot/blob/main/app/receiver/app.py"
    click SS "https://github.com/sudoskys/Openaibot/blob/main/app/sender/app.py"
    click MQ "https://github.com/sudoskys/Openaibot/blob/main/app/setting/rabbitmq.py"
    click TG "https://github.com/sudoskys/Openaibot/tree/main/app/sender/telegram/"
    click DC "https://github.com/sudoskys/Openaibot/tree/main/app/sender/discord/"
    click KK "https://github.com/sudoskys/Openaibot/tree/main/app/sender/kook/"
    click SL "https://github.com/sudoskys/Openaibot/tree/main/app/sender/slack/"
    click LLM "https://github.com/sudoskys/Openaibot/tree/main/llmkira/openai/"
    click PS "https://github.com/sudoskys/Openaibot/tree/main/llmkira/extra/plugins/"
    click CS "https://github.com/sudoskys/Openaibot/tree/main/llmkira/cache/"
    click MM "https://github.com/sudoskys/Openaibot/tree/main/llmkira/memory/"
    click TM "https://github.com/sudoskys/Openaibot/tree/main/llmkira/task/"
    click TS "https://github.com/sudoskys/Openaibot/tree/main/llmkira/sdk/tools/"
    click AUTH "https://github.com/sudoskys/Openaibot/blob/main/app/components/credential.py"
    click UM "https://github.com/sudoskys/Openaibot/tree/main/app/components/user_manager/"
    click DM "https://github.com/sudoskys/Openaibot/tree/main/llmkira/doc_manager/"
    click VP "https://github.com/sudoskys/Openaibot/tree/main/llmkira/extra/voice/"
    click HS "https://github.com/sudoskys/Openaibot/tree/main/llmkira/openapi/hook/"
```
