This repository contains a detailed sample app that apply MVI presentation architecture and uses Coroutines, Hilt, Compose.
To be able to build and run the app, you must have JDK 17 installed on your machine.
After cloning the project and syncing gradle, run the following command to compile, install and run the application.
./gradlew assembleDebug && adb install -r app/build/outputs/apk/debug/app-debug.apk && adb shell am start -n com.example.compose_template/.MainActivityThe application currently have a set of unit tests and UI tests to validate some of the test cases. To run the available tests run the following command
./gradlew :app:testDebugUnitTestAnd for UI tests after you run the Emulator
./gradlew :app:connectedDebugAndroidTestYou will have a generated report file at app/build/reports/tests/testDebugUnitTest/ and app/build/reports/androidTests/connected/debug/ labeled index.html where you can check unit and UI tests results.
ViewModel handles all business logic, state management, and interactions with use cases or repositories. States are handled using Intents and State model to be updated and reflected on UI easily.
Features are split into presentation, domain, and data layers:
- Presentation: Composables, ViewModels and State Handling.
- Domain: Use cases encapsulate business rules.
- Data: Repositories and API services.
Coroutines are used for asynchronous operations. Flow is used for exposing reactive streams from the repository/use cases to ViewModel.
Compose is used for the UI layer. Facilitate the UI design using declarative UI.
Hilt is used for dependency injection across ViewModels and repositories.
Jetpack Compose Navigation handles screen transitions.
Cached data is stored in memory in the ViewModel for offline-first feel. Pagination logic ensures efficient network usage and smooth scrolling for long lists.
ViewModels are unit-testable. Uses Turbine for testing Flow emissions. Mockito for mocking.
- Add E2E testing
- Replace mockito with mockk and Add UI Tests
- Add Github Actions to build and test on every PR to main