A complete Kotlin application built to demonstrate the use of Modern development tools with best practices implementation using multi-module architecture developed using SOLID principles

Overview

droid-pure-kotlin-application πŸ§žβ€

Android Best practices Kotlin Coroutines DaggerHilt Moshi Firebase Datastore Timber Orhanobut Jetpack compose Coil Google Material Compose Navigation Hilt navigation compose Activity compose Ui tooling preview Compose ui Kt lint Crashlytics

π™Έπš—πšπš›πš˜πšπšžπšŒπšπš’πš˜πš— πŸ’‘

🏷️ This repository serves as template and demo for building android applications for scale. It is suited for large teams where individuals can work independently on feature wise and layer wise reducing the dependency on each other. It is built with pure kotlin in the project namely compose for the presentation-layer, kotlin for writing the business-logic, kotlin-dsl for handeling the dependencies.
🏷️ Single activity architecture where compose-navigation is used for navigating between the screens. Also care is taken so that dependencies used in presentation layer is not available for domain layer and data layer. Multimodule architecture used with reusability by adhering SOLID-principles, also unit-testing, integration-testing in mind. Coding for abstraction rather than implementation is followed in the project that enables testing and so that fakes can be easily provided for abstractions for testing individual components.

🧱 🧱 Application is under constant improvement 🧱 🧱


π™Ώπšžπš›πšŽ πš”πš˜πšπš•πš’πš— πŸ—‚οΈ

dev_logo

🏷️ Programming language: βž– By migrating away from Java and towards kotlin, we can leverage the features like better readability, null saftey, less code, benifits of improved syntax and others.
🏷️ Kotlin DSL: βž– Earlier we used to use gradle for organizing dependencies. Gradle is written in a groovy programming language. Using the kotlin-DSL, we can organize the dependencies in our project cleaner and in an efficient way. Type safety. This allows better autocompletion which was missing from grovey till now. Code navigation between files becomes easy in Kotlin DSL. Refactoring is much easier.
🏷️ Compose: βž– Earlier we had xml for building the UI and thus there was one more language hooked to android project. But with the addition of jetpack compose, Even the UI will be built in kotlin language.


πš†πš‘πš’ πšŒπš•πšŽπšŠπš— πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ πš’πšœ πš—πšŽπšŽπšπšŽπš πŸ—‚οΈ

dev_logo

🏷️ Scalability: βž– When new features are added, using the clean architecture we can easily add the new features and maintain old existing features without breaking them.
🏷️ Testability: βž– For the new features, its essential we write a code that can be tested for all possible inputs so that once in production we can forecast all possible scenarios and handle them.
🏷️ Understandable: βž– Scaling a product with keeping the code testable is good but its also should be in such a way that everyone should understand it and also should easily be modify it.

πš†πš‘πš’ πš–πšžπš•πšπš’ πš–πš˜πšπšžπš•πšŽ πš’πšœ 𝚞𝚜𝚎𝚍 πš’πš— πš™πš›πš˜πš“πšŽπšŒπš πŸ—‚οΈ

🏷️ A multi module project helps us to segrigate between the layers of code in the project and enforcing strict seperation of concerns.
🏷️ When working on a large project this will keep the team to work in layer wise and also feature wise.
🏷️ A change in one feature will not affect other features in the project.


π™³πšŽπš™πšŽπš—πšπšŽπš—πšŒπš’ π™Έπš—πš“πšŽπšŒπšπš’πš˜πš— πŸ—‚οΈ

dev_logo

🏷️ A Depencency Injection results in a loosely coupled programs. It helps to achieve inversion of control. Inversion of control means a object or function recieves another object or function as a dependency.
🏷️ We use hilt that is built on top of dagger tool that generates code on behalf of user and helps to attain the inversion control easily. This is very essential because all the extra code that we need to generate, hilt will do it for us.
🏷️ The inversion control becomes even more crucial part of the structure in case of multi module project.
🏷️ This also helps in unit testing thte code because, since object is not created and instead provided to a function, we can easily mock it during unit testing.

