# why2lyj/youxiang-itchat architecture

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

- Interactive diagram: https://gitdiagram.com/why2lyj/youxiang-itchat
- Repository: https://github.com/why2lyj/youxiang-itchat

## Overview

Youxiang is a Python WeChat coupon-promotion assistant. Its main workflow starts the WeChat client, schedules configured platform jobs, fetches affiliate offers, and delivers product images and promotional text to selected groups. Separate chat handlers provide friend and group auto-replies, group-entry welcomes, and image moderation; Tencent NLP supplies the documented smart-chat option. The README also documents Taobao, JD, Pinduoduo, Suning, and unfinished Vipshop distribution. Several platform implementations are unsampled, so their internal call relationships are not inferred.

Main entry points: [`untils/scheduler.py`](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/scheduler.py) (Job scheduler), [`chat/wechat.py`](https://github.com/why2lyj/youxiang-itchat/blob/master/chat/wechat.py) (WeChat client), [`coupon/delivery.py`](https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/delivery.py) (Group delivery), [`coupon/pdd.py`](https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/pdd.py) (Pinduoduo offers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_main["Program entry<br/>[main.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_scheduler["Job scheduler<br/>[scheduler.py]"]
  node_retry["Retry helper<br/>[retry.py]"]
  node_common["Common utilities<br/>[common.py]"]
  node_ad["Ad utilities<br/>[ad.py]"]
end

subgraph group_chat["WeChat interaction"]
  node_wechat["WeChat client<br/>[wechat.py]"]
  node_chat_helper["Chat utilities<br/>[itchatHelper.py]"]
  node_message["Message handlers<br/>[message.py]"]
  node_nlp["Tencent smart chat<br/>[qq_nlpchat.py]"]
end

subgraph group_promotions["Coupon distribution"]
  node_delivery["Group delivery<br/>[delivery.py]"]
  node_pricing["Price formatting<br/>[pricing.py]"]
end

subgraph group_integrations["Platform integrations"]
  node_taobao["Taobao offers<br/>[tb.py]"]
  node_jd["JD offers<br/>[jd.py]"]
  node_pdd["Pinduoduo offers<br/>[pdd.py]"]
  node_suning["Suning offers<br/>[sn.py]"]
  node_vipshop["Vipshop offers"]
  node_tb_api["Taobao API client<br/>[tb_top_api.py]"]
  node_jd_api["JD API client<br/>[jd_api.py]"]
  node_pdd_api["Pinduoduo API client<br/>[pdd_api.py]"]
  node_shortener["JD URL shortener<br/>[suo_im.py]"]
end

node_operator(("Operator"))
node_affiliate_services{{"Affiliate platforms"}}
node_wechat_service{{"WeChat service"}}

node_operator -->|"starts"| node_main
node_main -->|"runs"| node_wechat
node_wechat -->|"reads"| node_config
node_wechat -->|"starts jobs"| node_scheduler
node_wechat -->|"registers handlers"| node_message
node_wechat -->|"initializes"| node_chat_helper
node_message -->|"requests replies"| node_nlp
node_message -->|"uses"| node_chat_helper
node_chat_helper -->|"reads"| node_config
node_wechat -->|"connects"| node_wechat_service
node_scheduler -->|"loads jobs"| node_config
node_scheduler -->|"dispatches"| node_jd
node_scheduler -->|"dispatches"| node_pdd
node_scheduler -.->|"schedules offers"| node_taobao
node_scheduler -.->|"schedules offers"| node_suning
node_scheduler -.->|"planned offers"| node_vipshop
node_taobao -->|"queries"| node_tb_api
node_taobao -->|"delivers"| node_delivery
node_taobao -->|"formats prices"| node_pricing
node_jd -->|"queries"| node_jd_api
node_jd -->|"shortens links"| node_shortener
node_jd -->|"delivers"| node_delivery
node_pdd -->|"queries"| node_pdd_api
node_pdd -->|"retries calls"| node_retry
node_pdd -->|"formats prices"| node_pricing
node_pdd -->|"delivers images"| node_delivery
node_suning -->|"sends images"| node_delivery
node_suning -->|"sends messages"| node_wechat_service
node_tb_api -->|"calls"| node_affiliate_services
node_jd_api -->|"calls"| node_affiliate_services
node_pdd_api -->|"calls"| node_affiliate_services
node_delivery -->|"saves images"| node_common
node_delivery -->|"sends content"| node_wechat_service
node_nlp -->|"requests NLP"| node_affiliate_services
node_message -->|"uses"| node_ad

click node_main "https://github.com/why2lyj/youxiang-itchat/blob/master/main.py"
click node_config "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/config.py"
click node_scheduler "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/scheduler.py"
click node_wechat "https://github.com/why2lyj/youxiang-itchat/blob/master/chat/wechat.py"
click node_chat_helper "https://github.com/why2lyj/youxiang-itchat/blob/master/chat/itchatHelper.py"
click node_message "https://github.com/why2lyj/youxiang-itchat/blob/master/chat/message.py"
click node_nlp "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/qq_nlpchat.py"
click node_delivery "https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/delivery.py"
click node_pricing "https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/pricing.py"
click node_taobao "https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/tb.py"
click node_jd "https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/jd.py"
click node_pdd "https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/pdd.py"
click node_suning "https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/sn.py"
click node_vipshop "https://github.com/why2lyj/youxiang-itchat/tree/master/coupon"
click node_tb_api "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/tb_top_api.py"
click node_jd_api "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/jd_api.py"
click node_pdd_api "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/pdd_api.py"
click node_shortener "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/suo_im.py"
click node_retry "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/retry.py"
click node_common "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/common.py"
click node_ad "https://github.com/why2lyj/youxiang-itchat/blob/master/untils/ad.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_config,node_scheduler,node_retry,node_common,node_ad toneBlue
class node_wechat,node_chat_helper,node_message,node_nlp toneAmber
class node_delivery,node_pricing toneMint
class node_taobao,node_jd,node_pdd,node_suning,node_vipshop,node_tb_api,node_jd_api,node_pdd_api,node_shortener toneRose
class node_operator,node_affiliate_services,node_wechat_service toneIndigo
```

## Components

### Application runtime

- [Program entry](https://github.com/why2lyj/youxiang-itchat/blob/master/main.py): `main.py`
- [Configuration](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/config.py): `untils/config.py`
- [Job scheduler](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/scheduler.py): `untils/scheduler.py`
- [Retry helper](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/retry.py): `untils/retry.py`
- [Common utilities](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/common.py): `untils/common.py`
- [Ad utilities](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/ad.py): `untils/ad.py`

### WeChat interaction

- [WeChat client](https://github.com/why2lyj/youxiang-itchat/blob/master/chat/wechat.py): `chat/wechat.py`
- [Chat utilities](https://github.com/why2lyj/youxiang-itchat/blob/master/chat/itchatHelper.py): `chat/itchatHelper.py`
- [Message handlers](https://github.com/why2lyj/youxiang-itchat/blob/master/chat/message.py): `chat/message.py`
- [Tencent smart chat](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/qq_nlpchat.py): `untils/qq_nlpchat.py`

### Coupon distribution

- [Group delivery](https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/delivery.py): `coupon/delivery.py`
- [Price formatting](https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/pricing.py): `coupon/pricing.py`

### Platform integrations

- [Taobao offers](https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/tb.py): `coupon/tb.py`
- [JD offers](https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/jd.py): `coupon/jd.py`
- [Pinduoduo offers](https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/pdd.py): `coupon/pdd.py`
- [Suning offers](https://github.com/why2lyj/youxiang-itchat/blob/master/coupon/sn.py): `coupon/sn.py`
- [Vipshop offers](https://github.com/why2lyj/youxiang-itchat/tree/master/coupon): `coupon`
- [Taobao API client](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/tb_top_api.py): `untils/tb_top_api.py`
- [JD API client](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/jd_api.py): `untils/jd_api.py`
- [Pinduoduo API client](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/pdd_api.py): `untils/pdd_api.py`
- [JD URL shortener](https://github.com/why2lyj/youxiang-itchat/blob/master/untils/suo_im.py): `untils/suo_im.py`

### Other components

- **Operator**
- **Affiliate platforms**
- **WeChat service**

## Connections

- Operator → Program entry: starts (evidence: `README.md`)
- Program entry → WeChat client: runs (evidence: `main.py`)
- WeChat client → Configuration: reads (evidence: `chat/wechat.py`)
- WeChat client → Job scheduler: starts jobs (evidence: `chat/wechat.py`)
- WeChat client → Message handlers: registers handlers (evidence: `chat/wechat.py`)
- WeChat client → Chat utilities: initializes (evidence: `chat/wechat.py`)
- Message handlers → Tencent smart chat: requests replies (evidence: `chat/message.py`)
- Message handlers → Chat utilities: uses (evidence: `chat/message.py`)
- Chat utilities → Configuration: reads (evidence: `chat/itchatHelper.py`)
- WeChat client → WeChat service: connects (evidence: `README.md`)
- Job scheduler → Configuration: loads jobs (evidence: `untils/scheduler.py`)
- Job scheduler → JD offers: dispatches (evidence: `untils/scheduler.py`)
- Job scheduler → Pinduoduo offers: dispatches (evidence: `untils/scheduler.py`)
- Job scheduler → Taobao offers: schedules offers
- Job scheduler → Suning offers: schedules offers
- Job scheduler → Vipshop offers: planned offers (evidence: `README.md`)
- Taobao offers → Taobao API client: queries (evidence: `coupon/tb.py`)
- Taobao offers → Group delivery: delivers (evidence: `coupon/tb.py`)
- Taobao offers → Price formatting: formats prices (evidence: `coupon/tb.py`)
- JD offers → JD API client: queries (evidence: `coupon/jd.py`)
- JD offers → JD URL shortener: shortens links (evidence: `coupon/jd.py`)
- JD offers → Group delivery: delivers (evidence: `coupon/jd.py`)
- Pinduoduo offers → Pinduoduo API client: queries (evidence: `coupon/pdd.py`)
- Pinduoduo offers → Retry helper: retries calls (evidence: `coupon/pdd.py`)
- Pinduoduo offers → Price formatting: formats prices (evidence: `coupon/pdd.py`)
- Pinduoduo offers → Group delivery: delivers images (evidence: `coupon/pdd.py`)
- Suning offers → Group delivery: sends images (evidence: `coupon/sn.py`)
- Suning offers → WeChat service: sends messages (evidence: `coupon/sn.py`)
- Taobao API client → Affiliate platforms: calls (evidence: `README.md`)
- JD API client → Affiliate platforms: calls (evidence: `README.md`)
- Pinduoduo API client → Affiliate platforms: calls (evidence: `README.md`)
- Group delivery → Common utilities: saves images (evidence: `coupon/delivery.py`)
- Group delivery → WeChat service: sends content (evidence: `coupon/delivery.py`)
- Tencent smart chat → Affiliate platforms: requests NLP (evidence: `untils/qq_nlpchat.py`)
- Message handlers → Ad utilities: uses (evidence: `chat/message.py`)
