# alikhaled17/puppeteer-ocr-pdf architecture

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

- Interactive diagram: https://gitdiagram.com/alikhaled17/puppeteer-ocr-pdf
- Repository: https://github.com/alikhaled17/puppeteer-ocr-pdf

## Overview

This is a small command-line workflow that logs into a configured book website, captures book pages as images, then OCRs and merges them into a searchable PDF. The browser and OCR stages are implemented in two files; the graph preserves that handoff. The README describes the setup and dependencies, while the sampled source shows the runtime calls and file processing.

Main entry points: [`index.js`](https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/index.js) (Capture page images), [`run.py`](https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/run.py) (OCR and page PDFs), [`info.json`](https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/info.json) (Login and book config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Browser capture"]
  node_config["Login and book config<br/>[info.json]"]
  node_capture_pages["Capture page images<br/>[index.js]"]
  node_page_images["Captured page images<br/>[index.js]"]
end

subgraph group_conversion["OCR conversion"]
  node_ocr["OCR and page PDFs<br/>[run.py]"]
  node_searchable_pdf["Searchable book PDF<br/>[run.py]"]
end

node_user(("Operator"))
node_website["Book website"]
node_tesseract["Tesseract OCR"]

node_user -->|"enters credentials"| node_config
node_capture_pages -->|"reads settings"| node_config
node_capture_pages -->|"logs in and navigates"| node_website
node_capture_pages -->|"screenshots pages"| node_page_images
node_capture_pages -->|"spawns with page list"| node_ocr
node_ocr -->|"reads and renames"| node_page_images
node_ocr -->|"requests OCR"| node_tesseract
node_ocr -->|"merges and writes"| node_searchable_pdf

click node_config "https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/info.json"
click node_capture_pages "https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/index.js"
click node_page_images "https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/index.js"
click node_ocr "https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/run.py"
click node_searchable_pdf "https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/run.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_config,node_capture_pages,node_page_images toneBlue
class node_ocr,node_searchable_pdf toneAmber
class node_user,node_website,node_tesseract toneIndigo
```

## Components

### Browser capture

- [Login and book config](https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/info.json): `info.json`
- [Capture page images](https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/index.js): `index.js`
- [Captured page images](https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/index.js): `index.js`

### OCR conversion

- [OCR and page PDFs](https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/run.py): `run.py`
- [Searchable book PDF](https://github.com/alikhaled17/puppeteer-ocr-pdf/blob/master/run.py): `run.py`

### Other components

- **Operator**
- **Book website**
- **Tesseract OCR**

## Connections

- Operator → Login and book config: enters credentials (evidence: `README.md`)
- Capture page images → Login and book config: reads settings (evidence: `index.js`)
- Capture page images → Book website: logs in and navigates (evidence: `index.js`)
- Capture page images → Captured page images: screenshots pages (evidence: `index.js`)
- Capture page images → OCR and page PDFs: spawns with page list (evidence: `index.js`)
- OCR and page PDFs → Captured page images: reads and renames (evidence: `run.py`)
- OCR and page PDFs → Tesseract OCR: requests OCR (evidence: `run.py`)
- OCR and page PDFs → Searchable book PDF: merges and writes (evidence: `run.py`)
