Skip to Content
FeaturesBooksIntegration

Books Module Integration Guide

Quick Start

The Books module has been fully implemented and integrated into the Oter codebase. Here’s what you need to know:

What Was Created

Module Structure

books/ ├── books_data/ # Data layer (Room, DAOs, DataSource) ├── books_domain/ # Domain layer (Models, Repository, Use Cases) ├── books_presentation/ # Presentation layer (UI, ViewModels, Navigation) └── README.md # Full documentation

Key Files

Data Layer:

  • BookDao.kt / ReadingLogDao.kt - Room DAOs
  • BookLocalDataSource.kt - Offline-first data source
  • BooksRepositoryImpl.kt - Repository implementation
  • Room entities: Book, ReadingLog

Domain Layer:

  • Models: Book, ReadingLog, BookStatus, BookDetail, BooksStats
  • BooksRepository interface
  • Use cases: GetBooks, AddBook, UpdateBookStatus, LogReadingMinutes, etc.

Presentation Layer:

  • ViewModels: BooksViewModel, BookDetailViewModel, BooksStatsViewModel
  • Screens: BooksLibraryScreen, BookDetailScreen, BooksStatsScreen
  • Bottom Sheets: AddBookBottomSheet, LogMinutesBottomSheet
  • Navigation: BooksNavGraph.kt, BooksDestination.kt

Integration Steps

1. Database Migration

The AppDatabase has been updated to version 6 with the new entities:

  • Book entity
  • ReadingLog entity
  • BookDao and ReadingLogDao added

2. Dependency Injection

  • BooksDataModule - Provides data layer dependencies
  • BooksDomainModule - Provides use cases
  • AppModule - Provides DAOs

3. Navigation

The books graph has been added to NavHostWrapper.kt:

booksGraph(navController)

4. Routes

  • books - Main library screen
  • books/{bookId} - Book detail screen
  • books/stats - Statistics screen

How to Access

From Navigation

Navigate to the books screen:

navController.navigate("books")

Add to Bottom Navigation (Optional)

If you want to add Books to the bottom navigation, update Routes.kt:

val BOOKS = BottomNavRoute("books", "books", "Books")

Then add it to your navigation graph.

Testing the Module

  1. Add a Book:

    • Navigate to books
    • Tap ”+” FAB
    • Enter title (required), author (optional)
    • Tap “Add”
  2. Log Reading Time:

    • Open a book detail
    • Tap “Log Minutes”
    • Enter minutes and date
    • Tap “Log”
    • If book was WANT, it auto-transitions to READING
  3. Change Status:

    • From book detail, use action buttons:
      • “Start Reading” → READING
      • “Finish Book” → FINISHED
      • “Drop Book” → DROPPED
  4. View Stats:

    • Tap stats icon in library
    • View reading statistics

Features

Minimal Friction:

  • Add book: Title only (author optional)
  • Log minutes: Default 15 min, today’s date
  • Big tap targets, no multi-step flows

Automatic Transitions:

  • Logging minutes on WANT → automatically sets to READING
  • Records startedAt when first moved to READING
  • Records finishedAt when FINISHED

Offline-First:

  • All data stored locally in Room
  • No network required
  • Fast, instant operations

Stats Tracking:

  • Minutes today/week/month
  • Reading streak (consecutive days)
  • Books finished this month
  • Currently reading count

Database Schema

books table:

  • id, title, author (nullable), status, createdAt, updatedAt, startedAt (nullable), finishedAt (nullable)

reading_logs table:

  • id, bookId, date (YYYY-MM-DD), minutes, createdAt

Notes

  • No notes/highlights: As per requirements, this is tracking-only
  • Time-based only: No page/chapter tracking in MVP
  • Local storage only: No sync/cloud features
  • Simple UI: Fast, minimal, focused on quick logging

Troubleshooting

If you encounter issues:

  1. Database migration: Ensure app database version is 6
  2. DI errors: Check that BooksDataModule and BooksDomainModule are properly installed
  3. Navigation: Verify booksGraph is added to NavHostWrapper
  4. Imports: All imports should be from com.esteban.ruano.books_*

Next Steps

The module is ready to use! To add it to your app’s main navigation:

  1. Add a navigation item/link to “books” route
  2. Optionally add to bottom navigation bar
  3. Test the full flow: add → log → finish

For detailed API documentation, see books/README.md.