# zhaoyingjun/chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/zhaoyingjun/chatbot
- Repository: https://github.com/zhaoyingjun/chatbot

## Overview

The repository contains two products: a Shopping Agent that turns order-page screenshots into analyzable, exportable data, and several Chinese Seq2Seq chatbot implementations across TensorFlow, distributed TensorFlow, and PyTorch. The chatbot workflow is corpus preparation, model training/checkpointing, then web-based inference. Shopping Agent backend-to-utility calls are visible in its API excerpt; its frontend/API connection and the chatbot variants’ broader workflows rely on README documentation where noted.

Main entry points: [`chatagent/shopping-agent/app/main.py`](https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/main.py) (Agent API), [`Chatbot-tensowflow2.0/Seq2seqchatbot/execute.py`](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/execute.py) (Train and predict), [`Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/execute.py`](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/execute.py) (Distributed trainer), [`Chatbot_pytorch/Seq2seqchatbot/execute.py`](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/execute.py) (Train and predict)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shop["Shopping Agent"]
  node_frontend["Agent UI<br/>[frontend.py]"]
  node_api["Agent API<br/>[main.py]"]
  node_browser["Browser control<br/>[web_utils.py]"]
  node_screens["Order screenshots<br/>[web_utils.py]"]
  node_ocr["Order extraction<br/>[ocr_utils.py]"]
  node_model["Chat model<br/>[main.py]"]
  node_excel["Excel export<br/>[excel_utils.py]"]
  node_settings["Agent settings<br/>[config.py]"]
end

subgraph group_tf["TensorFlow Chatbot"]
  node_tfdata["Corpus preparation<br/>[data_util.py]"]
  node_tfexec["Train and predict<br/>[execute.py]"]
  node_tfmodel["Seq2Seq model<br/>[seq2seqModel.py]"]
  node_tfconfig["Model settings<br/>[getConfig.py]"]
  node_tfweb["Chat web app<br/>[app.py]"]
end

subgraph group_dist["Distributed Chatbot"]
  node_distdata["Corpus preparation<br/>[data_util.py]"]
  node_distexec["Distributed trainer<br/>[execute.py]"]
  node_distmodel["Distributed model<br/>[seq2seqModel.py]"]
  node_distconfig["Model settings<br/>[getConfig.py]"]
  node_distweb["Chat web app<br/>[app.py]"]
  node_distptdata["Corpus preparation<br/>[data_util.py]"]
  node_distptexec["Distributed trainer<br/>[execute.py]"]
  node_distptmodel["Distributed model<br/>[seq2seqModel.py]"]
end

subgraph group_pt["PyTorch Chatbot"]
  node_ptdata["Corpus preparation<br/>[data_util.py]"]
  node_ptexec["Train and predict<br/>[execute.py]"]
  node_ptmodel["Attention model<br/>[seq2seqModel.py]"]
  node_ptconfig["Model settings<br/>[getConfig.py]"]
  node_ptweb["Chat web app<br/>[app.py]"]
end

node_user(("User"))

node_user -->|"instructs"| node_frontend
node_frontend -.->|"uses API"| node_api
node_api -->|"controls browser"| node_browser
node_browser -.->|"captures"| node_screens
node_api -->|"analyzes screenshots"| node_ocr
node_api -->|"saves and reads"| node_excel
node_api -->|"requests replies"| node_model
node_api -.->|"uses settings"| node_settings
node_user -.->|"sends message"| node_tfweb
node_tfweb -->|"requests prediction"| node_tfexec
node_tfdata -->|"prepares corpus"| node_tfexec
node_tfexec -.->|"trains and predicts"| node_tfmodel
node_tfexec -.->|"loads settings"| node_tfconfig
node_user -.->|"sends message"| node_distweb
node_distweb -->|"requests prediction"| node_distexec
node_distdata -->|"prepares corpus"| node_distexec
node_distexec -.->|"trains and predicts"| node_distmodel
node_distexec -.->|"loads settings"| node_distconfig
node_user -.->|"sends message"| node_ptweb
node_ptweb -->|"requests prediction"| node_ptexec
node_ptdata -->|"prepares corpus"| node_ptexec
node_ptexec -.->|"trains and predicts"| node_ptmodel
node_ptexec -.->|"loads settings"| node_ptconfig
node_distptdata -->|"prepares corpus"| node_distptexec
node_distptexec -.->|"trains and predicts"| node_distptmodel

