# z00326zr/ebook-treasure-chest architecture

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

- Interactive diagram: https://gitdiagram.com/z00326zr/ebook-treasure-chest
- Repository: https://github.com/z00326zr/ebook-treasure-chest

## Overview

电子书下载宝库把按分类整理的书籍及下载链接汇集为可浏览、可搜索的目录。读者可从 GitHub Pages 输入书名、作者或分类词并获取匹配结果；维护者则可从书籍来源站点同步书目，更新分类 Markdown，再生成供搜索页面使用的数据。README 和文件树支持这些主要能力，但搜索前端、批量抓取实现及部分生成关系未提供源码摘录，因此相关连线仅按文档说明或保留为未验证关系。

Main entry points: [`scripts/sync/sync_all_books.py`](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/sync_all_books.py) (全量同步编排), [`scripts/parse_md_to_json.py`](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/parse_md_to_json.py) (Markdown解析), [`scripts/sync/incremental_sync.py`](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/incremental_sync.py) (增量同步编排), [`scripts/sync/test_batch_sync.py`](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/test_batch_sync.py) (批量书目抓取)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_catalog["书目与分类"]
  node_categories["分类书目"]
  node_readme["分类导航<br/>[README.md]"]
end

subgraph group_sync["书目同步"]
  node_backup["目录备份<br/>[backup_md.py]"]
  node_idfinder["最大编号查找"]
  node_fullsync["全量同步编排<br/>[sync_all_books.py]"]
  node_incremental["增量同步编排"]
  node_batchsync["批量书目抓取<br/>[test_batch_sync.py]"]
  node_detailparse["详情与下载解析"]
  node_hotcats["热门分类更新"]
end

subgraph group_search["网页搜索"]
  node_webpage["搜索页面<br/>[index.html]"]
  node_searchjs["实时多词搜索<br/>[search.js]"]
end

subgraph group_pipeline["数据生成"]
  node_mdparser["Markdown解析"]
  node_booksjson[("书目搜索数据<br/>[all-books.json]")]
  node_statsjson["解析统计<br/>[parse-stats.json]"]
  node_indexgen["页面生成<br/>[generate_index.py]"]
end

node_reader(("读者"))
node_maintainer(("维护者"))
node_booksite["书籍来源站"]

node_reader -->|"打开搜索"| node_webpage
node_reader -->|"浏览分类"| node_readme
node_maintainer -.->|"启动全量同步"| node_fullsync
node_maintainer -.->|"启动增量同步"| node_incremental
node_fullsync -->|"备份目录"| node_backup
node_fullsync -->|"查找编号"| node_idfinder
node_fullsync -->|"调用抓取"| node_batchsync
node_fullsync -->|"更新分类导航"| node_hotcats
node_incremental -->|"查找编号"| node_idfinder
node_incremental -->|"调用抓取"| node_batchsync
node_batchsync -.->|"获取书目"| node_booksite
node_batchsync -.->|"写入书目"| node_categories
node_detailparse -->|"读取详情页"| node_booksite
node_hotcats -->|"统计分类"| node_categories
node_hotcats -->|"更新导航"| node_readme
node_fullsync -->|"生成搜索数据"| node_mdparser
node_incremental -->|"生成搜索数据"| node_mdparser
node_mdparser -->|"读取分类文件"| node_categories
node_mdparser -->|"写入书目"| node_booksjson
node_mdparser -->|"写入统计"| node_statsjson
node_indexgen -->|"读取书目"| node_booksjson
node_indexgen -->|"读取统计"| node_statsjson
node_indexgen -.->|"生成页面"| node_webpage
node_webpage -.->|"加载搜索逻辑"| node_searchjs
node_searchjs -.->|"搜索书目"| node_booksjson