π™²πš˜πš–πš–πšžπš—πš’πšŒπšŠπšπš’πš˜πš— πš‹πšŽπšπš πšŽπšŽπš— πšπš‘πšŽ πš•πšŠπš’πšŽπš›πšœ πŸ—‚οΈ

dev_logo

🏷️ Presentation Layer: βž– This layer is the UI layer of the application, It contains composables and view-models. The presentation layer communicates with the domain layer, But the presentation layer is not aware of the data layer.
🏷️ Domain Layer: βž– This layer contains use cases that contain business logic that perform one functionality each. It also contains the interfaces that communicates with repository which is present in the data layer.
🏷️ Data Layer: βž– The data layer contains the repositries, The repository can be a preference repository, remote API, local-filesystem etc. The data layer communicates back with the domain layer after fetching the data.

π™Έπš–πš™πš•πšŽπš–πšŽπš—πšπšŠπšπš’πš˜πš— 𝚘𝚏 πš‚π™Ύπ™»π™Έπ™³ πš™πš›πš’πš—πšŒπš’πš™πš•πšŽπšœ πŸ—‚οΈ

This applicaion is developed keeping in mind of clean architecture principles

SINGLE RESPONSIBILITY OPEN CLOSED PRINCIPLE LISKOV SUBSTITUTION PRINCIPLE INTERFACE SEGREGATION PRINCIPLE DEPENDENCY INVERSION PRINCIPLE
Each class having one responsibility. If there is a change in it, it must be because of only one reason only. If there are two reasons for a class to change, then it violates single responsibility principle. This indicates that the class is open for extension but closed for modification When we have a class that is inheriting the parent, the parent class functionality must be replaceable using the child class without modifying the functionality of parent class Here we should not force a class to do something that it does not want to do, Say a class is implementing interface then it overrides all the functions in it. Now if we don’t want a function of interface to be implemented then we give the default behaviour for the interface and so that it will not force the child class to override that method This indicates that, a class must depend on abstraction instead of concrete implementation. Say we want a implementation to be used for a class thence need to inject a abstraction for it instead of concrete implementation so that if its implementation changes in future , it must not affect where the abstract version of it is implemented

π™°πšπšŸπšŠπš—πšπšŠπšπšŽπšœ πšŠπš—πš π™³πš’πšœπšŠπšπšŸπšŠπš—πšπšŠπšπšŽπšœ 𝚘?? πš–πšžπš•πšπš’ πš–πš˜πšπšžπš•πšŽ πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ πŸ—‚οΈ

π™°πšπšŸπšŠπš—πšπšŠπšπšŽπšœ

Clear separation Faster build time
β€’ Each of the modules is a library and it can depend on each other
β€’ If there is a scenario where one library is not dependent on another, Then they can't access each other
β€’ Thus, instead of adding terms of separate packages in the app module, we can enforce strict modularity by modularising it
β€’ In a large project and big team we can enforce, who works on which project. Thus one person working on one won't affect other modules
β€’ Using the multi-module we can decrease the build time. When in multi-module each module will use separate threads so build time will decrease since all modules will build independently
β€’ Since Gradle needs to build the module that has been changed, it doesn't need to make the modules that have not been changed
β€’ Point to note here is that, say there is a root module with few child modules, if the root module changes, all the child modules also need to rebuild
β€’ Support for instant apps and dynamic feature module
β€’ Using this we can make parts of our app reusable

π™³πš’πšœπšŠπšπšŸπšŠπš—πšπšŠπšπšŽπšœ

β€’ Lot of initial code
β€’ Not knowing what problem it will cause


π™Όπš…πš…π™Ό πšœπšπš›πšžπšŒπšπšžπš›πšŽ 𝚞𝚜𝚎𝚍 πš’πš— πš–πšžπš•πšπš’-πš–πš˜πšπšžπš•πšŽ πšπš˜πš› πšŒπš•πšŽπšŠπš— πšŠπš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ

mvvm mvvm-improved














