# suversal/apple-store-inventory-monitor architecture

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

- Interactive diagram: https://gitdiagram.com/suversal/apple-store-inventory-monitor
- Repository: https://github.com/suversal/apple-store-inventory-monitor

## Overview

果到雷达是一个桌面端 Apple 直营店取货库存监控应用。用户选择地区、门店和型号后启动监控；Rust 核心周期性查询并判定库存，结果送到界面展示，并可触发提示音、Bark 推送或页面跳转。图中保留了目录刷新、送货信息、Clash 出口设置和应用内更新等 README 所述能力。核心查询实现未完整采样，相关连线仅按 README 和模块职责表示。

Main entry points: [`src-tauri/src/lib.rs`](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/lib.rs) (桌面命令与事件), [`src/lib/store.ts`](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src/lib/store.ts) (界面状态与命令), [`crates/apw-core/src/notify.rs`](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/notify.rs) (提醒分发), [`crates/apw-core/src/watcher.rs`](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/watcher.rs) (监控调度)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["桌面界面"]
  node_app["监控界面<br/>[App.tsx]"]
  node_ui_store["界面状态与命令<br/>[store.ts]"]
  node_monitor_log["状态与日志展示<br/>[monitorLog.ts]"]
  node_network_ui["网络设置"]
end

subgraph group_shell["应用外壳"]
  node_tauri["桌面命令与事件<br/>[lib.rs]"]
  node_persistent_settings[("设置持久化<br/>[lib.rs]")]
  node_updater["应用更新<br/>[lib.rs]"]
  node_notify["提醒分发<br/>[notify.rs]"]
  node_route_pool["线路轮换<br/>[route_pool.rs]"]
  node_chromium["浏览器查询"]
  node_clash["Clash 控制<br/>[clash.rs]"]
end

subgraph group_engine["监控引擎"]
  node_watcher["监控调度<br/>[watcher.rs]"]
  node_apple_logic["库存查询与判定<br/>[apple.rs]"]
  node_models["领域模型<br/>[model.rs]"]
end

subgraph group_catalog["目录与设置"]
  node_catalog["门店与商品目录<br/>[catalog.rs]"]
  node_online_catalog["在线目录抓取<br/>[apple_catalog.rs]"]
  node_region_data["内嵌目录数据<br/>[lib.rs]"]
  node_config["配置与目标<br/>[config.rs]"]
end

subgraph group_integrations["外部集成"]
  node_apple(("Apple 服务"))
  node_browser(("Chrome / Edge"))
  node_bark(("Bark 推送服务"))
  node_audio(("本机音频"))
  node_clash_service(("Clash 控制器"))
  node_web_pages(("Apple 商品页面"))
  node_desktop_open(("系统页面打开器"))
end

node_user(("用户"))

node_user -->|"配置监控"| node_app
node_app -->|"发起操作"| node_ui_store
node_app -->|"设置线路"| node_network_ui
node_ui_store -->|"调用命令"| node_tauri
node_tauri -->|"控制监控"| node_watcher
node_watcher -->|"执行查询"| node_apple_logic
node_apple_logic -->|"获取库存"| node_chromium
node_chromium -->|"驱动查询"| node_browser
node_browser -->|"请求库存"| node_apple
node_watcher -->|"使用状态模型"| node_models
node_watcher -->|"发送事件"| node_tauri
node_tauri -->|"转发事件"| node_ui_store
node_ui_store -->|"格式化日志"| node_monitor_log
node_ui_store -->|"更新界面"| node_app
node_tauri -->|"处理提醒"| node_notify
node_notify -.->|"推送通知"| node_bark
node_notify -.->|"播放提示音"| node_audio
node_notify -.->|"打开商品页"| node_desktop_open
node_tauri -.->|"打开链接"| node_desktop_open
node_tauri -->|"读写设置"| node_persistent_settings
node_tauri -->|"加载配置"| node_config
node_tauri -->|"提供目录"| node_catalog
node_catalog -->|"刷新目录"| node_online_catalog
node_online_catalog -->|"抓取目录"| node_web_pages
node_catalog -->|"离线兜底"| node_region_data
node_tauri -->|"管理查询线路"| node_route_pool
node_route_pool -->|"查询或切换节点"| node_clash
node_clash -.->|"访问控制接口"| node_clash_service
node_network_ui -->|"保存线路设置"| node_ui_store
node_ui_store -->|"检查或安装更新"| node_updater