click node_categories "https://github.com/z00326zr/ebook-treasure-chest/tree/main/md"
click node_backup "https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/backup_md.py"
click node_idfinder "https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/find_max_book_id.py"
click node_fullsync "https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/sync_all_books.py"
click node_incremental "https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/incremental_sync.py"
click node_batchsync "https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/test_batch_sync.py"
click node_detailparse "https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/parse_book_detail_enhanced.py"
click node_hotcats "https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/update_readme_hot_categories.py"
click node_readme "https://github.com/z00326zr/ebook-treasure-chest/blob/main/README.md"
click node_mdparser "https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/parse_md_to_json.py"
click node_booksjson "https://github.com/z00326zr/ebook-treasure-chest/blob/main/docs/all-books.json"
click node_statsjson "https://github.com/z00326zr/ebook-treasure-chest/blob/main/docs/parse-stats.json"
click node_indexgen "https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/generate_index.py"
click node_webpage "https://github.com/z00326zr/ebook-treasure-chest/blob/main/docs/index.html"
click node_searchjs "https://github.com/z00326zr/ebook-treasure-chest/blob/main/docs/search.js"

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_categories,node_readme toneBlue
class node_backup,node_idfinder,node_fullsync,node_incremental,node_batchsync,node_detailparse,node_hotcats toneAmber
class node_webpage,node_searchjs toneMint
class node_mdparser,node_booksjson,node_statsjson,node_indexgen toneRose
class node_reader,node_maintainer,node_booksite toneIndigo
```

## Components

### 书目与分类

- [分类书目](https://github.com/z00326zr/ebook-treasure-chest/tree/main/md): `md`
- [分类导航](https://github.com/z00326zr/ebook-treasure-chest/blob/main/README.md): `README.md`

### 书目同步

- [目录备份](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/backup_md.py): `scripts/sync/backup_md.py`
- [最大编号查找](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/find_max_book_id.py): `scripts/sync/find_max_book_id.py`
- [全量同步编排](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/sync_all_books.py): `scripts/sync/sync_all_books.py`
- [增量同步编排](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/incremental_sync.py): `scripts/sync/incremental_sync.py`
- [批量书目抓取](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/test_batch_sync.py): `scripts/sync/test_batch_sync.py`
- [详情与下载解析](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/parse_book_detail_enhanced.py): `scripts/sync/parse_book_detail_enhanced.py`
- [热门分类更新](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/sync/update_readme_hot_categories.py): `scripts/sync/update_readme_hot_categories.py`

### 网页搜索

- [搜索页面](https://github.com/z00326zr/ebook-treasure-chest/blob/main/docs/index.html): `docs/index.html`
- [实时多词搜索](https://github.com/z00326zr/ebook-treasure-chest/blob/main/docs/search.js): `docs/search.js`

### 数据生成

- [Markdown解析](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/parse_md_to_json.py): `scripts/parse_md_to_json.py`
- [书目搜索数据](https://github.com/z00326zr/ebook-treasure-chest/blob/main/docs/all-books.json): `docs/all-books.json`
- [解析统计](https://github.com/z00326zr/ebook-treasure-chest/blob/main/docs/parse-stats.json): `docs/parse-stats.json`
- [页面生成](https://github.com/z00326zr/ebook-treasure-chest/blob/main/scripts/generate_index.py): `scripts/generate_index.py`

### Other components

- **读者**
- **维护者**
- **书籍来源站**

## Connections

- 读者 → 搜索页面: 打开搜索 (evidence: `README.md`)
- 读者 → 分类导航: 浏览分类 (evidence: `README.md`)
- 维护者 → 全量同步编排: 启动全量同步
- 维护者 → 增量同步编排: 启动增量同步
- 全量同步编排 → 目录备份: 备份目录 (evidence: `scripts/sync/sync_all_books.py`)
- 全量同步编排 → 最大编号查找: 查找编号 (evidence: `scripts/sync/sync_all_books.py`)
- 全量同步编排 → 批量书目抓取: 调用抓取 (evidence: `scripts/sync/sync_all_books.py`)
- 全量同步编排 → 热门分类更新: 更新分类导航 (evidence: `scripts/sync/sync_all_books.py`)
- 增量同步编排 → 最大编号查找: 查找编号 (evidence: `scripts/sync/incremental_sync.py`)
- 增量同步编排 → 批量书目抓取: 调用抓取 (evidence: `scripts/sync/incremental_sync.py`)
- 批量书目抓取 → 书籍来源站: 获取书目
- 批量书目抓取 → 分类书目: 写入书目
- 详情与下载解析 → 书籍来源站: 读取详情页 (evidence: `scripts/sync/parse_book_detail_enhanced.py`)
- 热门分类更新 → 分类书目: 统计分类 (evidence: `scripts/sync/update_readme_hot_categories.py`)
- 热门分类更新 → 分类导航: 更新导航 (evidence: `scripts/sync/update_readme_hot_categories.py`)
- 全量同步编排 → Markdown解析: 生成搜索数据 (evidence: `scripts/sync/sync_all_books.py`)
- 增量同步编排 → Markdown解析: 生成搜索数据 (evidence: `scripts/sync/incremental_sync.py`)
- Markdown解析 → 分类书目: 读取分类文件 (evidence: `scripts/parse_md_to_json.py`)
- Markdown解析 → 书目搜索数据: 写入书目 (evidence: `scripts/parse_md_to_json.py`)
- Markdown解析 → 解析统计: 写入统计 (evidence: `scripts/parse_md_to_json.py`)
- 页面生成 → 书目搜索数据: 读取书目 (evidence: `scripts/generate_index.py`)
- 页面生成 → 解析统计: 读取统计 (evidence: `scripts/generate_index.py`)
- 页面生成 → 搜索页面: 生成页面
- 搜索页面 → 实时多词搜索: 加载搜索逻辑
- 实时多词搜索 → 书目搜索数据: 搜索书目 (evidence: `README.md`)
