A clean architecture example. Using Kotlin Flow, Retrofit and Dagger Hilt, etc.

Overview

android-clean-architecture

A clean architecture example. Using Kotlin Flow, Retrofit and Dagger Hilt, etc.

Intro

Architecture means the overall design of the project. It’s the organization of the code into classes or files or components or modules. And it’s how all these groups of code relate to each other. The architecture defines where the application performs its core functionality and how that functionality interacts with things like the database and the user interface.

Clean architecture refers to organizing the project so that it’s easy to understand and easy to change as the project grows. This doesn’t happen by chance. It takes intentional planning.

Reference

  • This android app using backend from this repo
  • If you want tutorial how to create this app step by step, go to this youtube playlist.

Screenshots

Notes

I created this app just for example how to implement clean architecture on android. It really biased to my preference and experience. Also, clean architecture is not mandatory to do. If you feel that you/your team are taking so much benefit by implementing this design pattern, then go for it. Otherwise, don't use it or just modify to your/your team preferences.

Main Picture

There are 3 layer in this app.

Presentation Layer Domain Layer Data Layer
your ui/view entity data source, dto
your viewmodel usecase repository implementation
probably your extension repository interface your library config(retrofit/room)
etc... etc.. etc...

App Level Example

Presentation Layer Something in Between Domain Layer Data Layer Outer data layer
LoginActivity & LoginViewModel <- LoginUseCase -> <- LoginRepository (interface) -> <- LoginRepositoryImplementation DataSource
You might also like...
Learning Project (Story App) For Applying Android Architecture Components And Clean Architecture Using MVVM With Kotlin

Learning Project (Story App) For Applying Android Architecture Components And Clean Architecture Using MVVM With Kotlin. Implemented by Clean Architecture, Hilt, MVVM, LiveData, Coroutines, Retrofit2, Glide

Example of Android project showing integration with Kotlin and Dagger 2

kotlin-dagger-example This project demonstrate how to setup an Android Project with Kotlin and Dagger 2. It's based on Dagger 2 example ##Known issues

Sample demonstrates use of Flow, StateFlow & how we can test Flow

FlowSample This sample demonstrates use of Flow, StateFlow & how we can test Flow. In Kotlin, Coroutine is just the scheduler part of RxJava but now w

Dagger-Hilt

DaggerHilt Dagger-Hilt in this Repo i have demonstrated the use of the following in android Kotlin Dagger2 Room Persistence Retrofit2 MVI / MVVM Archi

Clean MVVM with eliminating the usage of context from view models by introducing hilt for DI and sealed classes for displaying Errors in views using shared flows (one time event), and Stateflow for data

Clean ViewModel with Sealed Classes Following are the purposes of this repo Showing how you can remove the need of context in ViewModels. I. By using

🦁 A Disney app using transformation motions based on MVVM (ViewModel, Coroutines, Flow, LiveData, Room, Repository, Koin) architecture.
🦁 A Disney app using transformation motions based on MVVM (ViewModel, Coroutines, Flow, LiveData, Room, Repository, Koin) architecture.

DisneyMotions A demo Disney app using transformation motions based on MVVM architecture. The motion system is included in the 1.2.0-alpha05 released m

Android Github service with paging, hilt and retrofit

github-paging-hilt-retrofit This repository contains a simple app that implements Dagger-Hilt in MVVM architecture, Retrofit using Kotlin. The app has

🛒 Mercado Libre App Clone using modern Android development with Hilt, Coroutines, Jetpack (Room, ViewModel), and Jetpack Compose based on MVVM architecture.
🛒 Mercado Libre App Clone using modern Android development with Hilt, Coroutines, Jetpack (Room, ViewModel), and Jetpack Compose based on MVVM architecture.

Meli Clone 🛒 Mercado Libre App Clone using modern Android development with Hilt, Coroutines, Jetpack (Room, ViewModel), and Jetpack Compose based on

 A program written entirely in Kotlin using the principles of Clean Architecture according to the MVVM pattern
A program written entirely in Kotlin using the principles of Clean Architecture according to the MVVM pattern

A program written entirely in Kotlin using the principles of Clean Architecture according to the MVVM pattern. An application that shows a list of ani