🏷️ Implementations of repositories sits in the data layer.
🏷️ The Data layer has reference to domain layer, So it can access all the classes from the data layer.
🏷️ Presentation layer has reference to the domain layer, so it can access all the classes from the domain layer and not data layer.
🏷️ We alwaays inject abstractions to any class instead of concrete implementation.
🏷️ Data flows from presentation layer to data layer if data is saved locally or sent to server. In other case the data is retrieved from data layer to presentation layer in case when data is retrieved from server to UI displayed or from data saved locally to UI displayed


πšƒπšŽπšœπšπš’πš—πš πšπš‘πšŽ 𝚌𝚘𝚍𝚎 πŸ§ͺ

🏷️ We test the features of the code, Each of the features contain three layers namely data, domain, presentation.
🏷️ In the core layer we can write tests for the implementation and repository for each of modules.
🏷️ UI tests - Development in progress

π™ΏπšŠπšŒπš”πšŠπšπšŽ πš‚πšπš›πšžπšŒπšπšžπš›πšŽ πš’πš— πšπš‘πšŽ πš™πš›πš˜πš“πšŽπšŒπš πŸ“¦

Project Folder                                    # Root Package
.
β”œβ”€β”€ app                                           # It is the starting point for the application
β”‚   β”œβ”€β”€ activity                                  # Entire application has just one activity
β”‚   β”œβ”€β”€ view-model                                # This will be the view-model for the single activity     
|   β”œβ”€β”€ navigation                                # It contains the navigation compose and the routes used in the application
β”‚   └── application                               # Singleton used at application level
|
β”œβ”€β”€ buildSrc                                      # It contains all project dependencies & its version references that can be modified from one place
|
β”œβ”€β”€ core                                          # Module with code that can be re-used in all the modules. This also helps us to manage them easily
β”‚   β”œβ”€β”€ res                                       # String resources used in the project
β”‚   └── java
β”‚       β”œβ”€β”€ data                                  # data layer of the core module
β”‚       β”‚    β”œβ”€β”€ implementation                   # contains implementations of the features hosted in core module
β”‚       β”‚    └── repository                       # contains repository for the features
β”‚       β”‚  
β”‚       β”œβ”€β”€ di                                    # Hilt dependency injection
β”‚       β”œβ”€β”€ domain                                # Domain layer for all the reusable third party features in project
β”‚       β”‚   β”œβ”€β”€ features                          # Contains interface for all the reusable third party features in project
β”‚       β”‚   └── models                            # data modules used thorught the project
β”‚       β”‚
β”‚       └── platform                              # Can old other miscellaneous things needed in project, some are listed below
β”‚           β”œβ”€β”€ base                              # Can hold base classes that are used in different features in project
β”‚           β”œβ”€β”€ extensions                        # kotlin extensions that can be kept in one place and handeled
β”‚           └── functional                        # Other util functional elements in teh project
β”‚      
β”‚ 
β”œβ”€β”€ core-ui                                       # Module contains all the UI related things in the project
β”‚   β”œβ”€β”€ res                                       
β”‚   β”‚   β”œβ”€β”€ drawable                              # Contains all the drawables needed for the project
β”‚   β”‚   └── font                                  # Place we can store the font files in the project
β”‚   β”‚
β”‚   └── java
β”‚       β”œβ”€β”€ composables                           # Here we store the reusable composables used for the project 
β”‚       └── theme                                 # Contains the theme file used in project
β”‚ 
└── features                                      # The module contains all the features used in project
    β”‚
    β”œβ”€β”€ common                                    # sub-module that holds the logic that is re-used in multiple features
    β”‚   β”‚
    β”‚   β”‚
    β”‚   β”œβ”€β”€ common_data                           # sub-module for data
    β”‚   β”‚   β”œβ”€β”€ di                                # di for current module
    β”‚   β”‚   β”œβ”€β”€ repository                        # repository used for injection
    β”‚   β”‚   └── service                           # service used in repository
    β”‚   β”‚   
    β”‚   β”‚
    β”‚   └── common_domain                         # sub-module for domain
    β”‚       β”œβ”€β”€ di                                # di used for having use-case data object instance
    β”‚       β”œβ”€β”€ repository                        # interface of the repository
    β”‚       └── usecases                          # individual logic for domain data
    β”‚         
    └── login                                     # sub-module that contains one feature
        β”‚
        β”‚
        β”œβ”€β”€ login_data                            # sub-module for data
        β”‚   β”œβ”€β”€ di                                # di used to build the module and create instances of service and repository of current module
        β”‚   β”œβ”€β”€ repository                        # implementation of the repository
        β”‚   └── service                           # service used in repository
        β”‚   
        β”‚
        β”œβ”€β”€ login_domain                          # sub-module for domain
        β”‚   β”œβ”€β”€ di                                # di used for having use-case data object instance
        β”‚   β”œβ”€β”€ repository                        # interface of the repository
        β”‚   └── usecases                          # individual logic for domain data
        β”‚   
        β”‚
        └── login_presentation                    # sub-module for presentation
            β”œβ”€β”€ states                            # states of the data displayed and view-model
            β”œβ”€β”€ view-composable                   # composable representing a screen
            └── viewmodel                         # view model for the composable

