Context
Part of the Book Sources architecture evolution. After Phase R1 (Book Sources Refactor), Tome's database schema now supports books existing in multiple sources simultaneously via the book_sources many-to-many table.
Dependencies
Blocked by: #185 (Support non-Calibre books)
- Must wait until Phase R1 (Book Sources Refactor) is released and stable in production
- Requires Phase R2 (Remove calibre_id) to be completed for full architectural consistency
- UI already supports displaying multiple source badges (implemented in Phase R1.6)
Goal
Enable Tome to track books that exist in both Calibre and Audiobookshelf simultaneously, allowing users to:
- See which books have audiobook versions
- Track progress separately for ebook (Calibre) vs audiobook (Audiobookshelf)
- Display both source badges in the UI
- Sync metadata from both sources with configurable priority
Current State
After Phase R1:
- ✅
book_sources table supports many-to-many relationships
- ✅ UI components already display multiple provider badges
- ✅
provider_configs table manages provider priority for metadata conflicts
- ✅
bookSourceRepository provides all necessary CRUD operations
- ❌ No Audiobookshelf provider implementation exists
- ❌ No sync service for Audiobookshelf
Scope
1. Provider Configuration
2. Audiobookshelf Provider Implementation
3. Sync Service
4. Book Matching Logic
5. Metadata Conflict Resolution
6. UI Updates
7. Progress Tracking
8. Testing
9. Documentation
Design Decisions Needed
-
Book Matching Strategy:
- Should we automatically create
book_sources links when ISBN matches?
- Should we require user confirmation for fuzzy matches?
- How do we handle series matching?
-
Progress Tracking:
- One session for both sources, or separate sessions?
- How to display dual progress in UI?
- Should audiobook duration be converted to page equivalents?
-
Sync Direction:
- One-way (Audiobookshelf → Tome only)?
- Two-way sync?
- What data flows in each direction?
-
Conflict Resolution:
- What happens when both sources update the same metadata?
- Should we log conflicts for user review?
- Can users manually select preferred source per field?
Research Needed
Timeline
Estimated: 30-40 hours (1-2 weeks)
- Research & planning: 4 hours
- Provider implementation: 8 hours
- Sync service: 12 hours
- Book matching: 6 hours
- UI updates: 4 hours
- Testing: 4 hours
- Documentation: 2 hours
Risk Assessment
High Risk:
- Book matching logic is complex and error-prone
- Metadata conflicts could cause data loss if not handled carefully
Medium Risk:
- Audiobookshelf API might not support all features we need
- Progress tracking for audiobooks vs ebooks is conceptually different
Mitigation:
- Start with read-only sync (Audiobookshelf → Tome)
- Implement comprehensive logging for debugging
- Add user confirmation for all automatic matches
- Backup database before first sync
Success Criteria
Future Enhancements (Out of Scope)
- Automatic sync on schedule
- Webhook-based real-time sync
- Manual book linking UI (drag-and-drop to link books)
- Multiple Audiobookshelf servers
- Plex audiobooks integration
Context
Part of the Book Sources architecture evolution. After Phase R1 (Book Sources Refactor), Tome's database schema now supports books existing in multiple sources simultaneously via the
book_sourcesmany-to-many table.Dependencies
Blocked by: #185 (Support non-Calibre books)
Goal
Enable Tome to track books that exist in both Calibre and Audiobookshelf simultaneously, allowing users to:
Current State
After Phase R1:
book_sourcestable supports many-to-many relationshipsprovider_configstable manages provider priority for metadata conflictsbookSourceRepositoryprovides all necessary CRUD operationsScope
1. Provider Configuration
2. Audiobookshelf Provider Implementation
lib/providers/audiobookshelf.provider.tsIMetadataProviderinterface3. Sync Service
lib/services/audiobookshelf-sync.service.ts4. Book Matching Logic
book_sourcesentries when match found5. Metadata Conflict Resolution
book_sources.is_primary6. UI Updates
7. Progress Tracking
8. Testing
9. Documentation
Design Decisions Needed
Book Matching Strategy:
book_sourceslinks when ISBN matches?Progress Tracking:
Sync Direction:
Conflict Resolution:
Research Needed
Timeline
Estimated: 30-40 hours (1-2 weeks)
Risk Assessment
High Risk:
Medium Risk:
Mitigation:
Success Criteria
book_sourcesentriesFuture Enhancements (Out of Scope)