Skip to content

taylorren/ai-reader

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

21 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Reader3 - EPUB Reader with AI Analysis

A lightweight, self-hosted EPUB reader with integrated AI analysis capabilities.

Features

Reading Experience

  • ๐Ÿ“š Clean Layout - Three-column design (TOC, Content, AI Panel)
  • ๐Ÿ“– Sticky Navigation - Top navigation bar stays visible while scrolling
  • โŒจ๏ธ Keyboard Shortcuts - Arrow keys for prev/next chapter, ESC to close panels
  • ๐Ÿ”— Internal Links - Footnotes and author comments open in modal popups
  • ๐ŸŽฏ Clickable Covers - Click book covers to start reading instantly

AI & Annotations

  • ๐Ÿค– AI Analysis - Right-click on text for fact-checking or discussion (Ollama local or Cloud)
  • ๏ฟฝ *Personal Comments - Add your own notes without AI (no API cost)
  • ๐Ÿ’พ Manual Save - Choose what to save to avoid clutter
  • โœจ Color-Coded Highlights - Yellow (fact check), Blue (discussion), Green (comments)
  • ๐Ÿท๏ธ Smart Tooltips - Hover over highlights to see type
  • ๐Ÿ—‘๏ธ Edit & Delete - Manage all your highlights and comments
  • ๐ŸŽจ Markdown Support - AI responses render with proper formatting

Library & Organization

  • ๐Ÿ“ Highlights View - See all your notes and analyses for each book
  • ๐Ÿ“ค Export to Markdown - Export highlights with AI context warnings
  • ๐ŸŒ Web Upload - Upload EPUB files via click or drag & drop
  • ๐Ÿ–ผ๏ธ Cover Images - Automatic cover extraction and display
  • ๐Ÿ” Search - Find books by title or author
  • ๐Ÿ—‚๏ธ Organized Storage - All books in books/ directory, data in SQLite

Quick Start

1. Configure Ollama

Edit .env file:

# Ollama
OLLAMA_BASE_URL=http://localhost:11434/v1
OLLAMA_API_KEY=ollama
OLLAMA_MODEL=llama3
OLLAMA_CLOUD_MODEL=gpt-oss:120b-cloud

Then sign your Ollama daemon into Ollama Cloud once:

ollama signin

2. Add Books

Option A: Upload via Web Interface (Recommended)

  1. Start server: uv run server.py
  2. Open http://127.0.0.1:8123
  3. Click the "+" card OR drag & drop EPUB file
  4. Wait for automatic processing

Option B: Command Line

uv run reader3.py your_book.epub

3. Start Server

uv run server.py

The server listens on 0.0.0.0:8123 by default so other devices on your LAN can reach it. You can override that with:

READER_HOST=0.0.0.0 READER_PORT=8123 uv run server.py

4. Read and Analyze

  1. Open http://127.0.0.1:8123
  2. Select a book
  3. Right-click on text โ†’ Choose analysis type
  4. Review AI response in side panel
  5. Save if important
  6. Highlights appear on next visit!

Usage

AI Analysis

  • Select text โ†’ Right-click โ†’ Choose:
    • ๐Ÿ“‹ Fact Check - Verify facts and get context
    • ๐Ÿ’ก Discussion - Deep analysis and insights
    • ๐Ÿ’ฌ Add Comment - Your personal notes (no AI)
  • View response in right panel
  • Click "Save" for important insights

Highlights

  • Yellow - Fact checks
  • Blue - Discussions
  • Green - Your comments
  • Hover to see type, click to view/edit
  • All highlights are editable and deletable

View & Export Highlights

  • Click โ‹ฎ menu on any book โ†’ "View Highlights"
  • See all your notes and analyses in one page
  • Filter by type (Fact Check, Discussion, Comment)
  • Export to markdown for AI processing
  • Context length warnings for large exports
  • Jump directly to any chapter

Keyboard Shortcuts

  • โ† โ†’ - Navigate between chapters
  • ESC - Close panels and modals
  • Works anywhere except when typing in text fields

Project Structure

reader3/
โ”œโ”€โ”€ reader3.py          # EPUB processor
โ”œโ”€โ”€ server.py           # Web server
โ”œโ”€โ”€ database.py         # SQLite operations
โ”œโ”€โ”€ ai_service.py       # AI integration
โ”œโ”€โ”€ books/              # All book data here
โ”‚   โ””โ”€โ”€ book_name_data/
โ”‚       โ”œโ”€โ”€ book.pkl
โ”‚       โ””โ”€โ”€ images/
โ”œโ”€โ”€ templates/          # HTML templates
โ”œโ”€โ”€ reader_data.db      # SQLite database
โ””โ”€โ”€ .env                # API configuration

Data Management

View Your Highlights

  • Click โ‹ฎ menu on any book โ†’ "View Highlights"
  • See all notes, comments, and analyses in one page
  • Filter by type and jump to chapters

View Database (Advanced)

uv run check_database.py

Backup

# Double-click: backup.bat
# Or manually:
copy reader_data.db backups\reader_data_backup.db

Tools

  • check_database.py - View raw database contents (advanced)
  • backup.bat - Quick database backup

Why Ollama Cloud?

  • โœ… Uses the same Ollama workflow as local models
  • โœ… Lets you use larger hosted models without a local GPU
  • โœ… Keeps one provider for both local and cloud modes
  • โœ… Works through Ollama's OpenAI-compatible endpoint

Troubleshooting

API Key Error

  1. Check .env file exists and has correct key
  2. Restart server

No Highlights Showing

  1. Check browser console (F12) for errors
  2. Verify data exists: uv run check_database.py
  3. Hard refresh (Ctrl+Shift+R)

Server Won't Start

  1. Check if port 8123 is available
  2. Verify .env configuration

Run At Startup On Linux

This repo includes a systemd unit template and installer so the app can start on boot. The installed service runs the app with uv run server.py, matching the normal development command.

1. Install dependencies

uv sync

2. Install the systemd service

sudo ./scripts/install-systemd-service.sh

This installs deploy/reader3.service, enables it, and starts it immediately.

3. Check service status

systemctl status reader3.service

4. Open the port on the machine firewall if needed

If you use UFW:

sudo ufw allow 8123/tcp

Then browse to http://<your-linux-machine-ip>:8123 from another device on your home network.

5. Find the machine IP

hostname -I

License

MIT


Note: This project is designed to be simple and hackable. Ask your LLM to modify it however you like!

About

Read book, comment | fact check | discussion with AI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 30.2%
  • Python 29.5%
  • JavaScript 27.5%
  • CSS 11.6%
  • Other 1.2%