End-to-end Notion → images pipeline. Reads a chapter from a Notion textbook, refines it via ChatGPT, generates 80 image prompts, renders them via Gemini, then zips the images + refined chapter MD and uploads back to the chapter's Images Notion subpage.
FETCH ─→ REFINE ─→ PROMPTS ─→ IMAGES ─→ UPLOAD
Notion ChatGPT ChatGPT Gemini Notion
All five stages are file-existence-driven idempotent — re-running picks up exactly where it stopped.
:: 1. Extract the zip / clone this repo
:: 2. Double-click setup.bat (one-time — installs deps + launches Chrome)
:: 3. Sign in to ChatGPT and Gemini in the launched Chrome windows (one-time)
:: 4. Edit lessons.txt with chapters you want to generate
:: 5. Double-click start.batSee RUN.md for the click-by-click runbook, SETUP.md for first-time setup, GUIDE.md for an overview, QUICKSTART.md for the same in 90 seconds.
| Path | What |
|---|---|
start.bat / setup.bat |
Click-to-run entry points (Windows) |
lessons.txt (you create it) |
List of chapters to generate — grade,lang,subject,chapter per line |
lessons.txt.example |
Template with format docs |
.env (you create it from .env.example) |
Credentials |
scripts/run_batch.cjs |
Reads lessons.txt, runs the 5-stage pipeline once per chapter |
scripts/run_pipeline.cjs |
Single-chapter orchestrator |
scripts/run_autonomous.cjs |
IMAGES stage orchestrator (saver auto-restart, rescue on stall) |
scripts/dashboard.cjs |
Realtime HTML status board on http://localhost:7777 |
scripts/setup_chrome.cjs |
Launches the two debug-port Chrome windows (9222 ChatGPT, 9223 Gemini) |
scripts/probe_*.cjs |
Diagnostic probes — read tab state during a run |
tools/notion/ |
Notion API client + uploader (multi-part for files >20 MB) |
tools/browser/ |
Playwright drivers for ChatGPT and Gemini |
upload_images.py |
Stage 5 — zips images + refined MD, uploads to chapter's Images subpage |
refine_chapter.py / generate_prompts.py / fetch_chapter.py |
Stage 1–3 entry scripts |
PROMPT_FOR_CLAUDE.md |
Drop-in prompt for AI orchestration / monitoring on another machine |
node scripts/dashboard.cjs
# open http://localhost:7777Single-file Node HTTP server (no npm deps for the dashboard itself). Shows:
- Current lesson + 5 stage cards (animated for the running stage)
- 80-cell image grid filling green as PNGs are saved
- Orchestrator metrics (pending tabs, stall, rescues, 1095 detection)
- Lesson breakdown panel — every chapter ever processed with per-stage chips, completion %, status badge, and Notion-block link if uploaded
- Color-coded log tail
- Pipeline diagnostics (file paths, mtime, .cca state file sizes)
- Windows 10/11 (Chrome auto-launch is Windows-only currently)
- Node.js ≥ 14
- Python ≥ 3.10
- Google Chrome installed
- A Notion integration with Insert content capability and access to your chapter pages
- ChatGPT account + Gemini account (free tier works for ~100 images/day)
| Gemini daily quota | Free Gemini caps at ~100 image generations/day. Hitting it shows as Image Generation Limit Reached page title. Switch accounts or wait 24h. |
| Gemini error 1095 | Content policy filter rejects prompts mentioning religious figures, violence, named living people, etc. Soften and re-run. |
| Windows job-object spawn at depth 4 | run_batch → run_pipeline → run_autonomous → submit/save chain triggers AssignProcessToJobObject (87) on the inner spawn. Orphan run_autonomous.cjs survives and finishes IMAGES regardless; re-run run_batch after to pick up UPLOAD. Not yet patched at the spawn site. |
| Manual Google sign-in required | Automated SSO triggers reCAPTCHA + flags accounts. Sign in once per Chrome profile; sessions persist. |
MIT — see LICENSE if present, otherwise treat this as released under the MIT terms.
v5 — batch mode (lessons.txt) + Notion zip upload (refined MD bundled). Production-tested on G7 Uzbek world-history chapters. See PROMPT_FOR_CLAUDE.md for an orchestration prompt to drive runs from another machine.