Hello there , In this project I tried showcasing how to build an Android Application with clean architecture and MVVM using some of the jetpack libraries with Kotlin Coroutines & Dagger Hilt. This App is using the Rick and Morty GraphQl as a remote data source.
This app is based on the Guide to app architecture article, Kotlin 1.4, and coroutine. I also used some android architecture components like LiveData, ViewModel.
I wrote a medium article to talk about GraphQL and how to implement it in an android application, feel free to check it out.
- UI calls method from ViewModel.
- ViewModel executes Use case.
- Use case executes one or multiple Repositorie function.
- The Repository returns data from one or multiple Data Sources(Remote-Rick and morty GraphQL , Local-Room DB). the repository is the single source of truth
- Information flows back to the UI where we display the data fetched from data sources.
I made a diagram to show the flow of the data between the three layers(data, domain , presentation)
- Data
- This is my data layer and consists of the Repository implementation class as well as the remote and local data sources and mappers
- Domain
- This is the domain layer and consists of the domain models as well as the usecases.
- UI
- This is the presentation layer. I have set up packages by feature here. This consists of the view related code.
- DI
- This is where Dagger related code lives , I wanted to try out Hilt and see what it can deliver.
- Utils
- This is where most extension functions and constants.
- ViewModel - store and manage UI-related data in a lifecycle conscious way
- LiveData - notify the view when data changes .
- ViewBinding - easily write code that interacts with view
- Material - Material Components.
- Coroutine - performs background tasks
- Flows - for asynchronous data streams
- Coil - An image loading library for Android backed by Kotlin Coroutines
- Gson - JSON Parser
- Apollo- GraphQL client for the JVM, Android and Kotlin multiplatform
- Dagger Hilt - dependency injector
- Room - Save data in a local database
- Espresso // UI test
- Barsita -UI tests Built on top of Espresso
- Junit // unit tests
- Truth // Makes your test assertions and failure messages more readable