click node_frontend "https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/frontend.py"
click node_api "https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/main.py"
click node_browser "https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/web_utils.py"
click node_screens "https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/web_utils.py"
click node_ocr "https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/ocr_utils.py"
click node_model "https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/main.py"
click node_excel "https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/excel_utils.py"
click node_settings "https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/config.py"
click node_tfdata "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/data_util.py"
click node_tfexec "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/execute.py"
click node_tfmodel "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/seq2seqModel.py"
click node_tfconfig "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/config/getConfig.py"
click node_tfweb "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/web/app.py"
click node_distdata "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/data_util.py"
click node_distexec "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/execute.py"
click node_distmodel "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/seq2seqModel.py"
click node_distconfig "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/config/getConfig.py"
click node_distweb "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/web/app.py"
click node_ptdata "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/data_util.py"
click node_ptexec "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/execute.py"
click node_ptmodel "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/seq2seqModel.py"
click node_ptconfig "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/config/getConfig.py"
click node_ptweb "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/web/app.py"
click node_distptdata "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Distribute_seq2seqchatbot/data_util.py"
click node_distptexec "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Distribute_seq2seqchatbot/execute.py"
click node_distptmodel "https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Distribute_seq2seqchatbot/seq2seqModel.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_frontend,node_api,node_browser,node_screens,node_ocr,node_model,node_excel,node_settings,node_user toneBlue
class node_tfdata,node_tfexec,node_tfmodel,node_tfconfig,node_tfweb toneAmber
class node_distdata,node_distexec,node_distmodel,node_distconfig,node_distweb,node_distptdata,node_distptexec,node_distptmodel toneMint
class node_ptdata,node_ptexec,node_ptmodel,node_ptconfig,node_ptweb toneRose
```

## Components

### Shopping Agent

- [Agent UI](https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/frontend.py): `chatagent/shopping-agent/app/frontend.py`
- [Agent API](https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/main.py): `chatagent/shopping-agent/app/main.py`
- [Browser control](https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/web_utils.py): `chatagent/shopping-agent/app/web_utils.py`
- [Order screenshots](https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/web_utils.py): `chatagent/shopping-agent/app/web_utils.py`
- [Order extraction](https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/ocr_utils.py): `chatagent/shopping-agent/app/ocr_utils.py`
- [Chat model](https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/main.py): `chatagent/shopping-agent/app/main.py`
- [Excel export](https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/excel_utils.py): `chatagent/shopping-agent/app/excel_utils.py`
- [Agent settings](https://github.com/zhaoyingjun/chatbot/blob/master/chatagent/shopping-agent/app/config.py): `chatagent/shopping-agent/app/config.py`

### TensorFlow Chatbot

- [Corpus preparation](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/data_util.py): `Chatbot-tensowflow2.0/Seq2seqchatbot/data_util.py`
- [Train and predict](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/execute.py): `Chatbot-tensowflow2.0/Seq2seqchatbot/execute.py`
- [Seq2Seq model](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/seq2seqModel.py): `Chatbot-tensowflow2.0/Seq2seqchatbot/seq2seqModel.py`
- [Model settings](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/config/getConfig.py): `Chatbot-tensowflow2.0/Seq2seqchatbot/config/getConfig.py`
- [Chat web app](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Seq2seqchatbot/web/app.py): `Chatbot-tensowflow2.0/Seq2seqchatbot/web/app.py`

### Distributed Chatbot

- [Corpus preparation](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/data_util.py): `Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/data_util.py`
- [Distributed trainer](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/execute.py): `Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/execute.py`
- [Distributed model](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/seq2seqModel.py): `Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/seq2seqModel.py`
- [Model settings](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/config/getConfig.py): `Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/config/getConfig.py`
- [Chat web app](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/web/app.py): `Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/web/app.py`
- [Corpus preparation](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Distribute_seq2seqchatbot/data_util.py): `Chatbot_pytorch/Distribute_seq2seqchatbot/data_util.py`
- [Distributed trainer](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Distribute_seq2seqchatbot/execute.py): `Chatbot_pytorch/Distribute_seq2seqchatbot/execute.py`
- [Distributed model](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Distribute_seq2seqchatbot/seq2seqModel.py): `Chatbot_pytorch/Distribute_seq2seqchatbot/seq2seqModel.py`

### PyTorch Chatbot

- [Corpus preparation](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/data_util.py): `Chatbot_pytorch/Seq2seqchatbot/data_util.py`
- [Train and predict](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/execute.py): `Chatbot_pytorch/Seq2seqchatbot/execute.py`
- [Attention model](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/seq2seqModel.py): `Chatbot_pytorch/Seq2seqchatbot/seq2seqModel.py`
- [Model settings](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/config/getConfig.py): `Chatbot_pytorch/Seq2seqchatbot/config/getConfig.py`
- [Chat web app](https://github.com/zhaoyingjun/chatbot/blob/master/Chatbot_pytorch/Seq2seqchatbot/web/app.py): `Chatbot_pytorch/Seq2seqchatbot/web/app.py`

### Other components

- **User**

## Connections

- User → Agent UI: instructs (evidence: `README.md`)
- Agent UI → Agent API: uses API (evidence: `README.md`)
- Agent API → Browser control: controls browser (evidence: `chatagent/shopping-agent/app/main.py`)
- Browser control → Order screenshots: captures (evidence: `chatagent/shopping-agent/app/web_utils.py`)
- Agent API → Order extraction: analyzes screenshots (evidence: `chatagent/shopping-agent/app/main.py`)
- Agent API → Excel export: saves and reads (evidence: `chatagent/shopping-agent/app/main.py`)
- Agent API → Chat model: requests replies (evidence: `chatagent/shopping-agent/app/main.py`)
- Agent API → Agent settings: uses settings (evidence: `chatagent/shopping-agent/app/main.py`)
- User → Chat web app: sends message (evidence: `README.md`)
- Chat web app → Train and predict: requests prediction (evidence: `Chatbot-tensowflow2.0/Seq2seqchatbot/web/app.py`)
- Corpus preparation → Train and predict: prepares corpus (evidence: `README.md`)
- Train and predict → Seq2Seq model: trains and predicts
- Train and predict → Model settings: loads settings
- User → Chat web app: sends message (evidence: `README.md`)
- Chat web app → Distributed trainer: requests prediction (evidence: `Chatbot-tensowflow2.0/Distribute_seq2seqchatbot/web/app.py`)
- Corpus preparation → Distributed trainer: prepares corpus (evidence: `README.md`)
- Distributed trainer → Distributed model: trains and predicts
- Distributed trainer → Model settings: loads settings
- User → Chat web app: sends message (evidence: `README.md`)
- Chat web app → Train and predict: requests prediction (evidence: `Chatbot_pytorch/Seq2seqchatbot/web/app.py`)
- Corpus preparation → Train and predict: prepares corpus (evidence: `README.md`)
- Train and predict → Attention model: trains and predicts (evidence: `Chatbot_pytorch/Seq2seqchatbot/execute.py`)
- Train and predict → Model settings: loads settings (evidence: `Chatbot_pytorch/Seq2seqchatbot/execute.py`)
- Corpus preparation → Distributed trainer: prepares corpus (evidence: `README.md`)
- Distributed trainer → Distributed model: trains and predicts
