# zhu-tingshuai/personal_wxwork_zts architecture

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

- Interactive diagram: https://gitdiagram.com/zhu-tingshuai/personal_wxwork_zts
- Repository: https://github.com/zhu-tingshuai/personal_wxwork_zts

## Overview

This is a WeCom one-to-one auto-reply desktop application driven by screenshot RPA, OCR, local vector retrieval, and an LLM. Its primary workflow scans the visible client for unread conversations, identifies and extracts customer messages, applies deduplication and quality gates, then automatically sends, requests human confirmation, or escalates. A separate knowledge-ingestion workflow turns chat exports and videos into searchable Qdrant data. The graph includes README-documented features whose source was not sampled; those links cite the README rather than implying their implementation was inspected.

Main entry points: [`main.py`](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/main.py) (Scan coordinator), [`rag/responder.py`](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/responder.py) (Reply orchestration), [`wxbot/detector/_message_detector.py`](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/_message_detector.py) (Message detector), [`pipeline/run_pipeline.py`](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/run_pipeline.py) (Import coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["App orchestration"]
  node_main["Scan coordinator<br/>[main.py]"]
  node_config["Runtime config<br/>[manager.py]"]
end

subgraph group_capture["WeCom capture"]
  node_scanner["Window scanner<br/>[scanner.py]"]
  node_detector["Message detector"]
  node_red["Unread detection<br/>[red_dot.py]"]
  node_bubble["Bubble analysis<br/>[bubble.py]"]
  node_name["Name region<br/>[name_region.py]"]
  node_ocr["OCR extraction<br/>[ocr_engine.py]"]
end

subgraph group_reply["RAG and dispatch"]
  node_responder["Reply orchestration<br/>[responder.py]"]
  node_embedding["Query embedding<br/>[embed_query.py]"]
  node_retriever["Vector retrieval<br/>[retriever.py]"]
  node_qdrant[("Knowledge vectors")]
  node_generator["Reply generation<br/>[generator.py]"]
  node_llm["DeepSeek service"]
  node_guard["Quality gate<br/>[guard.py]"]
  node_fallback["Human fallback<br/>[human_fallback.py]"]
  node_sender["Message sender<br/>[sender.py]"]
end

subgraph group_knowledge["Knowledge ingestion"]
  node_pipeline["Import coordinator<br/>[run_pipeline.py]"]
  node_chat["Chat importer<br/>[chat_importer.py]"]
  node_transcribe["Video transcription"]
  node_chunker["Text chunking<br/>[chunker.py]"]
  node_embedder["Vector ingestion<br/>[embedder.py]"]
end

subgraph group_operations["Operator tools"]
  node_gui["Control window<br/>[main_window.py]"]
  node_notify["Human notification<br/>[fallback_ui.py]"]
  node_debug["Debug visualizer<br/>[visualizer.py]"]
  node_evaluation["RAG evaluation"]
end

node_operator(("Operator"))
node_wecom["WeCom desktop"]

node_operator -->|"starts and controls"| node_main
node_main -->|"loads settings"| node_config
node_main -->|"schedules scans"| node_scanner
node_scanner -->|"captures and clicks"| node_wecom
node_main -->|"processes screenshots"| node_detector
node_detector -->|"checks unread marks"| node_red
node_detector -->|"analyzes bubbles"| node_bubble
node_detector -->|"detects names"| node_name
node_detector -->|"extracts text"| node_ocr
node_main -->|"submits messages"| node_responder
node_responder -->|"embeds query"| node_embedding
node_responder -->|"searches knowledge"| node_retriever
node_retriever -->|"queries vectors"| node_qdrant
node_responder -->|"requests reply"| node_generator
node_generator -->|"calls chat API"| node_llm
node_responder -->|"checks response"| node_guard
node_responder -->|"escalates cases"| node_fallback
node_responder -->|"routes approved send"| node_sender
node_sender -->|"sends reply"| node_wecom
node_main -->|"updates controls"| node_gui
node_main -->|"notifies escalation"| node_notify
node_main -->|"records scan results"| node_debug
node_operator -->|"reviews pending replies"| node_gui
node_pipeline -->|"parses chat exports"| node_chat
node_pipeline -->|"transcribes videos"| node_transcribe
node_pipeline -->|"splits source text"| node_chunker
node_pipeline -->|"stores chunks"| node_embedder
node_embedder -->|"writes vectors"| node_qdrant
node_evaluation -->|"evaluates retrieval"| node_retriever
node_evaluation -->|"evaluates generation"| node_generator

click node_main "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/main.py"
click node_config "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/config/manager.py"
click node_scanner "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/scanner.py"
click node_detector "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/_message_detector.py"
click node_red "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/red_dot.py"
click node_bubble "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/bubble.py"
click node_name "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/name_region.py"
click node_ocr "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/ocr_engine.py"
click node_responder "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/responder.py"
click node_embedding "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/embed_query.py"
click node_retriever "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/retriever.py"
click node_generator "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/generator.py"
click node_guard "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/guard.py"
click node_fallback "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/human_fallback.py"
click node_sender "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/sender.py"
click node_pipeline "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/run_pipeline.py"
click node_chat "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/chat_importer.py"
click node_transcribe "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/video_transcribe.py"
click node_chunker "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/chunker.py"
click node_embedder "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/embedder.py"
click node_gui "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/gui/main_window.py"
click node_notify "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/notify/fallback_ui.py"
click node_debug "https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/debug/visualizer.py"
click node_evaluation "https://github.com/zhu-tingshuai/personal_wxwork_zts/tree/main/eval"

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_config toneBlue
class node_scanner,node_detector,node_red,node_bubble,node_name,node_ocr toneAmber
class node_responder,node_embedding,node_retriever,node_qdrant,node_generator,node_llm,node_guard,node_fallback,node_sender toneMint
class node_pipeline,node_chat,node_transcribe,node_chunker,node_embedder toneRose
class node_gui,node_notify,node_debug,node_evaluation,node_operator,node_wecom toneIndigo
```

## Components

### App orchestration

- [Scan coordinator](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/main.py): `main.py`
- [Runtime config](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/config/manager.py): `config/manager.py`

### WeCom capture

- [Window scanner](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/scanner.py): `wxbot/scanner.py`
- [Message detector](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/_message_detector.py): `wxbot/detector/_message_detector.py`
- [Unread detection](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/red_dot.py): `wxbot/detector/red_dot.py`
- [Bubble analysis](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/bubble.py): `wxbot/detector/bubble.py`
- [Name region](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/name_region.py): `wxbot/detector/name_region.py`
- [OCR extraction](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/detector/ocr_engine.py): `wxbot/detector/ocr_engine.py`

### RAG and dispatch

- [Reply orchestration](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/responder.py): `rag/responder.py`
- [Query embedding](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/embed_query.py): `rag/embed_query.py`
- [Vector retrieval](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/retriever.py): `rag/retriever.py`
- **Knowledge vectors**
- [Reply generation](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/generator.py): `rag/generator.py`
- **DeepSeek service**
- [Quality gate](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/guard.py): `rag/guard.py`
- [Human fallback](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/rag/human_fallback.py): `rag/human_fallback.py`
- [Message sender](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/wxbot/sender.py): `wxbot/sender.py`

### Knowledge ingestion

- [Import coordinator](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/run_pipeline.py): `pipeline/run_pipeline.py`
- [Chat importer](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/chat_importer.py): `pipeline/chat_importer.py`
- [Video transcription](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/video_transcribe.py): `pipeline/video_transcribe.py`
- [Text chunking](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/chunker.py): `pipeline/chunker.py`
- [Vector ingestion](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/pipeline/embedder.py): `pipeline/embedder.py`

### Operator tools

- [Control window](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/gui/main_window.py): `gui/main_window.py`
- [Human notification](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/notify/fallback_ui.py): `notify/fallback_ui.py`
- [Debug visualizer](https://github.com/zhu-tingshuai/personal_wxwork_zts/blob/main/debug/visualizer.py): `debug/visualizer.py`
- [RAG evaluation](https://github.com/zhu-tingshuai/personal_wxwork_zts/tree/main/eval): `eval`

### Other components

- **Operator**
- **WeCom desktop**

## Connections

- Operator → Scan coordinator: starts and controls (evidence: `README.md`)
- Scan coordinator → Runtime config: loads settings (evidence: `main.py`)
- Scan coordinator → Window scanner: schedules scans (evidence: `main.py`)
- Window scanner → WeCom desktop: captures and clicks (evidence: `README.md`)
- Scan coordinator → Message detector: processes screenshots (evidence: `README.md`)
- Message detector → Unread detection: checks unread marks (evidence: `wxbot/detector/_message_detector.py`)
- Message detector → Bubble analysis: analyzes bubbles (evidence: `wxbot/detector/_message_detector.py`)
- Message detector → Name region: detects names (evidence: `wxbot/detector/_message_detector.py`)
- Message detector → OCR extraction: extracts text (evidence: `wxbot/detector/_message_detector.py`)
- Scan coordinator → Reply orchestration: submits messages (evidence: `main.py`)
- Reply orchestration → Query embedding: embeds query (evidence: `rag/responder.py`)
- Reply orchestration → Vector retrieval: searches knowledge (evidence: `rag/responder.py`)
- Vector retrieval → Knowledge vectors: queries vectors (evidence: `README.md`)
- Reply orchestration → Reply generation: requests reply (evidence: `rag/responder.py`)
- Reply generation → DeepSeek service: calls chat API (evidence: `rag/generator.py`)
- Reply orchestration → Quality gate: checks response (evidence: `README.md`)
- Reply orchestration → Human fallback: escalates cases (evidence: `rag/responder.py`)
- Reply orchestration → Message sender: routes approved send (evidence: `rag/responder.py`)
- Message sender → WeCom desktop: sends reply (evidence: `README.md`)
- Scan coordinator → Control window: updates controls (evidence: `main.py`)
- Scan coordinator → Human notification: notifies escalation
- Scan coordinator → Debug visualizer: records scan results (evidence: `main.py`)
- Operator → Control window: reviews pending replies (evidence: `README.md`)
- Import coordinator → Chat importer: parses chat exports (evidence: `pipeline/run_pipeline.py`)
- Import coordinator → Video transcription: transcribes videos (evidence: `pipeline/run_pipeline.py`)
- Import coordinator → Text chunking: splits source text (evidence: `pipeline/run_pipeline.py`)
- Import coordinator → Vector ingestion: stores chunks (evidence: `pipeline/run_pipeline.py`)
- Vector ingestion → Knowledge vectors: writes vectors (evidence: `pipeline/embedder.py`)
- RAG evaluation → Vector retrieval: evaluates retrieval (evidence: `eval/run.py`)
- RAG evaluation → Reply generation: evaluates generation (evidence: `eval/run.py`)
