Skip to content

feat(data): Add Data Layer for User Collections (Watchlist, Liked, Lists)

AGHARAHIMOV AGHASALIM requested to merge feature/user-collections-data-layer into main

What does this MR do?

This MR establishes the entire backend foundation for all user-specific movie collections as defined in the project requirements. It provides a complete, tested, and robust data layer for managing a user's watchlist, liked movies, and custom-named lists.

Architectural Components:

  • Room Database Schema:
    • MovieEntity is updated with isLiked and isInWatchlist boolean flags.
    • A full many-to-many relationship is implemented for custom lists (UserListEntity <-> UserListMovieCrossRef <-> MovieEntity).
    • The database version is incremented to 2 with a destructive migration strategy for development.
  • Data Access Objects (DAOs):
    • MovieDao provides methods for toggling liked/watchlist status and retrieving these collections.
    • UserListDao provides methods for creating custom lists and managing their contents.
  • Repository Layer:
    • A new UserCollectionsRepository is introduced to abstract away all database logic. It provides a clean, suspendable API (e.g., likeMovie(movie), getWatchlist()) for the application's ViewModels.

How has this been tested?

The correctness of this feature is ensured by two layers of testing:

  1. Instrumented Test (DatabaseCollectionsTest): Verifies the entire Room database schema, including entities, DAOs, primary keys, and relationships, by running real database operations on a device.
  2. Unit Test (UserCollectionsRepositoryImplTest): Uses mock DAOs to verify the business logic within the repository implementation, ensuring it calls the correct DAO methods with the correct parameters.

Why was this change needed?

This is a cornerstone feature of the application. With this data layer in place, the UI dev can now build the functionality for the movie details screen (like/watchlist buttons) and the user profile screens (viewing their collections). This MR unblocks a significant portion of future feature development.

Merge request reports