A simple android application that demonstrates Mavericks (MvRx) architecture with feature modules.
- App Walk-through
- App Installation
- Building source
- Top Features
- Architecture
- Testing
- Libraries
- Extras
The app is based on this design by Dmitriy Kazarov.
You can download the APK from releases.
To build this project, you require:
- Android Studio 4.1.0 or higher
- Gradle 6.5 or higher
- Multi-module clean architecture
- RxJava
- Dependency injection with Koin
- API request with Retrofit and Moshi for JSON serialisation
- Local persistence with Room
- CI with Github actions
- Code coverage with jacoco with reports uploaded to codecov
- Code lint check with Ktlint using a gradle plugin
- Static code analysis with detekt
- Dependency management with buildSrc (Kotlin DSL)
- Dependency updates with buildSrcVersions
- Git hooks to perform ktlint, detekt and lint checks before committing
The application follows the clean architecture concept. As software architecture involves the design decisions that are hard to change, we should take an approach that does not result in coupling of the various components of the software. This makes it easy to make changes as it scales. The presentation layer for each feature uses an MvRx architecture. With this in mind, the project is organised into modules as follows:
This module contains features supported by the application. At present, only the shopping
feature is implemented. Other features can be added as modules as the project scales.
The shopping feature has two screens. One that shows a list of food. The user can scroll through the list and add an item to their cart. The other for displaying the user cart information. The module defines both the view and presentation for the feature. The presentation is implemented using MavericksViewModel
+ Fragment
combination with an MVRx architecture
The core module just sets up the implementation of the data
layer of the application. It provides the remote
and cache
layers. Concurrency in the application is implemented using RxJava and this module provides the implementation for the schedulers used in the application. The networking layer is mocked using hardcoded JSON data in the assets directory
This module contains utility classes, extension functions, custom views shared by the android related modules. Most of the android modules depend on this module. Having the common classes here prevents duplication of code.
This module contains classes shared in unit tests in all modules.
This module connects all other modules. Provides navigation implementation with the Navigation Architecture Component library.
Testing is done with Junit4 testing framework, and with Google Truth for making assertions. Mockk is used to provide mocks in some of the tests. The tests run on the CI and the code coverage report is generated by jacoco can be tracked here.
- Material Components
- Constraint Layout
- Retrofit for REST api communication
- Moshi for JSON serialisation and deserialisation
- Mockk for mocking in tests
- Koin for dependency injection
- RxJava for concurrency
- Navigation Architecture Component
- Room for database
- Glide for image loading
- ViewBinding
- Kotlin Delegates
- Ktlint gradle plugin for code lint checks
- Detekt for static code analysis
- LeakCanary for detecting memory leaks in development
The Gradle script uses Kotlin Gradle DSL (buildSrc ) which brings Kotlin's rich language features to Gradle configuration. The project also uses detect to detect code smells and ktlint to enforce proper code style. Github actions handle continuous integration and run detekt, ktlint, lint and unit tests concurrently. A pre-commit git hook verifies the project's code style before committing code. Test coverage reports are uploaded to codecov.