An android app built using Kotlin that consumes the given api and display the information. It has been built following Clean Architecture Principle, Repository Pattern, MVVM Architecture in the presentation layer as well as Jetpack components(including Jetpack Compose).
In order to be able to build the application you'll need Android Studio Minimum version Android Studio Chipmunk
- Clean architecture is an overkill for such a small app, just wanted to demonstrate and revise the current architecture patterns
This is the core layer of the application. The domain
layer is independent of any other layers thus ] domain models and business logic can be independent from other layers.This means that changes in other layers will have no effect on domain layer eg.
Components of domain layer include:
-
Models: Defines the core structure of the data that will be used within the application.
-
Repositories: Interfaces used by the use cases. Implemented in the data layer.
-
__Use cases: They enclose a single action, like getting data from a database or posting to a service. They use the repositories to resolve the action they are supposed to do. They usually override the operator “invoke”, so they can be called as a function.
The data
layer is responsibile for selecting the proper data source for the domain layer. It contains the implementations of the repositories declared in the domain layer.
Components of data layer include:
-
models
-dto models: Defines POJO of network responses.
-entity models: Defines the schema of SQLite database.
-
repository: Responsible for exposing data to the domain layer.
-
mappers: They perform data transformation between
domain
,dto
andentity
models. -
remote: This is responsible for performing network operations eg. defining API endpoints using Retrofit.
-
local: This is responsible for performing caching operations using Room.
The presentation
layer contains components involved in showing information to the user. The main part of this layer are the views(activity) and viewmodels.
This project uses some of the popular libraries, plugins and tools of the android ecosystem.
Used kotlin dsl to easily manage and update the dependencies
-
Hilt - Dependency Injection library.
-
-
Android KTX - Provide concise, idiomatic Kotlin to Jetpack and Android platform APIs.
-
Jetpack Compose - Jetpack Compose is Android’s modern toolkit for building native UI. It simplifies and accelerates UI development on Android.
-
AndroidX - Major improvement to the original Android Support Library, which is no longer maintained.
-
Lifecycle - Perform actions in response to a change in the lifecycle status of another component, such as activities and fragments.
-
ViewModel - Designed to store and manage UI-related data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations.
-
Compose Navigation -Component that allows easier implementation of navigation from composables.
-
-
Retrofit - Type-safe http client and supports coroutines out of the box.
-
OkHttp-Logging-Interceptor - Logs HTTP request and response data.
-
Coroutines - Library Support for coroutines.
-
Flow - Flows are built on top of coroutines and can provide multiple values. A flow is conceptually a stream of data that can be computed asynchronously.
-
Square/Logcat -Library for easier logging.
-
Material Design - Build awesome beautiful UIs.
-
kotlinx.coroutines - Library Support for coroutines,provides runBlocking coroutine builder used in tests.
-
Compose-Accompanist -Accompanist is a group of libraries that aim to supplement Jetpack Compose with features that are commonly required by developers but not yet available.
The tests are mainly unit tests covering the Network layer and Domain layer and also viewmodel tests for the characters module,main Libraries used for testing include:
- Junit - JUnit is a simple framework to write repeatable tests
- Hamcrest - Matchers that can be combined to create flexible expressions of intent
- Coroutines Testing - Test utilities for kotlinx.coroutines.
- CashApp Turbine - A small testing library for kotlinx.coroutines Flow
In this section i've included some resources ie. articles and GitHub repositories that are helpful when learning about clean architecture:
- The clean code blog by Robert C. Martin.
- A detailed guide on developing android apps using clean architecture pattern Medium article.
- Clean Architecture Component Boilerplater GitHub repo .
- Clean architecture sample Video by Philip Lackner
- Foodies Github Repo by Linus Moose to show how to build UIs with Compose
- Pokedex by Ronnie Otieno demonstrating how to properly use Jetpack Components