π™²πš˜πšπšŽ πššπšžπšŠπš•πš’πšπš’ πŸ“Ί

Run Kt lint πŸ”§

🏷️ It is static code analysis tool that is used to analyze the Kotlin code for you. It will check if you have written the code by following the Kotlin code guidelines or not.

// To check the list of errors
./gradlew ktlintCheck  
// Try to auto auto format errors
./gradlew ktlintFormat

π™·πš˜πš  𝚝𝚘 πš›πšžπš— πšπš‘πšŽ πšœπšŠπš–πš™πš•πšŽ πšŠπš™πš™πš•πš’πšŒπšŠπšπš’πš˜πš— πŸ‘£

🏷️ Basically You just follow steps to create a firebase account and eanable authentication module, I have summarized some steps below.
1️⃣ Before running the sample application, Please create a account in firebase console.
2️⃣ Now enable the authentication in settings for firebase(This is used during the authentication of login).
3️⃣ Add the google-services.json in the app level of the project that is obtained when creating a project in firebase.
4️⃣ Last but not least add your application SHA in your firebase settings.

πšƒπšŽπšŒπš‘ πšœπšπšŠπšŒπš” πŸ—οΈ ️

What How
🎭 πš„πšœπšŽπš› π™Έπš—πšπšŽπš›πšπšŠπšŒπšŽ (π™°πš—πšπš›πš˜πš’πš) π™ΉπšŽπšπš™πšŠπšŒπš” π™²πš˜πš–πš™πš˜πšœπšŽ
πŸ— π™°πš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ π™²πš•πšŽπšŠπš— π™°πš›πšŒπš‘πš’πšπšŽπšŒπšπšžπš›πšŽ
πŸ’‰ 𝙳𝙸 (π™°πš—πšπš›πš˜πš’πš) π™·πš’πš•πš
🌊 π™°πšœπš’πš—πšŒ π™²πš˜πš›πš˜πšžπšπš’πš—πšŽπšœ + Flow
🌐 π™½πšŽπšπš πš˜πš›πš”πš’πš—πš π™΅πš’πš›πšŽπš‹πšŠπšœπšŽ

π™²πšžπš›πš›πšŽπš—πšπš•πš’ πšπšŽπšŠπšπšžπš›πšŽπšœ πšπšŽπšŸπšŽπš•πš˜πš™πšŽπš 🧰

Demo contains three screen application namely registration, login, forgot-password and external service used here is firebase. User can create an account using registration. User can login and once login is successful the user details is saved in data-store

Login Registration Forgot Password

π™²πš˜πš—πšπš›πš’πš‹πšžπšπšŽ πŸ™‹β€β™‚οΈ

Read contribution guidelines for more information regarding contribution.

π™΅πšŽπšŽπšπš‹πšŠπšŒπš” ✍️

Feature requests are always welcome, File an issue here.

π™΅πš’πš—πš πšπš‘πš’πšœ πš™πš›πš˜πš“πšŽπšŒπš πšžπšœπšŽπšπšžπš• ? ❀️

Support it by clicking the ⭐ button on the upper right of this page. ✌️

