Skip to content

Clean Architecture Modular Project: MVVM + Jetpack Compose + Coroutines+ Flows + Dagger2 + LiveData + UnitTests + UITests + MockWebServer

Notifications You must be signed in to change notification settings

hard1k9850/SpaceX-prepare-for-Clean-Architecture-liftoff

 
 

Repository files navigation

SpaceX prepare for Clean Architecture liftoff:rocket:

JetpackCompose Platform Android Studio Arctic Fox License Build Status

The purpose of this project is to consolidate some of the learned insights throughout the years about the Clean Architecture principles and reflect those lesson on Android, taking advantage of the Kotlin programming language features too.

This project summarises some of the general use cases and needs that could be demanded on a production project using: Jetpack Compose, Functional Programming,MVVM setup, Coroutines, Kotlin Flows (check the branches section for more information).


Libraries Used 📚

Modules 📑

  • app - The application module with access to all the application
  • data - Android module that can only access domain module
  • data-api - Android module that can only access data module
  • domain - Kotlin module that cannot access any other module

And two extra modules:

  • core - Base classes module (factories, events, etc.) that cannot access any other module
  • core-android-test - Tests classes module (rules, date builders,etc.) that cannot access any other module

Branches :octocat:

There are three options depending on different tech-stack desired. The latest codebase will be updated in master. These are the three options available (all of them maintained):

  • master

    • Jetpack Compose (declarative UI)
    • Dagger Hilt
    • VM approach using UI States and Effects
    • Kotlin Flows (removed LiveData)
    • Modules simplification
    • The rest of modules remain the same (Tests)
  • SpaceX-Coroutines-Flows

    • Imperative UI
    • Dagger2
    • Kotlin Coroutines and Flows
    • Granular modularisation (CleanArchitecture approach)
    • Unit Tests + UI Tests + MockWebServer + Robot Pattern
  • SpaceX-RxJava

    • VMs and Fragments communication via RxJava
    • Dagger2
    • Granular modularisation (CleanArchitecture approach)
    • Unit Tests + UI Tests + MockWebServer + Robot Pattern

Testing 🔍

Unit Testing

There are some highlights:

  • Every layer in the architecture has been tested with its mapper|transformer|provider.
  • Mockito has been used for mocking|stubbing.
  • Given|When|Then steps have been followed, in order to give a more structured overview.
  • No comments in the tests because the tests functions are already concise and clear.

UI Testing (Compose)

I opted to use two types of approaches:

  • One using MockWebserver, where I recreate a real scenario where the app connects to an endpoint and I test the cases.
  • Another one, that I consider Isolated Compose Tests, where it's possible to mock and set any content, UI state, etc. Which is to emulate very specific cases.

This section is still evolving.

License 🚔

Copyright 2021 Fernando Prieto Moyano

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Clean Architecture Modular Project: MVVM + Jetpack Compose + Coroutines+ Flows + Dagger2 + LiveData + UnitTests + UITests + MockWebServer

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%