Skip to content

boivert/history-reader

Repository files navigation

History Reader

History Reader

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.

Features

  • 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.

Getting Started

Prerequisites

  • Python 3.10+
  • uv package manager

Setup

# 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 key

Add a Book

Download an EPUB (e.g. from Project Gutenberg) and process it:

uv run reader3.py dracula.epub

This creates a dracula_data/ folder containing the parsed book data and extracted images.

Start the Server

uv run server.py

Visit localhost:8123 to see your library.

Architecture

The app has two phases:

  1. EPUB Processing (reader3.py) — Parses an EPUB into a pickled Book object with cleaned HTML, plain text, images, and an enriched table of contents with heading-level sub-entries.

  2. Web Server (server.py) — FastAPI server that loads processed books and serves them through Jinja2 templates. Books are cached in memory via LRU cache.

  3. 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.

Library Management

Action How
Add a book uv run reader3.py <book.epub>
Remove a book Delete its *_data/ folder
List books Visit localhost:8123

License

MIT

About

A visual EPUB reader designed for reading books alongside LLMs. Includes auto-fetched portraits for easy name tracking and by-chapter copy-paste.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors