# diocrafts/ai-book-summarizer architecture

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

- Interactive diagram: https://gitdiagram.com/diocrafts/ai-book-summarizer
- Repository: https://github.com/diocrafts/ai-book-summarizer

## Overview

AI EPUB Book Summarizer turns an EPUB into Spanish chapter summaries and a combined book summary. The documented workflow extracts the EPUB, converts its contents into ordered chapter text, summarizes chapters with OpenAI, then summarizes the chapter outputs. The source excerpts show the top-level orchestration and prompt handling; extractor and processor internals were not sampled, so their detailed behavior and internal links are limited to the README’s description.

Main entry points: [`summarize_book.py`](https://github.com/diocrafts/ai-book-summarizer/blob/main/summarize_book.py) (Workflow runner), [`send_prompts.py`](https://github.com/diocrafts/ai-book-summarizer/blob/main/send_prompts.py) (Prompt processor), [`epub_processor.py`](https://github.com/diocrafts/ai-book-summarizer/blob/main/epub_processor.py) (Chapter preparation), [`epub_extractor.py`](https://github.com/diocrafts/ai-book-summarizer/blob/main/epub_extractor.py) (EPUB extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["EPUB ingestion"]
  node_runner["Workflow runner<br/>[summarize_book.py]"]
  node_extractor["EPUB extraction<br/>[epub_extractor.py]"]
  node_processor["Chapter preparation<br/>[epub_processor.py]"]
  node_chapter_text["Ordered chapter text"]
end

subgraph group_summaries["Summary generation"]
  node_prompts["Prompt processor<br/>[send_prompts.py]"]
  node_prompt_template["Base prompt<br/>[base_prompt.txt]"]
  node_openai{{"OpenAI API"}}
end

subgraph group_outputs["Generated outputs"]
  node_chapter_summaries["Chapter summaries"]
  node_book_summary["Book summary"]
end

node_reader(("Book reader"))
node_epub["EPUB book"]
node_reader_result(("Summary reader"))

node_reader -->|"runs"| node_runner
node_reader -->|"provides"| node_epub
node_runner -->|"calls extract"| node_extractor
node_extractor -->|"extracts for processing"| node_processor
node_runner -->|"calls process_epub"| node_processor
node_processor -->|"creates chapter text"| node_chapter_text
node_runner -->|"creates processor"| node_prompts
node_prompts -->|"reads ordered chapters"| node_chapter_text
node_prompts -->|"reads prompt"| node_prompt_template
node_prompts -->|"requests completions"| node_openai
node_prompts -->|"writes summaries"| node_chapter_summaries
node_runner -->|"reads summaries"| node_chapter_summaries
node_runner -->|"sends combined prompt"| node_prompts
node_runner -->|"writes global summary"| node_book_summary
node_reader_result -->|"reads"| node_book_summary

click node_runner "https://github.com/diocrafts/ai-book-summarizer/blob/main/summarize_book.py"
click node_extractor "https://github.com/diocrafts/ai-book-summarizer/blob/main/epub_extractor.py"
click node_processor "https://github.com/diocrafts/ai-book-summarizer/blob/main/epub_processor.py"
click node_prompts "https://github.com/diocrafts/ai-book-summarizer/blob/main/send_prompts.py"
click node_prompt_template "https://github.com/diocrafts/ai-book-summarizer/blob/main/base_prompt.txt"

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_runner,node_extractor,node_processor,node_chapter_text toneBlue
class node_prompts,node_prompt_template,node_openai toneAmber
class node_chapter_summaries,node_book_summary toneMint
class node_reader,node_epub,node_reader_result toneIndigo
```

## Components

### EPUB ingestion

- [Workflow runner](https://github.com/diocrafts/ai-book-summarizer/blob/main/summarize_book.py): `summarize_book.py`
- [EPUB extraction](https://github.com/diocrafts/ai-book-summarizer/blob/main/epub_extractor.py): `epub_extractor.py`
- [Chapter preparation](https://github.com/diocrafts/ai-book-summarizer/blob/main/epub_processor.py): `epub_processor.py`
- **Ordered chapter text**

### Summary generation

- [Prompt processor](https://github.com/diocrafts/ai-book-summarizer/blob/main/send_prompts.py): `send_prompts.py`
- [Base prompt](https://github.com/diocrafts/ai-book-summarizer/blob/main/base_prompt.txt): `base_prompt.txt`
- **OpenAI API**

### Generated outputs

- **Chapter summaries**
- **Book summary**

### Other components

- **Book reader**
- **EPUB book**
- **Summary reader**

## Connections

- Book reader → Workflow runner: runs (evidence: `README.md`)
- Book reader → EPUB book: provides (evidence: `README.md`)
- Workflow runner → EPUB extraction: calls extract (evidence: `summarize_book.py`)
- EPUB extraction → Chapter preparation: extracts for processing (evidence: `README.md`)
- Workflow runner → Chapter preparation: calls process_epub (evidence: `summarize_book.py`)
- Chapter preparation → Ordered chapter text: creates chapter text (evidence: `README.md`)
- Workflow runner → Prompt processor: creates processor (evidence: `summarize_book.py`)
- Prompt processor → Ordered chapter text: reads ordered chapters (evidence: `send_prompts.py`)
- Prompt processor → Base prompt: reads prompt (evidence: `send_prompts.py`)
- Prompt processor → OpenAI API: requests completions (evidence: `send_prompts.py`)
- Prompt processor → Chapter summaries: writes summaries (evidence: `send_prompts.py`)
- Workflow runner → Chapter summaries: reads summaries (evidence: `summarize_book.py`)
- Workflow runner → Prompt processor: sends combined prompt (evidence: `summarize_book.py`)
- Workflow runner → Book summary: writes global summary (evidence: `summarize_book.py`)
- Summary reader → Book summary: reads (evidence: `README.md`)
