How dmoyahur/moviesapp works
Main Components
• App Module – Represents the entry point for the Android application. It includes the application class, main activity, and navigation logic.
• Feature Modules – These include separate modules for “movies”, “detail”, and “search”. Each feature module encapsulates the UI (View), ViewModel, and use-case logic.
• Data Modules – Divided into several parts:
– Data – Repository, local, remote, and test submodules.
– Data – Repository module exposes interfaces for fetching data from both local (Room based) and remote (Retrofit, OkHttp) sources.
– Data – Remote handles API calls to TMDb and includes mappers for API responses.
– Data – Local manages caching with Room and handles database queries via DAO classes.
• Model Module – Contains domain-level models that are used to represent movies and error states throughout the app.
• Build-Logic Module – Contains custom Gradle scripts and plugins which standardize build conventions and rules across all modules.
• TestShared Module – Holds common testing utilities, test runners, and shared test rules for both unit testing and UI testing.
Relationships and Data Flow
• User interactions in the View (components in the feature modules) send events to the ViewModel.
• The ViewModel responds by invoking use cases, which act as a proxy, calling repository interfaces defined in the Data Repository module.
• The Repository abstracts data retrieval: it decides whether to fetch from the Local data source (cache via Room) or the Remote data source (API calls via Retrofit).
• Once data is fetched, it goes through mapping layers (e.g., converting DTOs to domain models in the Model module) before being sent back to the ViewModel.
• The ViewModel then updates the UI state (using state flows or LiveData) which the View listens to for re-rendering.
Architectural Patterns and Design Principles
• Modularization – Distinct modules should be depicted with clear boundaries. Show dependencies between modules (e.g., Feature modules depend on Data, Model and Common modules; Data Repository depends on both the Remote and Local modules).
• Use-case abstraction – Although a separate use-case (domain) module isn’t present, each feature directly contains use-case classes, so indicate that the use-case functions are interposed between the ViewModel and Repository.
• Data Mapping – Emphasize the transformation of remote data to local models, especially within the Data – Remote and Data – Local modules.