click node_app "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src/App.tsx"
click node_ui_store "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src/lib/store.ts"
click node_monitor_log "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src/lib/monitorLog.ts"
click node_network_ui "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src/components/NetworkSettings.tsx"
click node_tauri "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/lib.rs"
click node_persistent_settings "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/lib.rs"
click node_updater "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/lib.rs"
click node_watcher "https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/watcher.rs"
click node_apple_logic "https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/apple.rs"
click node_models "https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/model.rs"
click node_catalog "https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/catalog.rs"
click node_online_catalog "https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/apple_catalog.rs"
click node_region_data "https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/lib.rs"
click node_config "https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/config.rs"
click node_notify "https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/notify.rs"
click node_route_pool "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/route_pool.rs"
click node_chromium "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/chromium_fetcher.rs"
click node_clash "https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/clash.rs"

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_app,node_ui_store,node_monitor_log,node_network_ui toneBlue
class node_tauri,node_persistent_settings,node_updater,node_notify,node_route_pool,node_chromium,node_clash toneAmber
class node_watcher,node_apple_logic,node_models toneMint
class node_catalog,node_online_catalog,node_region_data,node_config toneRose
class node_apple,node_browser,node_bark,node_audio,node_clash_service,node_web_pages,node_desktop_open,node_user toneIndigo
```

## Components

### 桌面界面

- [监控界面](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src/App.tsx): `src/App.tsx`
- [界面状态与命令](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src/lib/store.ts): `src/lib/store.ts`
- [状态与日志展示](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src/lib/monitorLog.ts): `src/lib/monitorLog.ts`
- [网络设置](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src/components/NetworkSettings.tsx): `src/components/NetworkSettings.tsx`

### 应用外壳

- [桌面命令与事件](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [设置持久化](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [应用更新](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [提醒分发](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/notify.rs): `crates/apw-core/src/notify.rs`
- [线路轮换](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/route_pool.rs): `src-tauri/src/route_pool.rs`
- [浏览器查询](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/chromium_fetcher.rs): `src-tauri/src/chromium_fetcher.rs`
- [Clash 控制](https://github.com/suversal/apple-store-inventory-monitor/blob/main/src-tauri/src/clash.rs): `src-tauri/src/clash.rs`

### 监控引擎

- [监控调度](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/watcher.rs): `crates/apw-core/src/watcher.rs`
- [库存查询与判定](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/apple.rs): `crates/apw-core/src/apple.rs`
- [领域模型](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/model.rs): `crates/apw-core/src/model.rs`

### 目录与设置

- [门店与商品目录](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/catalog.rs): `crates/apw-core/src/catalog.rs`
- [在线目录抓取](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/apple_catalog.rs): `crates/apw-core/src/apple_catalog.rs`
- [内嵌目录数据](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/lib.rs): `crates/apw-core/src/lib.rs`
- [配置与目标](https://github.com/suversal/apple-store-inventory-monitor/blob/main/crates/apw-core/src/config.rs): `crates/apw-core/src/config.rs`

### 外部集成

- **Apple 服务**
- **Chrome / Edge**
- **Bark 推送服务**
- **本机音频**
- **Clash 控制器**
- **Apple 商品页面**
- **系统页面打开器**

### Other components

- **用户**

## Connections

- 用户 → 监控界面: 配置监控
- 监控界面 → 界面状态与命令: 发起操作
- 监控界面 → 网络设置: 设置线路
- 界面状态与命令 → 桌面命令与事件: 调用命令
- 桌面命令与事件 → 监控调度: 控制监控
- 监控调度 → 库存查询与判定: 执行查询
- 库存查询与判定 → 浏览器查询: 获取库存
- 浏览器查询 → Chrome / Edge: 驱动查询
- Chrome / Edge → Apple 服务: 请求库存
- 监控调度 → 领域模型: 使用状态模型
- 监控调度 → 桌面命令与事件: 发送事件
- 桌面命令与事件 → 界面状态与命令: 转发事件
- 界面状态与命令 → 状态与日志展示: 格式化日志
- 界面状态与命令 → 监控界面: 更新界面
- 桌面命令与事件 → 提醒分发: 处理提醒
- 提醒分发 → Bark 推送服务: 推送通知
- 提醒分发 → 本机音频: 播放提示音
- 提醒分发 → 系统页面打开器: 打开商品页
- 桌面命令与事件 → 系统页面打开器: 打开链接
- 桌面命令与事件 → 设置持久化: 读写设置
- 桌面命令与事件 → 配置与目标: 加载配置
- 桌面命令与事件 → 门店与商品目录: 提供目录
- 门店与商品目录 → 在线目录抓取: 刷新目录
- 在线目录抓取 → Apple 商品页面: 抓取目录
- 门店与商品目录 → 内嵌目录数据: 离线兜底
- 桌面命令与事件 → 线路轮换: 管理查询线路
- 线路轮换 → Clash 控制: 查询或切换节点
- Clash 控制 → Clash 控制器: 访问控制接口
- 网络设置 → 界面状态与命令: 保存线路设置
- 界面状态与命令 → 应用更新: 检查或安装更新
