feat: add reader infrastructure - Phase 0 database schema and queries
Implement Phase 0 prerequisites for reader functionality including
database schema, SQL queries, and frontend dependencies.
## Database Schema (5 New Tables + 1 Column Addition)
### New Tables Added:
1. **panel_data** - Comic/manga panel detection results
- Stores detected panel boundaries (x, y, width, height)
- Supports grid, ML, and manual detection methods
- JSONB storage for flexible panel structures
2. **reading_speed** - User reading speed statistics
- Tracks pages per minute and total reading time
- Per-user per-media-item tracking
- Enables progress estimation and analytics
3. **dictionary_cache** - Offline dictionary word definitions
- Caches external dictionary lookups
- Reduces API calls and improves performance
- Supports offline reading functionality
4. **reader_settings** - User reader preferences (per-user)
- Stores typography, theme, and display settings
- JSONB storage for flexible configuration
- Per-user customization (fonts, margins, themes)
5. **media_bookmarks** - Enhanced bookmarks with chapter/CFI support
- Unified bookmarking for ebooks, comics, manga, PDFs
- Supports page_number, chapter_number, and epubcfi_position
- Includes notes field for annotations
- Unique constraint on (media_item_id, user_id, title)
### Column Addition:
- **media_items.chapter_metadata** (JSONB) - Caches detected chapter structure
- Stores TOC/chapter detection results
- Prevents re-parsing files on every read
- Populated by ReaderService.DetectChapters()
## Database Queries (12 New Queries)
Added queries for all reader functionality:
- Panel data: GetPanelData, UpsertPanelData
- Reading speed: GetReadingSpeed, CreateReadingSpeed, UpdateReadingSpeed
- Dictionary: GetDictionaryEntry, CreateDictionaryEntry, UpdateDictionaryAccessed
- Settings: GetReaderSettings, UpsertReaderSettings
- Bookmarks: GetMediaBookmarks, CreateMediaBookmark, DeleteMediaBookmark, UpdateMediaBookmark
## Frontend Dependencies
Added to package.json:
- jszip@^3.10.1 - EPUB/comic archive parsing (client-side)
- pdfjs-dist@^3.11.174 - PDF rendering library (Mozilla PDF.js)
## Generated Code
Ran `sqlc generate` to regenerate:
- models.go - Go structs for new tables (55 lines added)
- querier.go - Database query methods (14 lines added)
- queries.sql.go - Compiled SQL queries (504 lines added)
## Implementation Status
Phase 0 prerequisites now complete:
✅ Database schema (5 tables + 1 column)
✅ SQL queries (12 queries)
✅ Frontend dependencies (2 packages)
✅ Generated Go code (sqlc)
✅ Database recreated with new schema
Ready for Phase 1: Infrastructure & Basic Reader implementation.
Related to: Universal web reader for ebooks, comics, manga, PDFs