# pampam000/richpannel-tg-vk architecture

> Architecture diagram of the GitHub repository pampam000/richpannel-tg-vk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pampam000/richpannel-tg-vk
- Repository: https://github.com/pampam000/richpannel-tg-vk

## Overview

This is an asynchronous customer-support bridge connecting Telegram, VK messages/comments, and VK wall comments with Richpanel tickets. Inbound messenger events create or update tickets; Richpanel webhooks route operator replies back to the customer’s originating channel, with SQLite tracking customer, ticket, and reply state. The graph emphasizes these documented runtime paths and the shared API layer. Some API and connector implementations were not excerpted, so uncertain internal calls are omitted.

Main entry points: [`app/richpanel/handlers.py`](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/handlers.py) (Richpanel Webhooks), [`app/main.py`](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/main.py) (Async Server), [`app/tg_bot/connector.py`](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/tg_bot/connector.py) (Telegram Connector), [`app/db.py`](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/db.py) (SQLite Conversation State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main["Async Server<br/>[main.py]"]
  node_instances["Client Instances"]
  node_config["App Configuration<br/>[config.py]"]
end

subgraph group_messenger["Messenger Channels"]
  node_tg_router["Telegram Handler<br/>[handlers.py]"]
  node_tg_connector["Telegram Connector<br/>[connector.py]"]
  node_vk_router["VK Webhook Handler<br/>[handlers.py]"]
  node_vk_connector["VK Message Connector<br/>[connector.py]"]
  node_vk_comment["VK Comment Connector"]
  node_vk_comments["VK Comment Utilities<br/>[comments_utils.py]"]
end

subgraph group_support["Richpanel Support"]
  node_rich_handler["Richpanel Webhooks<br/>[handlers.py]"]
end

subgraph group_state["Conversation State"]
  node_db[("SQLite Conversation State<br/>[db.py]")]
end

subgraph group_clients["API Clients"]
  node_rich_api["Richpanel API<br/>[api.py]"]
  node_rich_conversation["Conversation Client<br/>[converstion.py]"]
  node_rich_customer["Customer Client<br/>[customer.py]"]
  node_rich_base["Richpanel HTTP Base<br/>[base_wrapper.py]"]
  node_vk_api["VK API<br/>[api.py]"]
  node_vk_base["VK HTTP Base<br/>[base_wrapper.py]"]
end

node_customer(("Customer"))
node_operator(("Support Operator"))

node_customer -->|"sends message"| node_tg_router
node_customer -->|"sends event"| node_vk_router
node_main -->|"creates clients"| node_instances
node_main -->|"initializes database"| node_db
node_main -->|"registers router"| node_tg_router
node_main -->|"serves routes"| node_vk_router
node_main -->|"serves routes"| node_rich_handler
node_tg_router -->|"processes message"| node_tg_connector
node_vk_router -->|"dispatches messages"| node_vk_connector
node_vk_router -->|"dispatches comments"| node_vk_comment
node_tg_connector -->|"creates customer"| node_rich_api
node_tg_connector -->|"creates or updates ticket"| node_rich_conversation
node_tg_connector -->|"reads and updates links"| node_db
node_vk_connector -->|"uses conversation state"| node_db
node_vk_comment -->|"uses comment state"| node_db
node_vk_comments -->|"uses API instances"| node_instances
node_rich_handler -->|"retrieves ticket"| node_rich_conversation
node_rich_handler -->|"reads and records replies"| node_db
node_rich_handler -->|"sends wall reply"| node_vk_comments
node_operator -->|"posts webhook"| node_rich_handler
node_rich_handler -->|"routes reply"| node_tg_connector
node_rich_handler -->|"routes reply"| node_vk_connector
node_instances -->|"creates client"| node_rich_api
node_instances -->|"creates client"| node_vk_api
node_rich_conversation -->|"uses HTTP base"| node_rich_base
node_rich_customer -->|"uses HTTP base"| node_rich_base
node_rich_base -->|"reads API settings"| node_config
node_vk_base -->|"reads API settings"| node_config

click node_main "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/main.py"
click node_instances "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/create_instances.py"
click node_config "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/config.py"
click node_tg_router "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/tg_bot/handlers.py"
click node_tg_connector "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/tg_bot/connector.py"
click node_vk_router "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/handlers.py"
click node_vk_connector "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/connector.py"
click node_vk_comment "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/comment_connector.py"
click node_vk_comments "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/comments_utils.py"
click node_rich_handler "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/handlers.py"
click node_rich_api "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/api.py"
click node_rich_conversation "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/api_wrappers/conversations/converstion.py"
click node_rich_customer "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/api_wrappers/customers/customer.py"
click node_rich_base "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/api_wrappers/base/base_wrapper.py"
click node_vk_api "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/api.py"
click node_vk_base "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/api_wrappers/base/base_wrapper.py"
click node_db "https://github.com/pampam000/richpannel-tg-vk/blob/main/app/db.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_instances,node_config toneBlue
class node_tg_router,node_tg_connector,node_vk_router,node_vk_connector,node_vk_comment,node_vk_comments toneAmber
class node_rich_handler toneMint
class node_db toneRose
class node_rich_api,node_rich_conversation,node_rich_customer,node_rich_base,node_vk_api,node_vk_base,node_customer,node_operator toneIndigo
```

## Components

### Runtime

- [Async Server](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/main.py): `app/main.py`
- [Client Instances](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/create_instances.py): `app/create_instances.py`
- [App Configuration](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/config.py): `app/config.py`

### Messenger Channels

- [Telegram Handler](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/tg_bot/handlers.py): `app/tg_bot/handlers.py`
- [Telegram Connector](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/tg_bot/connector.py): `app/tg_bot/connector.py`
- [VK Webhook Handler](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/handlers.py): `app/vk/handlers.py`
- [VK Message Connector](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/connector.py): `app/vk/connector.py`
- [VK Comment Connector](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/comment_connector.py): `app/vk/comment_connector.py`
- [VK Comment Utilities](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/comments_utils.py): `app/vk/comments_utils.py`

### Richpanel Support

- [Richpanel Webhooks](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/handlers.py): `app/richpanel/handlers.py`

### Conversation State

- [SQLite Conversation State](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/db.py): `app/db.py`

### API Clients

- [Richpanel API](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/api.py): `app/richpanel/api.py`
- [Conversation Client](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/api_wrappers/conversations/converstion.py): `app/richpanel/api_wrappers/conversations/converstion.py`
- [Customer Client](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/api_wrappers/customers/customer.py): `app/richpanel/api_wrappers/customers/customer.py`
- [Richpanel HTTP Base](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/richpanel/api_wrappers/base/base_wrapper.py): `app/richpanel/api_wrappers/base/base_wrapper.py`
- [VK API](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/api.py): `app/vk/api.py`
- [VK HTTP Base](https://github.com/pampam000/richpannel-tg-vk/blob/main/app/vk/api_wrappers/base/base_wrapper.py): `app/vk/api_wrappers/base/base_wrapper.py`

### Other components

- **Customer**
- **Support Operator**

## Connections

- Customer → Telegram Handler: sends message (evidence: `app/tg_bot/handlers.py`)
- Customer → VK Webhook Handler: sends event (evidence: `app/vk/handlers.py`)
- Async Server → Client Instances: creates clients (evidence: `app/main.py`)
- Async Server → SQLite Conversation State: initializes database (evidence: `app/main.py`)
- Async Server → Telegram Handler: registers router (evidence: `app/main.py`)
- Async Server → VK Webhook Handler: serves routes (evidence: `app/main.py`)
- Async Server → Richpanel Webhooks: serves routes (evidence: `app/main.py`)
- Telegram Handler → Telegram Connector: processes message (evidence: `app/tg_bot/handlers.py`)
- VK Webhook Handler → VK Message Connector: dispatches messages (evidence: `app/vk/handlers.py`)
- VK Webhook Handler → VK Comment Connector: dispatches comments (evidence: `app/vk/handlers.py`)
- Telegram Connector → Richpanel API: creates customer (evidence: `app/tg_bot/connector.py`)
- Telegram Connector → Conversation Client: creates or updates ticket (evidence: `app/tg_bot/connector.py`)
- Telegram Connector → SQLite Conversation State: reads and updates links (evidence: `app/tg_bot/connector.py`)
- VK Message Connector → SQLite Conversation State: uses conversation state (evidence: `app/vk/connector.py`)
- VK Comment Connector → SQLite Conversation State: uses comment state (evidence: `app/vk/comment_connector.py`)
- VK Comment Utilities → Client Instances: uses API instances (evidence: `app/vk/comments_utils.py`)
- Richpanel Webhooks → Conversation Client: retrieves ticket (evidence: `app/richpanel/handlers.py`)
- Richpanel Webhooks → SQLite Conversation State: reads and records replies (evidence: `app/richpanel/handlers.py`)
- Richpanel Webhooks → VK Comment Utilities: sends wall reply (evidence: `app/richpanel/handlers.py`)
- Support Operator → Richpanel Webhooks: posts webhook (evidence: `app/richpanel/handlers.py`)
- Richpanel Webhooks → Telegram Connector: routes reply (evidence: `app/richpanel/handlers.py`)
- Richpanel Webhooks → VK Message Connector: routes reply (evidence: `app/richpanel/handlers.py`)
- Client Instances → Richpanel API: creates client (evidence: `app/create_instances.py`)
- Client Instances → VK API: creates client (evidence: `app/create_instances.py`)
- Conversation Client → Richpanel HTTP Base: uses HTTP base (evidence: `app/richpanel/api_wrappers/conversations/converstion.py`)
- Customer Client → Richpanel HTTP Base: uses HTTP base (evidence: `app/richpanel/api_wrappers/customers/customer.py`)
- Richpanel HTTP Base → App Configuration: reads API settings (evidence: `app/richpanel/api_wrappers/base/base_wrapper.py`)
- VK HTTP Base → App Configuration: reads API settings (evidence: `app/vk/api_wrappers/base/base_wrapper.py`)
