🍿 Trending TV shows & movies information app built based on MVVM pattern with Jetpack Compose, Hilt, Retrofit, Flow, Pagination and Room.
- Minumum SDK Level: 21
- 100% Kotlin
- Architecture
- MVVM Pattern: Industry-recognized software architecure pattern supported by Google
- Jetpack Compose: Modern toolkit for building Android user interfaces using a declarative programming model
- Jetpack Pagination: Library helps you load and display pages of data from a larger dataset from local storage or over network.
- ViewModel: Exposes data streams as a state holder
- Hilt: Dependency injection library built on top of Dagger benefit from the compile-time correctness, runtime performance, scalability, and Android Studio support
- Coroutines: Concurrency design pattern provided by Kotlin
- Retrofit: Type-safe REST client for Android, Java and Kotlin developed by Square.
- OkHttp : 3rd party library sending and receive HTTP-based network requests built on top of the Okio library
- GSON: Java library that can be used to convert Java Objects into their JSON representation
- Room: Abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite.
Top News app was built with Google's recommended modern app architecture - MVVM pattern. By separating multiple app components into three layers - UI, Domain and Data, the app is scalable, maintainable and testable.
- Architectural Principles
- Separations of concerns
- Drive UI from data models
- Single source of truth
- Unidirectional Data Flow
WatchBase is composed with two main layers - UI layer and data layer. Each layer has app components which have different responsibilities.
UI layer displays the application data and serves as the primary point for user interactions. Whenever the app data changes, the UI should update to reflect changes made by either user interaction or external input.
- The main activity and all the fragments - Feed, Browse, Saved, etc are UI elements and they display articles received from network requests and the database
- NewsViewModel holds state and plays as a bridge between UI elements and the data layer
- UI elements request actions to ViewModel and observer ViewModel's livedatas to automatically update screens
Data layer is reponsible for containing application data and business logics. The data layer is consisted of repositories and data sources. It is important to keep each repository as a single source of truth.
- NewsRepository is a single source of truth and requests data from NewsLocalDataSource and NewsRemoteDataSource.
- NewsLocalDataSource is a class managing the database built with Room library and NewsRemoteDataSource is a class requesting network response to NewsAPI server.
Watchbase uses TMDB API for fetching data from the server. TMDB API provides detailed information about TV shows, movies and casts.