Architecture With MVI using Kotlin, Coroutines, Retrofit and Unit test

Overview

Architecture With MVI using Kotlin, Coroutines, Retrofit and Unit test

MVI (Model-View-Intent) streamlines the process of creating and developing applications by introducing a reactive approach

This repository contains a sample app that implements MVI architecture using Kotlin, ViewModel, Retrofit, Coroutines, Hilt and etc to make login screen and receive the results.

How does the MVI work?

User does an action which will be an Intent → Intent is a state which is an input to model → Model stores state and send the requested state to the View → View Loads the state from Model → Displays to the user. If we observe, the data will always flow from the user and end with the user through intent. It cannot be the other way, Hence it's called Unidirectional architecture. If the user does one more action the same cycle is repeated, hence it is Cyclic.

MVI Cycle Description

The app has the following packages:

  1. core: It contains (Dependency injection modules, Constants class, and Main App class).
  2. Features: It contains packages of screens we have in the application each screen package contains
  • data: it contains APIs and modules related to that screen
  • UI: it contains intents, states, and UI classes like activity, fragments..etc, and view models
  • use-cases: it contains the use cases classes responsible for the business and logic of the data we received from the models.
  1. helpers: Helper classes.

Unit Test: Unit-test for LoginUseCase class done as a sample you can use to have a good step with the real implementation.

  1. LoginUseCase class Code

Note:

The API link is only as an example for the explanation but it does not work You can use your own link, you can set your API link in Build.gradle

Reference resources:

  1. Coroutines: Check here
  2. Retrofit: Check here
  3. Hilt: Check here
  4. MVI: Check here
You might also like...
Android News Reader app. Kotlin Coroutines, Retrofit and Realm
Android News Reader app. Kotlin Coroutines, Retrofit and Realm

News Reader Android News Reader app Code that follows Packt Publishing Kotlin in Practice Video Course Example of Kotlin Coroutine usage, with Realm a

Small Kafka Playground to play around with Test Containers, and KotlinX Coroutines bindings while reading Kafka Definite Guide V2

KafkaPlayground Small playground where I'm playing around with Kafka in Kotlin and the Kafka SDK whilst reading the Kafka book Definite Guide from Con

Includes jetpack compose, navigation, paging, hilt, retrofit, coil, coroutines, flow..
Includes jetpack compose, navigation, paging, hilt, retrofit, coil, coroutines, flow..

Nextflix-Composable A Clean Architecture App to show use of multi-module-architecture in a Jetpack Compose. The modules are as follow: app: Presentati

Educational App made with Retrofit, Coroutines, Navigation Component, Room, Dagger Hilt, Flow & Material Motion Animations.
Educational App made with Retrofit, Coroutines, Navigation Component, Room, Dagger Hilt, Flow & Material Motion Animations.

TechHub TechHub is a sample educational app that provides courses for people who want to learn new skills in mostly tech-related areas. The goal of th

E-Commerce application with MVVM & Clean Arch - Hilt - Coroutines - Retrofit - Firebase - Room DB.
E-Commerce application with MVVM & Clean Arch - Hilt - Coroutines - Retrofit - Firebase - Room DB.

E-Commerce-App E-Commerce application with MVVM & Clean Arch - Hilt - Coroutines - Retrofit - Firebase - Room DB. API Link Project Features MVVM with

🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture
🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture

GithubSearchKMM Github Repos Search - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Depend

Example Multi module architecture Android project using MVVM, Dynamic Features, Dagger-Hilt, Coroutines and Navigation Components
Example Multi module architecture Android project using MVVM, Dynamic Features, Dagger-Hilt, Coroutines and Navigation Components

ModularDynamicFeatureHilt An Android template project following a multi module approach with clean architecture. It has been built following Clean Arc

A Kotlin multiplatform unit testing library inspired by / similar to Google Truth.

Truthish A testing API inspired by Google Truth but rewritten in Kotlin from the ground up, so it can be used in Kotlin multiplatform projects. For ex

 Movie app that receives popular movies and allows the user to search for the specific movie through the Rest API with help of retrofit library &MVVM architecture.
Movie app that receives popular movies and allows the user to search for the specific movie through the Rest API with help of retrofit library &MVVM architecture.

MovieClue Millions of movies, TV shows and people to discover. Explore now Movie app that recieves popular movies and allow the user to search for spe

Owner
Ahmed Karam
Android Developer with 6 years of experience designing, developing, testing, and maintaining Android applications. Developing a new codebase from scratch
Ahmed Karam
Clean Architecture Modular Project: MVI + Jetpack Compose + Coroutines + Flows + Hilt + UnitTests

NyTimes for Clean Architecture The purpose of this project is to consolidate some of the learned insights throughout the years about the Clean Archite

Ahmed mahmoud abo elnaga 8 Oct 27, 2022
A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

Nek.12 4 Oct 31, 2022
MVIExample - A sample app showing how to build an app using the MVI architecture pattern

MVIExample A sample app showing how to build an app using the MVI architecture p

Yasser AKBBACH 0 Jan 8, 2022
Sample application to demonstrate Multi-module Clean MVVM Architecture and usage of Android Hilt, Kotlin Flow, Navigation Graph, Unit tests etc.

MoneyHeist-Chars Sample application to demonstrate Multi-module Clean MVVM Architecture and usage of Android Hilt, Kotlin Flow, Navigation Graph, Room

Hisham 20 Nov 19, 2022
FaceTimeClone app that implements Coroutines , mvvm architecture , clean architecture , navigation component , hilt , etc.... using kotlin language

This repository contains a FaceTimeClone app that implements Coroutines , mvvm architecture , clean architecture , navigation component , hilt , etc.... using kotlin language

null 17 Dec 13, 2022
Searchbook - SearchBooks is an app built with Jetpack Compose and architecture of MVVM + MVI

SearchBooks SearchBooks is an app built with Jetpack Compose and architecture of

Jayden 4 Nov 20, 2022
MVI Architecture Android Beginners: Sample App

MVI Architecture Android Beginners: Sample App This repository contains a sample app that implements MVI architecture using Kotlin, ViewModel, LiveDat

Mahmoud Sallam 1 Nov 29, 2021
An tool to help developer to use Retrofit elegantly while using kotlinx.coroutines.

one An tool to help developer to use Retrofit elegantly while using kotlinx.coroutines. Feature Transform different data structs to one. {errorCode, d

ChengTao 30 Dec 27, 2022
Recycler-coroutines - RecyclerView Auto Add Data Using Coroutines

Sample RecyclerView Auto Add With Coroutine Colaborator Very open to anyone, I'l

Faisal Amir 8 Dec 1, 2022