Comments
  • About   validate input  vlaue  by    MutableStateFlow & LoginActivityState

    About validate input vlaue by MutableStateFlow & LoginActivityState

    Dear Sir

    thx your demo

    i try upgrade Hilt verion -- PR https://github.com/ydhnwb/android-clean-architecture/issues/2

    now i base your demo try to modify something -like input value validate

    i think validate input must into Viewmodel

    and the steps is "validate input --> login"

    it can use kotlin flow combine

    so i try it https://github.com/CMingTseng/android-clean-architecture/blob/b42a42819c88c5a7adbf86cdc50031aa72849fea/app/src/main/java/com/ydhnwb/cleanarchitectureexercise/presentation/login/LoginViewModel.kt#L54

    but something is not right

    1. if input email "or" pwd is wrong , the validate result notify to UI by MutableStateFlow is right ,the UI (fragment) will show "not email type" or "PWD length wrong "

    2. when input email "And" pwd are wrong ,the validate result notify to UI by MutableStateFlow only one time !!! the UI (fragment) anly show "not email type" or "PWD length wrong " , not both

    what is wrong ?

    THX

    opened by CMingTseng 0
  • hilt-lifecycle-viewmodel is deprecated @Dagger 2.34

    hilt-lifecycle-viewmodel is deprecated @Dagger 2.34

    Dear Sir

    how fix

    1. hilt-lifecycle-viewmodel is deprecated

    2. In Dagger 2.31, it's possible to achieve the above without using @HiltViewModel and passing everything manually

    THX

    https://issuetracker.google.com/issues/188663855#comment2

    https://stackoverflow.com/questions/68649447/viewmodel-constructor-should-be-annotated-with-inject-instead-of-assistedinjec

    opened by CMingTseng 0
Shreyas Patil 2.2k Jan 4, 2023
My own approach to what I think an Android MVVM project with Clean Architecture should look like with Dagger-Hilt as Dependency Injector engine

MVVM Project Hilt Introducción Este proyecto es mi visión particular, ni mejor ni peor (sólo una más) que cualquier otra aproximación a lo que yo enti

Antonio Fdez. Alabarce 7 Dec 16, 2022
This is an example of a simple application with layered software base on clean-architecture as application architecture and mvvm as presentation architecture

This is an example of a simple application with layered software base on clean-architecture as application architecture and mvvm as presentation archi

null 3 Jul 2, 2021
Clean Android multi-module offline-first scalable app in 2022. Including Jetpack Compose, MVI, Kotlin coroutines/Flow, Kotlin serialization, Hilt and Room.

Android Kotlin starter project - 2022 edition Android starter project, described precisely in this article. Purpose To show good practices using Kotli

Krzysztof Dąbrowski 176 Jan 3, 2023
MVVM ,Hilt DI ,LiveData ,Flow ,SharedFlow ,Room ,Retrofit ,Coroutine , Navigation Component ,DataStore ,DataBinding , ViewBinding, Coil

RickMorty This is a simple app which has been implemented using Clean Architecture alongside MVVM design to run (online/offline) using : [ MVVM ,Hilt

Ali Assalem 13 Jan 5, 2023
Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

Mohammadali Rezaei 7 Nov 28, 2022
🗡️ Deddit demonstrates modern Android development with Hilt, Coroutines, Flow, Jetpack, and Material Design based on MVVM architecture

Deddit demonstrates modern Android development with Hilt, Coroutines, Flow, Jetpack (ViewModel,Paging3), and Material Design based on MVVM

Krish Parekh 9 Sep 2, 2022
Showify is a my first simple ✅ Android application 📱 using DI, where I learn how to use dagger-hilt, retrofit2, mvvm, livedata, Requestly Interceptor

Showify is a my first simple ✅ Android application ?? using DI, where I learn how to use dagger-hilt, retrofit2, mvvm, livedata, Requestly Interceptor and so much more...

MOHIT GUPTA 1 Jun 21, 2022
Movie Android App written in Kotlin, MVVM, Clean Architechture, Modularized, Coroutines, Android Architecture Components and Hilt

Movie Android App written in Kotlin, MVVM, Clean Architechture, Modularized, Coroutines, Android Architecture Components and Hilt.

Klejvi Kapaj 16 Dec 27, 2022