Migration Plan - IndexedDB to API¶
Current Status¶
✅ Completed: - Backend API (all endpoints working) - API client services (bookApiService, annotationApiService, settingsApiService) - Logging and diagnostics - epubService (book loading) - BookViewer (progress tracking)
Components Still Using IndexedDB¶
Priority 1: Core Functionality (CRITICAL)¶
BookGrid.tsx- Library view- Uses:
useLiveQuery(db.books.toArray()) - Needs:
bookApiService.getBooks() -
Impact: Can't see imported books
-
ImportButton.tsx- Book import - Uses:
epubService.importEpub()(now fixed) -
Should work with current fix
-
BookCard.tsx- Book display - Uses:
type Bookfrom db -
Needs: Update to use API Book type
-
BookCardMenu.tsx- Delete book - Uses:
db.books.delete() - Needs:
bookApiService.deleteBook()
Priority 2: Annotations (HIGH)¶
annotationService.ts- Annotation operations- Uses:
db.highlights,db.notes,db.chatContexts - Needs: Replace with
annotationApiService -
Impact: Highlights, notes, chat won't persist
-
AnnotationsSidebar.tsx- View annotations - Uses:
annotationService(which uses db) -
Will work once annotationService is migrated
-
UnifiedAnnotationOverlay.tsx- Annotation display - Uses:
annotationService - Will work once annotationService is migrated
Priority 3: Settings (MEDIUM)¶
ReaderSettings.tsx- Reader settings- Uses:
db.settings - Needs:
settingsApiService - Impact: Settings won't persist
Priority 4: Chat (MEDIUM)¶
chatService.ts- Chat operations- Uses:
db.settingsfor API config -
Needs:
settingsApiService -
ChatOverlay.tsx- Chat interface- Uses:
dbfor general chats - Needs: API endpoint for general chats (not yet implemented)
- Uses:
Priority 5: Type Definitions (LOW)¶
- Type imports - Various components
- Many components import types from
lib/db - Needs: Create shared types file or use API types
- Many components import types from
Migration Order¶
Phase 1: Library (Now)¶
- ✅ Create shared types
- ✅ Migrate BookGrid
- ✅ Migrate BookCard
- ✅ Migrate BookCardMenu
- ✅ Test: Import, view, delete books
Phase 2: Annotations (Next)¶
- ✅ Migrate annotationService to use API
- ✅ Update all annotation components
- ✅ Test: Create, view, edit, delete annotations
Phase 3: Settings (Then)¶
- ✅ Migrate ReaderSettings
- ✅ Migrate chatService
- ✅ Test: Settings persistence
Phase 4: Cleanup (Finally)¶
- ✅ Remove old db.ts
- ✅ Remove dexie dependencies
- ✅ Remove old services
- ✅ Final testing
Estimated Time¶
- Phase 1: 30-45 minutes
- Phase 2: 45-60 minutes
- Phase 3: 20-30 minutes
- Phase 4: 15-20 minutes
Total: ~2-3 hours