A self-hosted EPUB reader designed for reading books alongside LLMs. Load EPUBs, read chapters, and copy text directly to your favourite LLM. Built with FastAPI and vanilla JavaScript.
- EPUB library — Process any EPUB file into a local library. Add books with a single command, remove by deleting a folder.
- Three-column reader — Navigable table of contents on the left, chapter content in the centre, and an optional AI portrait panel on the right.
- One-click copy — Copy any chapter or section text to your clipboard via the TOC copy buttons, ready to paste into an LLM.
- Augur (AI portraits) — Scroll through a chapter and the app automatically identifies historical figures in view, fetching their Wikipedia portraits and bios. Requires an Anthropic API key.
- Collapsible TOC with scroll spy — Nested table of contents that expands, collapses, and highlights the section you're currently reading.
- Python 3.10+
- uv package manager
# Clone the repository
git clone https://github.com/boivert/history-reader.git
cd history-reader
# Install dependencies
uv sync
# (Optional) Enable Augur portrait extraction
cp .env.example .env
# Edit .env and add your Anthropic API keyDownload an EPUB (e.g. from Project Gutenberg) and process it:
uv run reader3.py dracula.epubThis creates a dracula_data/ folder containing the parsed book data and extracted images.
uv run server.pyVisit localhost:8123 to see your library.
The app has two phases:
-
EPUB Processing (
reader3.py) — Parses an EPUB into a pickledBookobject with cleaned HTML, plain text, images, and an enriched table of contents with heading-level sub-entries. -
Web Server (
server.py) — FastAPI server that loads processed books and serves them through Jinja2 templates. Books are cached in memory via LRU cache. -
Portrait Extraction (
portraits.py) — Sends visible paragraph text to Claude Haiku to extract person names, then fetches portraits and bios from the Wikipedia API.
The frontend is a single-file Jinja2 template (templates/reader.html) containing all HTML, CSS, and JavaScript — no build step, no framework dependencies.
| Action | How |
|---|---|
| Add a book | uv run reader3.py <book.epub> |
| Remove a book | Delete its *_data/ folder |
| List books | Visit localhost:8123 |
MIT
