Skip to content

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)

  1. BookGrid.tsx - Library view
  2. Uses: useLiveQuery(db.books.toArray())
  3. Needs: bookApiService.getBooks()
  4. Impact: Can't see imported books

  5. ImportButton.tsx - Book import

  6. Uses: epubService.importEpub() (now fixed)
  7. Should work with current fix

  8. BookCard.tsx - Book display

  9. Uses: type Book from db
  10. Needs: Update to use API Book type

  11. BookCardMenu.tsx - Delete book

  12. Uses: db.books.delete()
  13. Needs: bookApiService.deleteBook()

Priority 2: Annotations (HIGH)

  1. annotationService.ts - Annotation operations
  2. Uses: db.highlights, db.notes, db.chatContexts
  3. Needs: Replace with annotationApiService
  4. Impact: Highlights, notes, chat won't persist

  5. AnnotationsSidebar.tsx - View annotations

  6. Uses: annotationService (which uses db)
  7. Will work once annotationService is migrated

  8. UnifiedAnnotationOverlay.tsx - Annotation display

  9. Uses: annotationService
  10. Will work once annotationService is migrated

Priority 3: Settings (MEDIUM)

  1. ReaderSettings.tsx - Reader settings
  2. Uses: db.settings
  3. Needs: settingsApiService
  4. Impact: Settings won't persist

Priority 4: Chat (MEDIUM)

  1. chatService.ts - Chat operations
  2. Uses: db.settings for API config
  3. Needs: settingsApiService

  4. ChatOverlay.tsx - Chat interface

    • Uses: db for general chats
    • Needs: API endpoint for general chats (not yet implemented)

Priority 5: Type Definitions (LOW)

  1. Type imports - Various components
    • Many components import types from lib/db
    • Needs: Create shared types file or use API types

Migration Order

Phase 1: Library (Now)

  1. ✅ Create shared types
  2. ✅ Migrate BookGrid
  3. ✅ Migrate BookCard
  4. ✅ Migrate BookCardMenu
  5. ✅ Test: Import, view, delete books

Phase 2: Annotations (Next)

  1. ✅ Migrate annotationService to use API
  2. ✅ Update all annotation components
  3. ✅ Test: Create, view, edit, delete annotations

Phase 3: Settings (Then)

  1. ✅ Migrate ReaderSettings
  2. ✅ Migrate chatService
  3. ✅ Test: Settings persistence

Phase 4: Cleanup (Finally)

  1. ✅ Remove old db.ts
  2. ✅ Remove dexie dependencies
  3. ✅ Remove old services
  4. ✅ 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

Let's Start!