How dheerajkotwani/cinewatch works
Project Type & Purpose
• The project is an Android mobile application built using Kotlin.
• Its main features include browsing movie listings (upcoming, popular, top rated), viewing detailed movie info, cast details, bookmarking favorites, and trailers.
• It uses TMDB APIs for retrieving movie data and implements MVVM along with Dependency Injection, Room for local storage, Retrofit for networking, and Paging 3 for incremental data loading.
Analyzing the File Structure
• At the top level, the primary directories are:
• “app”: Contains Android-specific resources, configurations, and the main application code.
• “app/src/main”: Houses the code structured in subfolders representing different layers:
◦ “data”: Divided into “api” (network calls using Retrofit and SafeApiRequest), “local” (using Room and BookmarkDatabase with related DAO), “model” (data models like Movie, Actor, Cast, etc.), and “repository” (NetworkRepository bridging API and local data).
◦ “di”: Contains dependency injection modules (ApiModule, DatabaseModule) using Dagger 2.
◦ “ui”: Organized further into feature-centric packages (home, search, details, main, paging, etc.). Each feature typically has a Fragment/Activity alongside its ViewModel.
◦ “utils”: Utility classes for common tasks (networking, constants, date/time, views, etc.).
• Additional directories for resources, layouts, navigation (nav_graph.xml), and tests are also present, which reinforce the use of modern Android components like Navigation Graph and Paging.
Key Components & Their Interactions
• UI Layer:
• Activities/Fragments (e.g., MainActivity, SplashScreenActivity, HomeFragment, MovieDetailsFragment, etc.) form the presentation layer.
• Adapters (e.g., various RecyclerViewAdapters) display lists of movies, casts, etc.
• ViewModels (e.g., HomeViewModel, SearchViewModel, MovieDetailsViewModel, etc.) that manage UI data and lifecycle, observing LiveData.
• Domain / Data Layer:
• Repository (NetworkRepository) acts as a mediator between data sources.
• Data sources include:
▪ Network Service (NetworkService.kt) using Retrofit for remote calls.
▪ Local Database (BookmarkDatabase with BookmarkDao) using Room for caching/bookmarks.
• Data Models (Movie, Actor, etc.) that represent the domain objects.
• Dependency Injection:
• DI modules (ApiModule, DatabaseModule) to bind dependencies via Dagger 2, making sure the right implementations are injected into ViewModels and Repositories.
• External Services & Libraries:
• TMDB API is the external source.
• Other libraries include Dagger 2, Retrofit, Room, Paging 3, Material Components, and Coil (for image loading).