# kebenxiaoming/matrix architecture

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

- Interactive diagram: https://gitdiagram.com/kebenxiaoming/matrix
- Repository: https://github.com/kebenxiaoming/matrix

## Overview

Matrix is a Python video-distribution system that automates account login and publishing to Douyin, WeChat Channels, Xiaohongshu, and Kuaishou. Its primary workflow consumes login or publish queues in MySQL, dispatches to platform-specific automation, and records results; Redis supports login state and QR-code data. The README also documents a separate Xiaohongshu signing service. Edges reflect the supplied excerpts, SOURCE INDEX references, and README; some platform modules and database details were not sampled in full.

Main entry points: [`publish_video_queue.py`](https://github.com/kebenxiaoming/matrix/blob/main/publish_video_queue.py) (Publish worker), [`user_queue_login.py`](https://github.com/kebenxiaoming/matrix/blob/main/user_queue_login.py) (Login worker), [`xhs_uploader/main.py`](https://github.com/kebenxiaoming/matrix/blob/main/xhs_uploader/main.py) (Xiaohongshu login and upload), [`douyin_uploader/main.py`](https://github.com/kebenxiaoming/matrix/blob/main/douyin_uploader/main.py) (Douyin login and upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_queue["Queue orchestration"]
  node_login_worker["Login worker"]
  node_publish_worker["Publish worker"]
end

subgraph group_platforms["Platform automation"]
  node_douyin["Douyin login and upload<br/>[main.py]"]
  node_channels["Channels login and upload<br/>[main.py]"]
  node_xhs["Xiaohongshu login and upload<br/>[main.py]"]
  node_ks_login_upload["Kuaishou login and upload<br/>[main.py]"]
  node_ks_batch["Kuaishou batch upload<br/>[main.py]"]
end

subgraph group_state["State and configuration"]
  node_mysql[("MySQL queues and accounts")]
  node_redis[("Redis login state")]
  node_config["Runtime configuration<br/>[conf.py]"]
  node_file_schedule["Video path and scheduling<br/>[files_times.py]"]
end

subgraph group_signing["Xiaohongshu signing"]
  node_xhs_sign_client["Signing client<br/>[main.py]"]
  node_xhs_sign_service["Signing API<br/>[app2024.py]"]
end

node_operator(("Operator"))
node_douyin_service{{"Douyin creator platform"}}
node_channels_service{{"WeChat Channels platform"}}
node_xhs_service{{"Xiaohongshu platform"}}
node_ks_service{{"Kuaishou creator platform"}}

node_operator -->|"starts login"| node_login_worker
node_operator -->|"starts publishing"| node_publish_worker
node_login_worker -->|"reads and updates"| node_mysql
node_login_worker -->|"dispatches login"| node_douyin
node_login_worker -->|"dispatches login"| node_channels
node_login_worker -->|"dispatches login"| node_xhs
node_login_worker -->|"dispatches login"| node_ks_login_upload
node_publish_worker -->|"reads queue; updates status"| node_mysql
node_publish_worker -->|"dispatches upload"| node_douyin
node_publish_worker -->|"dispatches upload"| node_channels
node_publish_worker -->|"dispatches upload"| node_xhs
node_publish_worker -->|"dispatches upload"| node_ks_login_upload
node_publish_worker -->|"uses paths and tags"| node_file_schedule
node_douyin -->|"automates browser"| node_douyin_service
node_channels -->|"automates browser"| node_channels_service
node_xhs -->|"uploads content"| node_xhs_service
node_ks_login_upload -->|"automates browser"| node_ks_service
node_ks_batch -->|"automates batch uploads"| node_ks_service
node_douyin -->|"stores login state"| node_redis
node_ks_login_upload -->|"stores login state"| node_redis
node_xhs -->|"stores login state"| node_redis
node_config -->|"configures connection"| node_mysql
node_config -->|"configures connection"| node_redis
node_xhs -->|"requests signatures"| node_xhs_sign_service
node_xhs_sign_service -->|"computes web signatures"| node_xhs_service

click node_login_worker "https://github.com/kebenxiaoming/matrix/blob/main/user_queue_login.py"
click node_publish_worker "https://github.com/kebenxiaoming/matrix/blob/main/publish_video_queue.py"
click node_config "https://github.com/kebenxiaoming/matrix/blob/main/conf.py"
click node_file_schedule "https://github.com/kebenxiaoming/matrix/blob/main/utils/files_times.py"
click node_douyin "https://github.com/kebenxiaoming/matrix/blob/main/douyin_uploader/main.py"
click node_channels "https://github.com/kebenxiaoming/matrix/blob/main/tencent_uploader/main.py"
click node_xhs "https://github.com/kebenxiaoming/matrix/blob/main/xhs_uploader/main.py"
click node_ks_login_upload "https://github.com/kebenxiaoming/matrix/blob/main/ks_uploader/main.py"
click node_ks_batch "https://github.com/kebenxiaoming/matrix/blob/main/kuaishou/main.py"
click node_xhs_sign_client "https://github.com/kebenxiaoming/matrix/blob/main/xhs_uploader/main.py"
click node_xhs_sign_service "https://github.com/kebenxiaoming/matrix/blob/main/xhs-api/app2024.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_login_worker,node_publish_worker toneBlue
class node_douyin,node_channels,node_xhs,node_ks_login_upload,node_ks_batch toneAmber
class node_mysql,node_redis,node_config,node_file_schedule toneMint
class node_xhs_sign_client,node_xhs_sign_service toneRose
class node_operator,node_douyin_service,node_channels_service,node_xhs_service,node_ks_service toneIndigo
```

## Components

### Queue orchestration

- [Login worker](https://github.com/kebenxiaoming/matrix/blob/main/user_queue_login.py): `user_queue_login.py`
- [Publish worker](https://github.com/kebenxiaoming/matrix/blob/main/publish_video_queue.py): `publish_video_queue.py`

### Platform automation

- [Douyin login and upload](https://github.com/kebenxiaoming/matrix/blob/main/douyin_uploader/main.py): `douyin_uploader/main.py`
- [Channels login and upload](https://github.com/kebenxiaoming/matrix/blob/main/tencent_uploader/main.py): `tencent_uploader/main.py`
- [Xiaohongshu login and upload](https://github.com/kebenxiaoming/matrix/blob/main/xhs_uploader/main.py): `xhs_uploader/main.py`
- [Kuaishou login and upload](https://github.com/kebenxiaoming/matrix/blob/main/ks_uploader/main.py): `ks_uploader/main.py`
- [Kuaishou batch upload](https://github.com/kebenxiaoming/matrix/blob/main/kuaishou/main.py): `kuaishou/main.py`

### State and configuration

- **MySQL queues and accounts**
- **Redis login state**
- [Runtime configuration](https://github.com/kebenxiaoming/matrix/blob/main/conf.py): `conf.py`
- [Video path and scheduling](https://github.com/kebenxiaoming/matrix/blob/main/utils/files_times.py): `utils/files_times.py`

### Xiaohongshu signing

- [Signing client](https://github.com/kebenxiaoming/matrix/blob/main/xhs_uploader/main.py): `xhs_uploader/main.py`
- [Signing API](https://github.com/kebenxiaoming/matrix/blob/main/xhs-api/app2024.py): `xhs-api/app2024.py`

### Other components

- **Operator**
- **Douyin creator platform**
- **WeChat Channels platform**
- **Xiaohongshu platform**
- **Kuaishou creator platform**

## Connections

- Operator → Login worker: starts login (evidence: `README.MD`)
- Operator → Publish worker: starts publishing (evidence: `README.MD`)
- Login worker → MySQL queues and accounts: reads and updates (evidence: `user_queue_login.py`)
- Login worker → Douyin login and upload: dispatches login (evidence: `user_queue_login.py`)
- Login worker → Channels login and upload: dispatches login (evidence: `user_queue_login.py`)
- Login worker → Xiaohongshu login and upload: dispatches login (evidence: `user_queue_login.py`)
- Login worker → Kuaishou login and upload: dispatches login (evidence: `user_queue_login.py`)
- Publish worker → MySQL queues and accounts: reads queue; updates status (evidence: `publish_video_queue.py`)
- Publish worker → Douyin login and upload: dispatches upload (evidence: `publish_video_queue.py`)
- Publish worker → Channels login and upload: dispatches upload (evidence: `publish_video_queue.py`)
- Publish worker → Xiaohongshu login and upload: dispatches upload (evidence: `publish_video_queue.py`)
- Publish worker → Kuaishou login and upload: dispatches upload (evidence: `publish_video_queue.py`)
- Publish worker → Video path and scheduling: uses paths and tags (evidence: `publish_video_queue.py`)
- Douyin login and upload → Douyin creator platform: automates browser (evidence: `douyin_uploader/main.py`)
- Channels login and upload → WeChat Channels platform: automates browser (evidence: `tencent_uploader/main.py`)
- Xiaohongshu login and upload → Xiaohongshu platform: uploads content (evidence: `xhs_uploader/main.py`)
- Kuaishou login and upload → Kuaishou creator platform: automates browser (evidence: `ks_uploader/main.py`)
- Kuaishou batch upload → Kuaishou creator platform: automates batch uploads (evidence: `kuaishou/main.py`)
- Douyin login and upload → Redis login state: stores login state (evidence: `douyin_uploader/main.py`)
- Kuaishou login and upload → Redis login state: stores login state (evidence: `ks_uploader/main.py`)
- Xiaohongshu login and upload → Redis login state: stores login state (evidence: `xhs_uploader/main.py`)
- Runtime configuration → MySQL queues and accounts: configures connection (evidence: `conf.py`)
- Runtime configuration → Redis login state: configures connection (evidence: `conf.py`)
- Xiaohongshu login and upload → Signing API: requests signatures (evidence: `xhs_uploader/main.py`)
- Signing API → Xiaohongshu platform: computes web signatures (evidence: `xhs-api/app2024.py`)
