How jbiaojerry/ebook-treasure-chest works
1. What this repo is
- This is a static ebook catalog and search site, not a traditional application server.
- The published product lives in docs/ and is intended for GitHub Pages hosting, with all search and navigation happening client-side.
2. Primary content layer
- The large md/ directory is the canonical content store.
- Each Markdown file represents a category/tag page such as 文学.md, 历史.md, Python.md, etc., and contains curated ebook download links or entries for that topic.
- The README’s “热门分类” section is effectively a human-readable summary of these category pages.
3. Generated site output
- docs/index.html is the entry page for the hosted site.
- docs/search.js powers the browser-side search experience.
- docs/books.json, docs/all-books.json, and docs/parse-stats.json are generated data files consumed by the static site.
- docs/.nojekyll indicates GitHub Pages is serving the folder as plain static content, without Jekyll processing.
4. Search architecture
- Search is fully client-side.
- The browser loads prebuilt JSON indexes from docs/, and search.js filters/ranks results in real time.
- The README emphasizes multi-keyword search, so the search index is designed around fast local matching rather than server queries.
5. Data transformation pipeline
- scripts/parse_md_to_json.py is the main bridge from Markdown content to structured JSON.
- scripts/generate_index.py likely turns the category corpus into the searchable homepage/index structure.
- docs/parse-stats.json suggests the generation step also computes content statistics for display or validation.
6. Content sync pipeline
- scripts/sync/ contains the ingestion/update machinery:
- sync_all_books.py for full corpus refreshes
- incremental_sync.py for partial updates
- find_max_book_id.py and max_book_id_found.txt for checkpointing incremental state
- parse_book_detail_enhanced.py for extracting richer book metadata
- backup_md.py for preserving existing Markdown before overwrites
- This is the boundary where external ebook source data is normalized into the repo’s markdown format.
7. Automation and build orchestration
- .github/workflows/full-sync.yml handles complete refresh runs.
- .github/workflows/incremental-sync.yml handles ongoing deltas.
- .github/workflows/generate-site.yml rebuilds/publishes the static site artifacts.
- The architecture is therefore GitHub Actions + generated static assets, with no always-on backend service.
8. Quality and validation
- scripts/sync/test_batch_sync.py indicates batch-sync behavior is tested before or during ingestion.
- The presence of backup and checkpoint files shows the repo is designed to recover from partial sync failures and avoid losing curated Markdown content.
9. README generation / topical curation
- scripts/sync/update_readme_hot_categories.py appears to keep the README’s “热门分类” list aligned with actual category popularity.
- This means the README is not just documentation; it is partly a generated/maintained presentation layer over the corpus.
10. End-to-end data flow
- External ebook sources → sync scripts → Markdown category files in md/ → parser/generator scripts → JSON + HTML assets in docs/ → GitHub Pages static site → browser-side search/navigation.
11. Important architectural boundary
- The repo cleanly separates:
- source content and curation in md/
- generation logic in scripts/
- published runtime in docs/
- That boundary is the key to drawing the architecture diagram correctly: the site is a generated artifact, not a live application with a server database.
12. Overall shape
- Think of it as a content pipeline + static site renderer + GitHub Pages deployment.
- The core user experience is browsing and searching a large, precomputed ebook index, while maintenance is handled by scheduled or manual GitHub Actions workflows.
Main entry points: generate-site.yml Publish WF · search.js Search UI · parse_md_to_json.py MD parser · generate_index.py Index builder
Components 21
Content corpus
Canonical Markdown category pages and curated reading lists.
- README · Human-facing entry point with hot categories and repo guidance.
README.md - Category MD · Large set of topic pages that define the ebook catalog and tags.
- Top topics · Representative high-traffic categories such as 文学, 历史, Python, AI, and related topic pages.
Build and sync
Scripts that transform, refresh, and validate the corpus.
- MD parser · Converts markdown category pages into structured JSON data.
scripts/parse_md_to_json.py - Index builder · Builds the searchable site index and homepage-facing artifacts.
scripts/generate_index.py - Full sync · Performs complete corpus refresh from external ebook sources.
scripts/sync/sync_all_books.py - Delta sync · Handles partial updates and incremental corpus changes.
scripts/sync/incremental_sync.py - Book parser · Extracts richer book metadata during sync.
scripts/sync/parse_book_detail_enhanced.py - MD backup · Preserves markdown content before overwrite or regeneration.
scripts/sync/backup_md.py - Sync checkpoint · Tracks the last processed book ID for incremental runs.
max_book_id_found.txt - Batch test · Checks batch sync behavior during ingestion.
scripts/sync/test_batch_sync.py - Hot categories · Keeps README category highlights aligned with corpus popularity.
scripts/sync/update_readme_hot_categories.py
Published site
Static assets served from GitHub Pages.
- Home page · GitHub Pages entry page for browsing the catalog.
docs/index.html - Search UI · Browser-side search and ranking over prebuilt JSON indexes.
docs/search.js - Books index · Primary JSON catalog consumed by the static site.
docs/books.json - All books · Expanded JSON dataset used by the site and search flow.
docs/all-books.json - Parse stats · Content statistics emitted during generation for display or validation.
docs/parse-stats.json - No Jekyll · Ensures GitHub Pages serves the docs folder as plain static content.
docs/.nojekyll
GitHub Actions
Automated workflows for refresh and deployment.
- Full sync WF · GitHub Actions workflow for complete refresh runs.
.github/workflows/full-sync.yml - Delta WF · GitHub Actions workflow for incremental updates.
.github/workflows/incremental-sync.yml - Publish WF · GitHub Actions workflow that rebuilds and publishes static site artifacts.
.github/workflows/generate-site.yml
Connections 28
- README → Top topics: summarizes · README highlights the major topical categories reflected in markdown pages.
- Category MD → MD parser: feeds · Markdown category pages are parsed into structured data.
- MD parser → Books index: emits · Parser produces the main books JSON artifact.
- MD parser → All books: emits · Parser also contributes the broader catalog dataset.
- MD parser → Parse stats: emits · Generation step records parsing statistics.
- Index builder → Home page: builds · Index generator produces the homepage and site shell.
- Index builder → Books index: consumes · Site generator uses the structured catalog data.
- Index builder → All books: consumes · Site generator uses the expanded book dataset.
- Home page → Search UI: loads · The static home page loads the client search script.
- Search UI → Books index: queries · Browser search filters the prebuilt catalog index.
- Search UI → All books: queries · Browser search can also inspect the larger catalog dataset.
- Search UI → Parse stats: may read · Search or display logic can use generation statistics as supporting data.
- Full sync → Book parser: uses · Full sync enriches book records during ingestion.
- Delta sync → Book parser: uses · Delta sync also extracts detailed metadata.
- Full sync → MD backup: protects · Full refresh backs up markdown before overwriting content.
- Delta sync → MD backup: protects · Incremental updates preserve existing markdown first.
- Delta sync → Sync checkpoint: tracks · Incremental sync relies on the last processed book ID.
- Full sync → Batch test: checks · Batch behavior is validated during sync runs.
- Hot categories → README: updates · Hot category generation keeps the README presentation current.
- Full sync WF → Full sync: runs · Full-sync workflow executes the corpus refresh job.
- Delta WF → Delta sync: runs · Incremental workflow executes delta ingestion.
- Publish WF → Index builder: runs · Site workflow rebuilds the generated index and assets.
- Publish WF → Search UI: publishes · Workflow publishes the client-side search runtime with the site.
- Publish WF → Home page: publishes · Workflow publishes the static entry page.
- Publish WF → Books index: publishes · Workflow deploys the generated catalog data.
- Publish WF → All books: publishes · Workflow deploys the expanded book dataset.
- Publish WF → Parse stats: publishes · Workflow deploys generated parsing statistics.
- Publish WF → No Jekyll: publishes · Workflow keeps GitHub Pages serving the docs folder as static files.