π™»πš’πšŒπšŽπš—πšœπšŽ Licence πŸ’³

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

You might also like...
FirestoreCleanArchitectureApp is an app built with Kotlin and Firestore that displays data in real-time using the MVVM Architecture Pattern. For the UI it uses Jetpack Compose,  Android's modern toolkit for building native UI.
FirestoreCleanArchitectureApp is an app built with Kotlin and Firestore that displays data in real-time using the MVVM Architecture Pattern. For the UI it uses Jetpack Compose, Android's modern toolkit for building native UI.

FirestoreCleanArchitectureApp FirestoreCleanArchitectureApp is an app built with Kotlin and Cloud Firestore that displays data in real-time using Andr

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

 Futurama Quotes demonstrates modern Android development implements MVVM architecture
Futurama Quotes demonstrates modern Android development implements MVVM architecture

This application allows you to see futurama quotes. You can search quotes according to the character that said it as well. Futurama Quotes demonstrates modern Android development implements MVVM architecture.

 πŸ—‘οΈ 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, 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

Build with Jetpack Compose & all modern techniques and architecture of android app development
Build with Jetpack Compose & all modern techniques and architecture of android app development

IMDB Movie App Build with Jetpack Compose & all modern techniques and architecture of android app development ScreenShots πŸ›  Built With πŸ›  Kotlin - Fi

Math Your Brain is a math game built using Jetpack Compose and Modern MVVM Architecture
Math Your Brain is a math game built using Jetpack Compose and Modern MVVM Architecture

Math Your Brain is a math game built using Jetpack Compose and Modern MVVM Architecture. I built this so that programmers learning Jetpack Compose Can use this repository as a learning material for Jetpack Compose.

The complete Android Kotlin Developer course
The complete Android Kotlin Developer course

The complete Android Kotlin Developer course In this course you will learn how to make 17 online games, and apps for Android, using Kotlin. check the

A sample to demonstrate how to use Compose with Ktor Websockets
A sample to demonstrate how to use Compose with Ktor Websockets

This is a sample to demonstrate how to use Compose with Ktor Websockets

ToDo App based on Modern Android Application tech-stacks and MVVM architecture.
ToDo App based on Modern Android Application tech-stacks and MVVM architecture.

ToDo App Task Management App based on Modern Android Application tech-stacks and MVVM architecture. Techs Used πŸ’» Kotlin - First class and official pr

Owner
Devrath
Passionate about writing software that solves problems in a creative way
Devrath
Shreyas Patil 2.2k Jan 4, 2023
A project that showcases best practices for MAD (Modern Android Development).

MAD Dictionary Is this dictionary mad? Well yes, but actually no. MAD = Modern Android Development, this app is built using the very new and very awes

Abhishek Choudhary 11 Mar 12, 2022
πŸ“š Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

Madalin Valceleanu 2.3k Dec 30, 2022
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

Yusuf Ruziev 2 Apr 26, 2022
A movie & TV show exploration app that implements MVVM design pattern by following the clean architecture principles, using TMDB API.

?? Movie App ?? A movie & TV show exploration app that implements MVVM design pattern by following the clean architecture principles, using TMDB API.

Bora Bor 11 Dec 22, 2022
Kotlin backend based on the Clean Architecture principles. Ktor, JWT, Exposed, Flyway, KGraphQL/GraphQL generated endpoints, Gradle.

Kotlin Clean Architecture Backend Kotlin backend based on the Clean Architecture principles. The application is separated into three modules: Domain,

null 255 Jan 3, 2023
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
For Kotlin with SpringBoot project that have multi-module-structure template

Goals kotlin + spring-boot + gradle + multi-module building Module-Structure ---root |--- src.main.kotlin.KotlinSpringbootMultiModuleTemplateAppl

pguma 1 Jul 24, 2022
πŸ›’ 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

Esteban Aragon 7 Sep 22, 2022
Kotlin multi platform project template and sample app with everything shared except the UI. Built with clean architecture + MVI

KMMNewsAPP There are two branches Main News App Main The main branch is a complete template that you can clone and use to build the awesome app that y

Kashif Mehmood 188 Dec 30, 2022