Skip to content

cesarwillymc/AddFast

Repository files navigation

Android Components Architecture

You can help me improve by giving me advice on my LinkedIn!

The next version will be cross-platform kotlin for android and ios

N|Solid

Application mobile with theme dark and light

This application has the objective of containing basic things for a good architecture in android projects, this project will improve sequentially first by migrating the MVVM project to Modular Architecture. This project is carried out in my National University of the Altiplano as a basic work, which I am refactoring to become a guide for android developers. Any comment you can communicate with me through my Linkedin CESAR

In the proyect i used Firestore, Bugsnack, Coroutines, Navigation Dynamic,Mockk , JUnit5 and Others.

The elements of the project change according to some things, such as if you are logged in, if you are an administrator and many other things. The project only displays basic flowchart options. Modules such as viewing applications, super user type user and many more are missing.

Mode Light Dark
HOME
CATEGORY
DETAIL ADD
PROFILE
AUTH
AUTH CODE
POSTULATE
MY ADDS

Flowchart

Architecture

The architecture of the application is based, apply and strictly complies with each of the following 5 points:

Modules

Modules are collection of source files and build settings that allow you to divide a project into discrete units of functionality. In this case apart from dividing by functionality/responsibility, existing the following dependence between them:

The above graph shows the app modularisation:

  • :app depends on :core and indirectly depends on :features by dynamic-features.
  • :features modules depends on :commons, :core, :libraries and :app.
  • :core and :commons only depends for possible utils on :libraries.
  • :libraries don’t have any dependency.

App module

The :app module is an com.android.application, which is needed to create the app bundle. It is also responsible for initiating the dependency graph, play core and another project global libraries, differentiating especially between different app environments.

Core module

The :core module is an com.android.library for serving network requests or accessing to the database. Providing the data source for the many features that require it.

Features modules

The :features module are an com.android.dynamic-feature is essentially a gradle module which can be downloaded independently from the base application module. It can hold code and resources and include dependencies, just like any other gradle module.

Commons modules

The :commons modules are an com.android.library only contains code and resources which are shared between feature modules. Reusing this way resources, layouts, views, and components in the different features modules, without the need to duplicate code.

Libraries modules

The :libraries modules are an com.android.library, basically contains different utilities that can be used by the different modules.

Architecture components

Ideally, ViewModels shouldn’t know anything about Android. This improves testability, leak safety and modularity. ViewModels have different scopes than activities or fragments. While a ViewModel is alive and running, an activity can be in any of its lifecycle states. Activities and fragments can be destroyed and created again while the ViewModel is unaware.

Passing a reference of the View (activity or fragment) to the ViewModel is a serious risk. Lets assume the ViewModel requests data from the network and the data comes back some time later. At that moment, the View reference might be destroyed or might be an old activity that is no longer visible, generating a memory leak and, possibly, a crash.

The communication between the different layers follow the above diagram using the reactive paradigm, observing changes on components without need of callbacks avoiding leaks and edge cases related with them.

Authors

Cesar Mamani

Linkedin