# afazhriel/booktoskill architecture

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

- Interactive diagram: https://gitdiagram.com/afazhriel/booktoskill
- Repository: https://github.com/afazhriel/booktoskill

## Overview

book-to-skill converts books, folders, globs, and other structured prose into clean text and metadata, then relies on an agent to create an Agent Skills-compatible skill. The main runtime is a CLI that orchestrates input discovery and format-specific extraction; parsers cover PDF, EPUB, DOCX, RTF, HTML, plain text, and Calibre formats. The README also documents analysis-only, generate-from-analysis, and fold-in workflows. Parser and orchestration links reflect the provided excerpts and SOURCE INDEX; the agent-generation stage is documented rather than implemented in the sampled Python runtime.

Main entry points: [`book_to_skill/utils.py`](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/utils.py) (Extraction workflow), [`book_to_skill/parsers/html.py`](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/html.py) (HTML extraction), [`book_to_skill/parsers/text.py`](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/text.py) (Text decoding), [`book_to_skill/cli.py`](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/cli.py) (Command interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["CLI and workflow"]
  node_cli["Command interface<br/>[cli.py]"]
  node_orchestrator["Extraction workflow<br/>[utils.py]"]
  node_config["Formats and paths<br/>[config.py]"]
  node_dependencies["Dependency checks<br/>[dependencies.py]"]
end

subgraph group_extraction["Document extraction"]
  node_pdf["PDF extraction<br/>[pdf.py]"]
  node_epub["EPUB extraction<br/>[epub.py]"]
  node_docx["DOCX extraction<br/>[docx.py]"]
  node_rtf["RTF extraction<br/>[rtf.py]"]
  node_html["HTML extraction<br/>[html.py]"]
  node_text["Text decoding<br/>[text.py]"]
  node_calibre["Calibre formats<br/>[calibre.py]"]
end

subgraph group_processing["Text processing"]
  node_sanitize["Text sanitization<br/>[sanitize.py]"]
  node_workfiles["Extracted text and metadata<br/>[config.py]"]
end

subgraph group_generation["Skill generation"]
  node_agent(("Agent generator"))
  node_skill["Generated skill"]
  node_host(("Agent host"))
end

subgraph group_utilities["Analysis utilities"]
  node_discovery["Discovery tax analysis<br/>[discovery_tax.py]"]
  node_scanner["Generated skill scanner"]
  node_validator["Skill validator<br/>[validate_skill.py]"]
end

node_user(("User"))

node_user -->|"provides sources"| node_cli
node_cli -->|"invokes"| node_orchestrator
node_orchestrator -->|"uses settings"| node_config
node_orchestrator -->|"checks dependencies"| node_dependencies
node_orchestrator -->|"dispatches extraction"| node_pdf
node_orchestrator -->|"dispatches extraction"| node_epub
node_orchestrator -->|"dispatches extraction"| node_docx
node_orchestrator -->|"dispatches extraction"| node_rtf
node_orchestrator -->|"dispatches extraction"| node_html
node_orchestrator -->|"dispatches extraction"| node_text
node_orchestrator -->|"dispatches extraction"| node_calibre
node_epub -->|"parses content"| node_html
node_html -->|"reads files"| node_text
node_rtf -->|"reads files"| node_text
node_orchestrator -.->|"sanitizes text"| node_sanitize
node_orchestrator -->|"writes results"| node_workfiles
node_workfiles -->|"provides extracted content"| node_agent
node_agent -->|"generates"| node_skill
node_skill -->|"loads on demand"| node_host
node_discovery -->|"measures extraction"| node_orchestrator
node_scanner -->|"checks characters"| node_sanitize

click node_cli "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/cli.py"
click node_orchestrator "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/utils.py"
click node_config "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/config.py"
click node_dependencies "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/dependencies.py"
click node_pdf "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/pdf.py"
click node_epub "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/epub.py"
click node_docx "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/docx.py"
click node_rtf "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/rtf.py"
click node_html "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/html.py"
click node_text "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/text.py"
click node_calibre "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/calibre.py"
click node_sanitize "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/sanitize.py"
click node_workfiles "https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/config.py"
click node_discovery "https://github.com/afazhriel/booktoskill/blob/master/tools/discovery_tax.py"
click node_scanner "https://github.com/afazhriel/booktoskill/blob/master/tools/scan_generated_skill.py"
click node_validator "https://github.com/afazhriel/booktoskill/blob/master/tools/validate_skill.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_cli,node_orchestrator,node_config,node_dependencies,node_user toneBlue
class node_pdf,node_epub,node_docx,node_rtf,node_html,node_text,node_calibre toneAmber
class node_sanitize,node_workfiles toneMint
class node_agent,node_skill,node_host toneRose
class node_discovery,node_scanner,node_validator toneIndigo
```

## Components

### CLI and workflow

- [Command interface](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/cli.py): `book_to_skill/cli.py`
- [Extraction workflow](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/utils.py): `book_to_skill/utils.py`
- [Formats and paths](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/config.py): `book_to_skill/config.py`
- [Dependency checks](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/dependencies.py): `book_to_skill/dependencies.py`

### Document extraction

- [PDF extraction](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/pdf.py): `book_to_skill/parsers/pdf.py`
- [EPUB extraction](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/epub.py): `book_to_skill/parsers/epub.py`
- [DOCX extraction](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/docx.py): `book_to_skill/parsers/docx.py`
- [RTF extraction](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/rtf.py): `book_to_skill/parsers/rtf.py`
- [HTML extraction](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/html.py): `book_to_skill/parsers/html.py`
- [Text decoding](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/text.py): `book_to_skill/parsers/text.py`
- [Calibre formats](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/parsers/calibre.py): `book_to_skill/parsers/calibre.py`

### Text processing

- [Text sanitization](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/sanitize.py): `book_to_skill/sanitize.py`
- [Extracted text and metadata](https://github.com/afazhriel/booktoskill/blob/master/book_to_skill/config.py): `book_to_skill/config.py`

### Skill generation

- **Agent generator**
- **Generated skill**
- **Agent host**

### Analysis utilities

- [Discovery tax analysis](https://github.com/afazhriel/booktoskill/blob/master/tools/discovery_tax.py): `tools/discovery_tax.py`
- [Generated skill scanner](https://github.com/afazhriel/booktoskill/blob/master/tools/scan_generated_skill.py): `tools/scan_generated_skill.py`
- [Skill validator](https://github.com/afazhriel/booktoskill/blob/master/tools/validate_skill.py): `tools/validate_skill.py`

### Other components

- **User**

## Connections

- User → Command interface: provides sources (evidence: `README.md`)
- Command interface → Extraction workflow: invokes (evidence: `book_to_skill/cli.py`)
- Extraction workflow → Formats and paths: uses settings (evidence: `book_to_skill/utils.py`)
- Extraction workflow → Dependency checks: checks dependencies (evidence: `book_to_skill/utils.py`)
- Extraction workflow → PDF extraction: dispatches extraction (evidence: `book_to_skill/utils.py`)
- Extraction workflow → EPUB extraction: dispatches extraction (evidence: `book_to_skill/utils.py`)
- Extraction workflow → DOCX extraction: dispatches extraction (evidence: `book_to_skill/utils.py`)
- Extraction workflow → RTF extraction: dispatches extraction (evidence: `book_to_skill/utils.py`)
- Extraction workflow → HTML extraction: dispatches extraction (evidence: `book_to_skill/utils.py`)
- Extraction workflow → Text decoding: dispatches extraction (evidence: `book_to_skill/utils.py`)
- Extraction workflow → Calibre formats: dispatches extraction (evidence: `book_to_skill/utils.py`)
- EPUB extraction → HTML extraction: parses content (evidence: `book_to_skill/parsers/epub.py`)
- HTML extraction → Text decoding: reads files (evidence: `book_to_skill/parsers/html.py`)
- RTF extraction → Text decoding: reads files (evidence: `book_to_skill/parsers/rtf.py`)
- Extraction workflow → Text sanitization: sanitizes text (evidence: `book_to_skill/utils.py`)
- Extraction workflow → Extracted text and metadata: writes results (evidence: `book_to_skill/utils.py`)
- Extracted text and metadata → Agent generator: provides extracted content (evidence: `README.md`)
- Agent generator → Generated skill: generates (evidence: `README.md`)
- Generated skill → Agent host: loads on demand (evidence: `README.md`)
- Discovery tax analysis → Extraction workflow: measures extraction (evidence: `tools/discovery_tax.py`)
- Generated skill scanner → Text sanitization: checks characters (evidence: `tools/scan_generated_skill.py`)
