# nizitao/wechatvibe architecture

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

- Interactive diagram: https://gitdiagram.com/nizitao/wechatvibe
- Repository: https://github.com/nizitao/wechatvibe

## Overview

WechatVibe is a Windows desktop client for browsing locally stored WeChat conversations and producing message insights and person/group portraits. The main workflow is: select an account and conversations, read paged history, request message or portrait analysis, then view persisted results and progress. Analysis can use local Laya inference or a configured API provider. The graph preserves the documented history, account, model, and portrait branches; some runtime wiring is documented only at product level, so those links cite the README rather than unsampled implementation.

Main entry points: [`bridge/backend_service.py`](https://github.com/nizitao/wechatvibe/blob/main/bridge/backend_service.py) (Application service), [`chatui/app.js`](https://github.com/nizitao/wechatvibe/blob/main/chatui/app.js) (Chat and settings UI), [`native-reader/wr/service.py`](https://github.com/nizitao/wechatvibe/blob/main/native-reader/wr/service.py) (Native database reader), [`bridge/batch_engine.py`](https://github.com/nizitao/wechatvibe/blob/main/bridge/batch_engine.py) (Incremental message analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop experience"]
  node_desktop["Chat and settings UI<br/>[app.js]"]
end

subgraph group_service["Application services"]
  node_history["History browser<br/>[history_browser.py]"]
  node_backend["Application service<br/>[backend_service.py]"]
  node_selection["Conversation selection"]
  node_batch["Incremental message analysis<br/>[batch_engine.py]"]
  node_portrait["Portrait statistics"]
end

subgraph group_reader["WeChat data access"]
  node_wechat["WeChat source adapter<br/>[wechat_source.py]"]
  node_native["Native database reader<br/>[service.py]"]
  node_discovery["Account discovery<br/>[discovery.py]"]
  node_dbread["Decrypted SQLite queries<br/>[database.py]"]
end

subgraph group_analysis["Analysis engines"]
  node_local["Local Laya analysis<br/>[analysis.ts]"]
  node_laya["Laya inference runtime<br/>[agent.ts]"]
  node_apiinsight["API message insights"]
  node_apiportrait["API portrait evidence"]
  node_connectors["Model connectors"]
end

subgraph group_state["Persistent state"]
  node_resultstore[("Analysis and portrait store<br/>[result_store.py]")]
  node_batchstate[("Batch progress state<br/>[batch_state.py]")]
end

node_user(("User"))
node_modelservice{{"Configured model service"}}
node_wechatdb[("Local WeChat databases")]

node_user -->|"uses"| node_desktop
node_desktop -->|"requests analysis"| node_backend
node_desktop -->|"browses history"| node_history
node_desktop -->|"selects conversations"| node_selection
node_backend -->|"loads conversations"| node_wechat
node_backend -->|"runs incremental analysis"| node_batch
node_backend -->|"coordinates portraits"| node_portrait
node_wechat -->|"reads account data"| node_native
node_native -->|"discovers accounts"| node_discovery
node_native -->|"queries shards"| node_dbread
node_native -->|"reads"| node_wechatdb
node_batch -->|"stores outcomes"| node_resultstore
node_batch -.->|"tracks batches"| node_batchstate
node_backend -->|"loads saved results"| node_resultstore
node_backend -->|"requests local inference"| node_local
node_local -->|"runs inference"| node_laya
node_backend -->|"requests API insights"| node_apiinsight
node_backend -->|"requests API portraits"| node_apiportrait
node_apiinsight -->|"generates with"| node_connectors
node_apiportrait -->|"generates with"| node_connectors
node_connectors -->|"sends requests"| node_modelservice
node_portrait -->|"persists portraits"| node_resultstore

click node_desktop "https://github.com/nizitao/wechatvibe/blob/main/chatui/app.js"
click node_history "https://github.com/nizitao/wechatvibe/blob/main/bridge/history_browser.py"
click node_backend "https://github.com/nizitao/wechatvibe/blob/main/bridge/backend_service.py"
click node_selection "https://github.com/nizitao/wechatvibe/blob/main/bridge/conversation_selection.py"
click node_batch "https://github.com/nizitao/wechatvibe/blob/main/bridge/batch_engine.py"
click node_portrait "https://github.com/nizitao/wechatvibe/blob/main/bridge/api_portrait_statistics.py"
click node_wechat "https://github.com/nizitao/wechatvibe/blob/main/bridge/wechat_source.py"
click node_native "https://github.com/nizitao/wechatvibe/blob/main/native-reader/wr/service.py"
click node_discovery "https://github.com/nizitao/wechatvibe/blob/main/native-reader/wr/discovery.py"
click node_dbread "https://github.com/nizitao/wechatvibe/blob/main/native-reader/wr/database.py"
click node_local "https://github.com/nizitao/wechatvibe/blob/main/electron/analysis.ts"
click node_laya "https://github.com/nizitao/wechatvibe/blob/main/electron/laya/agent.ts"
click node_apiinsight "https://github.com/nizitao/wechatvibe/blob/main/electron/api-message-insights.ts"
click node_apiportrait "https://github.com/nizitao/wechatvibe/blob/main/electron/api-portrait-evidence.ts"
click node_connectors "https://github.com/nizitao/wechatvibe/blob/main/electron/model-connectors.ts"
click node_resultstore "https://github.com/nizitao/wechatvibe/blob/main/bridge/result_store.py"
click node_batchstate "https://github.com/nizitao/wechatvibe/blob/main/bridge/batch_state.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_desktop,node_user toneBlue
class node_history,node_backend,node_selection,node_batch,node_portrait,node_wechatdb toneAmber
class node_wechat,node_native,node_discovery,node_dbread toneMint
class node_local,node_laya,node_apiinsight,node_apiportrait,node_connectors toneRose
class node_resultstore,node_batchstate,node_modelservice toneIndigo
```

## Components

### Desktop experience

- [Chat and settings UI](https://github.com/nizitao/wechatvibe/blob/main/chatui/app.js): `chatui/app.js`

### Application services

- [History browser](https://github.com/nizitao/wechatvibe/blob/main/bridge/history_browser.py): `bridge/history_browser.py`
- [Application service](https://github.com/nizitao/wechatvibe/blob/main/bridge/backend_service.py): `bridge/backend_service.py`
- [Conversation selection](https://github.com/nizitao/wechatvibe/blob/main/bridge/conversation_selection.py): `bridge/conversation_selection.py`
- [Incremental message analysis](https://github.com/nizitao/wechatvibe/blob/main/bridge/batch_engine.py): `bridge/batch_engine.py`
- [Portrait statistics](https://github.com/nizitao/wechatvibe/blob/main/bridge/api_portrait_statistics.py): `bridge/api_portrait_statistics.py`

### WeChat data access

- [WeChat source adapter](https://github.com/nizitao/wechatvibe/blob/main/bridge/wechat_source.py): `bridge/wechat_source.py`
- [Native database reader](https://github.com/nizitao/wechatvibe/blob/main/native-reader/wr/service.py): `native-reader/wr/service.py`
- [Account discovery](https://github.com/nizitao/wechatvibe/blob/main/native-reader/wr/discovery.py): `native-reader/wr/discovery.py`
- [Decrypted SQLite queries](https://github.com/nizitao/wechatvibe/blob/main/native-reader/wr/database.py): `native-reader/wr/database.py`

### Analysis engines

- [Local Laya analysis](https://github.com/nizitao/wechatvibe/blob/main/electron/analysis.ts): `electron/analysis.ts`
- [Laya inference runtime](https://github.com/nizitao/wechatvibe/blob/main/electron/laya/agent.ts): `electron/laya/agent.ts`
- [API message insights](https://github.com/nizitao/wechatvibe/blob/main/electron/api-message-insights.ts): `electron/api-message-insights.ts`
- [API portrait evidence](https://github.com/nizitao/wechatvibe/blob/main/electron/api-portrait-evidence.ts): `electron/api-portrait-evidence.ts`
- [Model connectors](https://github.com/nizitao/wechatvibe/blob/main/electron/model-connectors.ts): `electron/model-connectors.ts`

### Persistent state

- [Analysis and portrait store](https://github.com/nizitao/wechatvibe/blob/main/bridge/result_store.py): `bridge/result_store.py`
- [Batch progress state](https://github.com/nizitao/wechatvibe/blob/main/bridge/batch_state.py): `bridge/batch_state.py`

### Other components

- **User**
- **Configured model service**
- **Local WeChat databases**

## Connections

- User → Chat and settings UI: uses (evidence: `README.md`)
- Chat and settings UI → Application service: requests analysis (evidence: `README.md`)
- Chat and settings UI → History browser: browses history (evidence: `README.md`)
- Chat and settings UI → Conversation selection: selects conversations (evidence: `README.md`)
- Application service → WeChat source adapter: loads conversations (evidence: `bridge/backend_service.py`)
- Application service → Incremental message analysis: runs incremental analysis (evidence: `bridge/backend_service.py`)
- Application service → Portrait statistics: coordinates portraits (evidence: `bridge/backend_service.py`)
- WeChat source adapter → Native database reader: reads account data (evidence: `bridge/wechat_source.py`)
- Native database reader → Account discovery: discovers accounts (evidence: `native-reader/wr/service.py`)
- Native database reader → Decrypted SQLite queries: queries shards (evidence: `native-reader/wr/service.py`)
- Native database reader → Local WeChat databases: reads (evidence: `README.md`)
- Incremental message analysis → Analysis and portrait store: stores outcomes (evidence: `bridge/backend_service.py`)
- Incremental message analysis → Batch progress state: tracks batches (evidence: `bridge/batch_engine.py`)
- Application service → Analysis and portrait store: loads saved results (evidence: `bridge/backend_service.py`)
- Application service → Local Laya analysis: requests local inference (evidence: `README.md`)
- Local Laya analysis → Laya inference runtime: runs inference (evidence: `electron/analysis.ts`)
- Application service → API message insights: requests API insights (evidence: `README.md`)
- Application service → API portrait evidence: requests API portraits (evidence: `README.md`)
- API message insights → Model connectors: generates with (evidence: `electron/api-message-insights.ts`)
- API portrait evidence → Model connectors: generates with (evidence: `electron/api-portrait-evidence.ts`)
- Model connectors → Configured model service: sends requests (evidence: `README.md`)
- Portrait statistics → Analysis and portrait store: persists portraits (evidence: `bridge/backend_service.py`)
