<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Madalin Valceleanu</title>
    <description>The latest articles on DEV Community by Madalin Valceleanu (@vmadalin).</description>
    <link>https://dev.to/vmadalin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F241763%2F2f701c03-0f7f-4f4e-a7b0-5c0fa8428b1f.png</url>
      <title>DEV Community: Madalin Valceleanu</title>
      <link>https://dev.to/vmadalin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vmadalin"/>
    <language>en</language>
    <item>
      <title>📚 Android Components Architecture in a Modular Word</title>
      <dc:creator>Madalin Valceleanu</dc:creator>
      <pubDate>Sun, 08 Dec 2019 16:51:23 +0000</pubDate>
      <link>https://dev.to/vmadalin/android-components-architecture-in-a-modular-word-1bmj</link>
      <guid>https://dev.to/vmadalin/android-components-architecture-in-a-modular-word-1bmj</guid>
      <description>&lt;p&gt;Over years Android architecture evolved to support production-quality apps on any scale focused on helping developers to design robust, testable, and maintainable apps. For that Google has promoted in the last years &lt;a href="https://developer.android.com/kotlin" rel="noopener noreferrer"&gt;Kotlin&lt;/a&gt; as an official Android programming language impulse via a series of community-led events like &lt;a href="https://events.withgoogle.com/kotlin-everywhere/" rel="noopener noreferrer"&gt;Kotlin/Everywhere&lt;/a&gt; and programmers Udacity courses &lt;a href="https://www.udacity.com/course/kotlin-bootcamp-for-programmers--ud9011" rel="noopener noreferrer"&gt;Kotlin Bootcamp&lt;/a&gt;. And it is not for less since the advantages are endless with respect to Java offering modern statically typed programming language that will boost your productivity and increase your developer happiness.&lt;/p&gt;

&lt;p&gt;But first of all, if you want to check directly the project before continuing reading the introduction, you can do by accessing the following link:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/VMadalin/kotlin-sample-app" rel="noopener noreferrer"&gt;https://github.com/VMadalin/kotlin-sample-app&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2kkzeygep5zrdnpj6kl7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2kkzeygep5zrdnpj6kl7.png" alt="Github project badges" width="800" height="32"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The programming paradigm in android has seen a drastic turn with the introduction of &lt;a href="https://developer.android.com/jetpack" rel="noopener noreferrer"&gt;Android Jetpack&lt;/a&gt; a suite of libraries, tools, and guidance to help developers write high-quality apps easier. These components help you to follow best practices, free you from writing boilerplate code, and simplify complex tasks. That has ended up giving rise to what is known today as &lt;a href="https://android-developers.googleblog.com/2019/10/android-dev-summit-2019-keynote.html" rel="noopener noreferrer"&gt;Modern Android Development&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.android.com/topic/libraries/architecture" rel="noopener noreferrer"&gt;Android Architecture Components&lt;/a&gt; are part of Jetpack and are a collection of libraries that help you design robust, testable, and maintainable apps. Start with classes for managing your UI component lifecycle and handling data persistence. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Modular_programming" rel="noopener noreferrer"&gt;Modular Android App Architecture&lt;/a&gt; presented from &lt;a href="https://twitter.com/yigitboyar" rel="noopener noreferrer"&gt;Yigit Boyar&lt;/a&gt; and &lt;a href="https://twitter.com/fmuntenescu" rel="noopener noreferrer"&gt;Florina Muntenescu&lt;/a&gt; in &lt;a href="https://www.youtube.com/watch?v=PZBg5DIzNww" rel="noopener noreferrer"&gt;Google I/O'19&lt;/a&gt;, is a software design technique to separate functionality into independent, interchangeable modules so that each contains everything necessary to execute a specific functionality.&lt;br&gt;
The below diagram demonstrates how would an application that uses this software design technique, although if you want to see more, I recommend the following &lt;a href="https://medium.com/androiddevelopers/a-patchwork-plaid-monolith-to-modularized-app-60235d9f212e" rel="noopener noreferrer"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2sfbpjfzurh89473hevb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2sfbpjfzurh89473hevb.png" alt="Modularized app with multiple independent features what share or not the same libraries" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;Yet when it comes to combining all architecture puzzles together into simple client application it is difficult to find open-sourced app sample to follow. For this reason, I decided to build one based, apply and strictly complies with each of the following 5 points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A single-activity architecture, using the &lt;a href="https://developer.android.com/guide/navigation/navigation-getting-started" rel="noopener noreferrer"&gt;Navigation component&lt;/a&gt; to manage fragment operations.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.android.com/topic/libraries/architecture/" rel="noopener noreferrer"&gt;Android architecture components&lt;/a&gt;, part of Android Jetpack forgive to project a robust design, testable and maintainable.&lt;/li&gt;
&lt;li&gt;Pattern &lt;a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel" rel="noopener noreferrer"&gt;Model-View-ViewModel&lt;/a&gt; (MVVM) facilitating &lt;a href="https://en.wikipedia.org/wiki/Separation_of_concerns" rel="noopener noreferrer"&gt;separation&lt;/a&gt; of development of the graphical user interface.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://en.wikipedia.org/wiki/SOLID" rel="noopener noreferrer"&gt;S.O.L.I.D&lt;/a&gt; design principles intended to make software designs more understandable, flexible and maintainable.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://proandroiddev.com/build-a-modular-android-app-architecture-25342d99de82" rel="noopener noreferrer"&gt;Modular app architecture&lt;/a&gt; allows being developed features in isolation, independently from other features.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fku5yye8tqituel4wnork.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fku5yye8tqituel4wnork.gif" width="1024" height="1024"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The project presents a modern, 2019 approach to &lt;a href="https://www.android.com/" rel="noopener noreferrer"&gt;Android&lt;/a&gt; application development using &lt;a href="https://kotlinlang.org/" rel="noopener noreferrer"&gt;Kotlin&lt;/a&gt; and latest &lt;a href="https://github.com/VMadalin/kotlin-sample-app#tech-stack" rel="noopener noreferrer"&gt;tech-stack&lt;/a&gt;.&lt;br&gt;
The goal of the project is to demonstrate best practices, provide a set of guidelines, modular application, scalable, maintainable and testable. This application may look simple, but it has all of these small details that will set the rock-solid foundation of the larger app suitable for bigger teams and long application lifecycle management.&lt;/p&gt;
&lt;h2&gt;
  
  
  Application structure
&lt;/h2&gt;

&lt;p&gt;One of the key benefits of modularization architecture is supposed to be clear navigation throughout the app and source code. Looking at the root folder of the project, the following structure becomes clear:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu5264fdbe4bxv54ixl4p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu5264fdbe4bxv54ixl4p.png" alt="Project structure on root folder" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Interaction between modules
&lt;/h2&gt;

&lt;p&gt;Between the modules is established a dependency relationship that allows us to make an API request, access to DDBB or use a certain initialized library. Reusing the code in this way and avoiding duplicating. The below graph shows the app dependency between modules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;:app depends on :core and indirectly depends on :features by &lt;a href="https://developer.android.com/studio/projects/dynamic-delivery" rel="noopener noreferrer"&gt;dynamic-features&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;:features modules depend on :commons, :core, :app and some specific utils:library that will use.&lt;/li&gt;
&lt;li&gt;:core and :commons only depends on possible utils on :libraries.&lt;/li&gt;
&lt;li&gt;:libraries don't have any dependency.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fakngm0dfjro4riw4mfgq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fakngm0dfjro4riw4mfgq.png" alt="Graph of dependencies between modules" width="581" height="321"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  App module
&lt;/h3&gt;

&lt;p&gt;The :app module is a com.android.application, which is needed to create the App Bundle. It is also responsible for initiating the dependency graph, play core and other project global libraries, differentiating especially between different app environments.&lt;/p&gt;
&lt;h3&gt;
  
  
  Core module
&lt;/h3&gt;

&lt;p&gt;The :core module is a com.android.library for serving network requests or accessing to the DDBB. Providing the data source for the many features that require it.&lt;/p&gt;
&lt;h3&gt;
  
  
  Features modules
&lt;/h3&gt;

&lt;p&gt;The :features module are a 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.&lt;/p&gt;
&lt;h3&gt;
  
  
  Commons modules
&lt;/h3&gt;

&lt;p&gt;The :commons modules are a com.android.library only contains code and resources which are shared between feature modules. Reusing this way layouts, views, and other components in the different features modules, without the need to duplicate code.&lt;/p&gt;
&lt;h3&gt;
  
  
  Libraries modules
&lt;/h3&gt;

&lt;p&gt;The :libraries modules are a com.android.library, basically contains different utilities that can be used by the different modules.&lt;/p&gt;
&lt;h2&gt;
  
  
  Architecture components
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Passing a reference of the View (activity or fragment) to the ViewModel is a serious risk. Let's assume the ViewModel requests data from the network and the data comes back sometime 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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fowczfuzw9jccx8wyg042.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fowczfuzw9jccx8wyg042.png" alt="Observer pattern in the presentation and data layer" width="800" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The communication between the different layers follows the above diagram using the reactive paradigm, observing changes on components without the need of callbacks avoiding leaks and edge cases related to them.&lt;/p&gt;
&lt;h2&gt;
  
  
  Configuration files
&lt;/h2&gt;

&lt;p&gt;With App Modularization we want to gain fine-grained dependency control but we also need to make sure we don't end up maintaining multiple configuration files.&lt;/p&gt;

&lt;p&gt;For that we have the following common configuration files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/VMadalin/kotlin-sample-app/blob/master/buildSrc/src/main/kotlin/commons/android-dynamic-feature.gradle.kts" rel="noopener noreferrer"&gt;commons/android-dynamic-feature.gradle.kts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/VMadalin/kotlin-sample-app/blob/master/buildSrc/src/main/kotlin/commons/android-library.gradle.kts" rel="noopener noreferrer"&gt;commons/android-library.gradle.kts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/VMadalin/kotlin-sample-app/blob/master/buildSrc/src/main/kotlin/commons/kotlin-library.gradle.kts" rel="noopener noreferrer"&gt;commons/kotlin-library.gradle.kts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following android-dynamic-feature.gradle.kts is applied to every feature module with the following line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins {
    id("commons.android-dynamic-feature")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Things to consider
&lt;/h2&gt;

&lt;p&gt;Of course, nothing is perfect, especially if it has recently come out. Here are some issues what I found during development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Navigation component doesn't support multiple back-stack for the moment. Exist different &lt;a href="https://github.com/android/architecture-components-samples/issues/530" rel="noopener noreferrer"&gt;workarounds&lt;/a&gt; but not officially solution to this. (&lt;a href="https://issuetracker.google.com/issues/127932815" rel="noopener noreferrer"&gt;issue&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Robolectric isn't compatible with dynamic-features modules for the moment. Test on dynamic-feature throws the following exception. The same test but under android-library , works correctly. (&lt;a href="https://github.com/robolectric/robolectric/issues/5383" rel="noopener noreferrer"&gt;issue&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java.lang.RuntimeException:java.lang.UnsupportedOperationException: libraries not supported yet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Roboelectric throw the following exception on testing apps with data-binding in module. (&lt;a href="https://issuetracker.google.com/issues/126775542" rel="noopener noreferrer"&gt;issue&lt;/a&gt;)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java.lang.NoClassDefFoundError:androidx/databinding/DataBinderMapperImpl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/mockk" rel="noopener noreferrer"&gt;MockK&lt;/a&gt; with LiveData dependency throws an exception when trying to obtain value. (&lt;a href="https://github.com/mockk/mockk/issues/388" rel="noopener noreferrer"&gt;issue&lt;/a&gt;). The workaround is to use mockito for the moment.

 &lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java.lang.ClassCastException:java.lang.Object cannot be cast to java.lang.String
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Projects
&lt;/h3&gt;

&lt;p&gt;This is project is a sample, to inspire you and should handle most of the common cases, but obviously not all. If you need to take a look at additional resources to find solutions for your project, visit these interesting projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://github.com/google/iosched" rel="noopener noreferrer"&gt;iosched&lt;/a&gt; (by &lt;a href="https://github.com/google" rel="noopener noreferrer"&gt;google&lt;/a&gt;) - official Android application from google IO 2019.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/android/plaid" rel="noopener noreferrer"&gt;plaid&lt;/a&gt; (by &lt;a href="https://github.com/android" rel="noopener noreferrer"&gt;android&lt;/a&gt;) - app which provides design news &amp;amp; inspiration, being an example of implementing material design.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/android/sunflower" rel="noopener noreferrer"&gt;sunflower&lt;/a&gt; (by &lt;a href="https://github.com/android" rel="noopener noreferrer"&gt;android&lt;/a&gt;) - a gardening app illustrating Android development best practices with Android Jetpack.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/android/architecture-components-samples" rel="noopener noreferrer"&gt;architecture-components-samples&lt;/a&gt; (by &lt;a href="https://github.com/android" rel="noopener noreferrer"&gt;android&lt;/a&gt;) - collection of samples for Android Architecture Components.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/android/architecture-samples" rel="noopener noreferrer"&gt;architecture-sample&lt;/a&gt; (by &lt;a href="https://github.com/android" rel="noopener noreferrer"&gt;android&lt;/a&gt;) - collection of samples to discuss and showcase different architectural tools and patterns for Android apps.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/bufferapp/android-clean-architecture-boilerplate" rel="noopener noreferrer"&gt;android-clean-architecture-boilerplate&lt;/a&gt; (by &lt;a href="https://github.com/bufferapp" rel="noopener noreferrer"&gt;bufferapp&lt;/a&gt;) - an android boilerplate project using clean architecture&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/sanogueralorenzo/Android-Kotlin-Clean-Architecture" rel="noopener noreferrer"&gt;android-kotlin-clean-architecture&lt;/a&gt; (by &lt;a href="https://github.com/sanogueralorenzo" rel="noopener noreferrer"&gt;sanogueralorenzo&lt;/a&gt;) - android sample Clean Architecture app written in Kotlin.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/JeroenMols/ModularizationExample" rel="noopener noreferrer"&gt;modularization-example&lt;/a&gt; (by &lt;a href="https://github.com/JeroenMols" rel="noopener noreferrer"&gt;JeroenMols&lt;/a&gt;) - easy to understand real-life example of a modularized Android app.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/Eli-Fox/LEGO-Catalog" rel="noopener noreferrer"&gt;lego-catalog&lt;/a&gt; (by &lt;a href="https://github.com/Eli-Fox" rel="noopener noreferrer"&gt;Eli-Fox&lt;/a&gt;) - app illustrating current Android Architecture state using Android development best practices.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/chrisbanes/tivi" rel="noopener noreferrer"&gt;tivi&lt;/a&gt; (by &lt;a href="https://github.com/chrisbanes" rel="noopener noreferrer"&gt;chrisbanes&lt;/a&gt;) - an app which attempts to use the latest cutting edge libraries and tools.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/igorwojda/android-showcase" rel="noopener noreferrer"&gt;android-showcase&lt;/a&gt; (by &lt;a href="https://github.com/igorwojda" rel="noopener noreferrer"&gt;igorwojda&lt;/a&gt;) - app following best practices: Kotlin, coroutines, Clean Architecture, feature modules, tests, MVVM, static analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Articles
&lt;/h3&gt;

&lt;p&gt;A collection of very interesting articles related last android community tendencies and recommendations for start to take in consideration for your current/next project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://medium.com/androiddevelopers/a-patchwork-plaid-monolith-to-modularized-app-60235d9f212e" rel="noopener noreferrer"&gt;Transform monolith to modularization application&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://medium.com/swlh/using-the-navigation-component-in-a-modular-world-e7578825962" rel="noopener noreferrer"&gt;Using the Navigation Component in a Modular World&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://medium.com/androiddevelopers/dependency-injection-in-a-multi-module-project-1a09511c14b7" rel="noopener noreferrer"&gt;Dependency injection in a multi module project&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://medium.com/androiddevelopers/viewmodels-and-livedata-patterns-antipatterns-21efaef74a54" rel="noopener noreferrer"&gt;ViewModels and LiveData: Patterns + AntiPatterns&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://blog.q42.nl/dynamic-feature-and-regular-modules-using-dagger2-12a7edcec1ff" rel="noopener noreferrer"&gt;Dynamic feature and regular modules using Dagger2&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://proandroiddev.com/android-architecture-starring-kotlin-coroutines-jetpack-mvvm-room-paging-retrofit-and-dagger-7749b2bae5f7" rel="noopener noreferrer"&gt;Android Architecture starring Kotlin Coroutines, Jetpack (MVVM, Room, Paging), Retrofit and Dagger 2&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://proandroiddev.com/official-kotlin-style-guide-with-ktlint-4a649c172956" rel="noopener noreferrer"&gt;Official Kotlin Style Guide with Ktlint&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://proandroiddev.com/gradle-dependency-management-with-kotlin-94eed4df9a28" rel="noopener noreferrer"&gt;Gradle dependency management with Kotlin (buildSrc)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://proandroiddev.com/detecting-kotlin-code-smells-with-detekt-e79c52a35faf" rel="noopener noreferrer"&gt;Detecting Kotlin Code Smells with Detekt&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://medium.com/mindorks/best-coding-practices-tips-and-more-for-android-4ec03c7eeb2c" rel="noopener noreferrer"&gt;Best coding practices, tips and more for Android&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Libraries
&lt;/h3&gt;

&lt;p&gt;The open-source community create and maintains tons of awesome libraries making your job more easy, giving the opportunity to use them in your developments. Here are a very important collection of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://github.com/wasabeef/awesome-android-ui" rel="noopener noreferrer"&gt;awesome-android-ui&lt;/a&gt; - collection list of awesome Android UI/UX libraries.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/KotlinBy/awesome-kotlin#android-libraries" rel="noopener noreferrer"&gt;awesome-android-libraries&lt;/a&gt; - collection of awesome Kotlin related stuff.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://android-arsenal.com/" rel="noopener noreferrer"&gt;android-arsenal&lt;/a&gt; - android developer portal with tools, libraries, and apps.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Best practices
&lt;/h3&gt;

&lt;p&gt;Avoid reinventing the wheel by following these guidelines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/distribute/best-practices" rel="noopener noreferrer"&gt;Google best practices&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/futurice/android-best-practices" rel="noopener noreferrer"&gt;Android development best practices&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Codelabs
&lt;/h3&gt;

&lt;p&gt;Google Developers Codelabs provide a guided, tutorial, hands-on coding experience. Most codelabs will step you through the process of building a small application, or adding a new feature to an existing application. They cover a wide range of android concepts to learn and practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/courses/fundamentals-training/toc-v2" rel="noopener noreferrer"&gt;Android Developer Fundamentals&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://codelabs.developers.google.com/?cat=Android" rel="noopener noreferrer"&gt;Android Developer Codelabs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F76w4n5qj7na7lk7pmcz1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F76w4n5qj7na7lk7pmcz1.png" alt="Alt Text" width="676" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are certain benefits in writing or migrating to Modular App and using Architecture Components with them. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster build times.&lt;/li&gt;
&lt;li&gt;Fine-grained dependency control.&lt;/li&gt;
&lt;li&gt;Improve reusability across other apps.&lt;/li&gt;
&lt;li&gt;Improves the ownership &amp;amp; the quality of the codebase.&lt;/li&gt;
&lt;li&gt;Stricter boundaries when compared to packages.&lt;/li&gt;
&lt;li&gt;Encourages Open Source of the newly created libraries.&lt;/li&gt;
&lt;li&gt;Makes Instant Apps &amp;amp; Dynamic Features possible (improving discoverability).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember, keeping modules &lt;a href="https://proandroiddev.com/clean-architecture-data-flow-dependency-rule-615ffdd79e29" rel="noopener noreferrer"&gt;Clean&lt;/a&gt; improves testability and eases future refactoring in case it needs to be shared between multiple user-facing features.&lt;/p&gt;




&lt;p&gt;The aim of this article was to provide a brief overview of how to combining all architecture puzzles together into your current/next project. &lt;/p&gt;

&lt;p&gt;If you have any questions, improvements, recommendations about modularization and architecture components please add your response 🙂.&lt;/p&gt;

&lt;p&gt;The full open-source code can be found on GitHub:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/VMadalin/kotlin-sample-app" rel="noopener noreferrer"&gt;https://github.com/VMadalin/kotlin-sample-app&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/vmadalin" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs31ex3t32t40fwbfusfw.png" width="159" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for your time and reading.&lt;br&gt;
V.Madalin&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>architecture</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Sample Android Components Architecture</title>
      <dc:creator>Madalin Valceleanu</dc:creator>
      <pubDate>Tue, 19 Nov 2019 10:05:15 +0000</pubDate>
      <link>https://dev.to/vmadalin/sample-android-components-architecture-291g</link>
      <guid>https://dev.to/vmadalin/sample-android-components-architecture-291g</guid>
      <description>&lt;p&gt;Sample Project that presents modern, 2019 approach to Android application development using Kotlin, MVVM architecture, single Activity pattern, latest tech-stack: androidx, gradle-dsl, dynamic-features, retrofit, coroutines, live data, room, paging, dagger and more..&lt;/p&gt;

&lt;p&gt;link: &lt;a href="https://github.com/VMadalin/kotlin-sample-app" rel="noopener noreferrer"&gt;https://github.com/VMadalin/kotlin-sample-app&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech-stack
&lt;/h2&gt;

&lt;p&gt;This project takes advantage of many popular libraries, plugins and tools of the Android ecosystem. Most of the libraries are in the stable version, unless there is a good reason to use non-stable dependency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dependencies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/jetpack" rel="noopener noreferrer"&gt;Jetpack&lt;/a&gt;:

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/kotlin/ktx.html" rel="noopener noreferrer"&gt;Android KTX&lt;/a&gt; - provide concise, idiomatic Kotlin to Jetpack and Android platform APIs.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/jetpack/androidx" rel="noopener noreferrer"&gt;AndroidX&lt;/a&gt; - major improvement to the original Android &lt;a href="https://developer.android.com/topic/libraries/support-library/index" rel="noopener noreferrer"&gt;Support Library&lt;/a&gt;, which is no longer maintained.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/studio/profile/benchmark.html" rel="noopener noreferrer"&gt;Benchmark&lt;/a&gt; - handles warmup, measures your code performance, and outputs benchmarking results to the Android Studio console.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/topic/libraries/data-binding/" rel="noopener noreferrer"&gt;Data Binding&lt;/a&gt; - allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/topic/libraries/architecture/lifecycle" rel="noopener noreferrer"&gt;Lifecycle&lt;/a&gt; - perform actions in response to a change in the lifecycle status of another component, such as activities and fragments.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/topic/libraries/architecture/livedata" rel="noopener noreferrer"&gt;LiveData&lt;/a&gt; - lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/guide/navigation/" rel="noopener noreferrer"&gt;Navigation&lt;/a&gt; - helps you implement navigation, from simple button clicks to more complex patterns, such as app bars and the navigation drawer.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/topic/libraries/architecture/paging/" rel="noopener noreferrer"&gt;Paging&lt;/a&gt; - helps you load and display small chunks of data at a time. Loading partial data on demand reduces usage of network bandwidth and system resources.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/topic/libraries/architecture/room" rel="noopener noreferrer"&gt;Room&lt;/a&gt; - persistence library provides an abstraction layer over SQLite to allow for more robust database access while harnessing the full power of SQLite.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/topic/libraries/architecture/viewmodel" rel="noopener noreferrer"&gt;ViewModel&lt;/a&gt; - designed to store and manage UI-related data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;  &lt;a href="https://kotlinlang.org/docs/reference/coroutines-overview.html" rel="noopener noreferrer"&gt;Coroutines&lt;/a&gt; - managing background threads with simplified code and reducing needs for callbacks.&lt;/li&gt;

&lt;li&gt;  &lt;a href="https://dagger.dev/" rel="noopener noreferrer"&gt;Dagger2&lt;/a&gt; - dependency injector for replacement all FactoryFactory classes.&lt;/li&gt;

&lt;li&gt;  &lt;a href="https://square.github.io/retrofit/" rel="noopener noreferrer"&gt;Retrofit&lt;/a&gt; - type-safe HTTP client.&lt;/li&gt;

&lt;li&gt;  &lt;a href="https://github.com/bumptech/glide" rel="noopener noreferrer"&gt;Glide&lt;/a&gt; -  image loading and caching library for Android focused on smooth scrolling.&lt;/li&gt;

&lt;li&gt;  &lt;a href="https://github.com/square/moshi" rel="noopener noreferrer"&gt;Moshi&lt;/a&gt; - makes it easy to parse JSON into Kotlin objects.&lt;/li&gt;

&lt;li&gt;  &lt;a href="https://github.com/JakeWharton/timber" rel="noopener noreferrer"&gt;Timber&lt;/a&gt; - a logger with a small, extensible API which provides utility on top of Android's normal Log class.&lt;/li&gt;

&lt;li&gt;  &lt;a href="http://facebook.github.io/stetho/" rel="noopener noreferrer"&gt;Stetho&lt;/a&gt; - debug bridge for applications via Chrome Developer Tools.&lt;/li&gt;

&lt;li&gt;  &lt;a href="https://github.com/VMadalin/kotlin-sample-app/blob/master/buildSrc/src/main/kotlin/dependencies/Dependencies.kt" rel="noopener noreferrer"&gt;and more...&lt;/a&gt;
&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Test Dependencies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/training/testing/ui-automator" rel="noopener noreferrer"&gt;UIAutomator&lt;/a&gt; - a UI testing framework suitable for cross-app functional UI testing across system and installed apps.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/training/testing/espresso" rel="noopener noreferrer"&gt;Espresso&lt;/a&gt; - to write concise, beautiful, and reliable Android UI tests&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/robolectric/robolectric" rel="noopener noreferrer"&gt;Robolectric&lt;/a&gt; - industry-standard unit testing framework for Android.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/junit-team/junit4" rel="noopener noreferrer"&gt;JUnit&lt;/a&gt; - a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/nhaarman/mockito-kotlin" rel="noopener noreferrer"&gt;Mockito&lt;/a&gt; - most popular Mocking framework for unit tests written in Java.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/android/android-test" rel="noopener noreferrer"&gt;AndroidX&lt;/a&gt; - the androidx test library provides an extensive framework for testing Android apps.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/VMadalin/kotlin-sample-app/blob/master/buildSrc/src/main/kotlin/dependencies/TestDependencies.kt" rel="noopener noreferrer"&gt;and more...&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Plugins
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://github.com/pinterest/ktlint" rel="noopener noreferrer"&gt;Ktlint&lt;/a&gt; - an anti-bikeshedding Kotlin linter with built-in formatter.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/arturbosch/detekt" rel="noopener noreferrer"&gt;Detekt&lt;/a&gt; - a static code analysis tool for the Kotlin programming language.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/diffplug/spotless" rel="noopener noreferrer"&gt;Spotless&lt;/a&gt; - a code formatter can do more than just find formatting errors.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/ben-manes/gradle-versions-plugin" rel="noopener noreferrer"&gt;Versions&lt;/a&gt; - make easy to determine which dependencies have updates.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://developer.android.com/guide/navigation/navigation-pass-data#Safe-args" rel="noopener noreferrer"&gt;SafeArgs&lt;/a&gt; - generates simple object and builder classes for type-safe navigation and access to any associated arguments.&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/jacoco/jacoco" rel="noopener noreferrer"&gt;Jacoco&lt;/a&gt; - code coverage library&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/VMadalin/kotlin-sample-app/blob/master/buildSrc/build-dependencies.gradle.kts" rel="noopener noreferrer"&gt;and more...&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>architecture</category>
      <category>sample</category>
      <category>kotlin</category>
    </item>
    <item>
      <title>Building my smart home</title>
      <dc:creator>Madalin Valceleanu</dc:creator>
      <pubDate>Fri, 04 Oct 2019 10:26:58 +0000</pubDate>
      <link>https://dev.to/vmadalin/building-my-smart-home-3b0m</link>
      <guid>https://dev.to/vmadalin/building-my-smart-home-3b0m</guid>
      <description>&lt;p&gt;In this article that is focused on the entire public, I will explain experiences, anecdotes about a personal project of how I turned my home into smart and how can I also control the different electronic devices, enter in home by phone with a simple gesture or open the building door using a Siri voice command.&lt;/p&gt;

&lt;p&gt;Basically the idea was started with an Arduino kit that I had purchased and I had started to fiddle with the different modules joysticks, relays, motors, displays, etc .. So I decided to turn my home into a smart and control it from the phone. Although it could also be integrated with GoogleHome / HomePod, but for the moment I postponed it for another phase.&lt;/p&gt;

&lt;p&gt;These have been the objectives of the project that I set before starting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Power on/off, control the intensity and program the house lights as well the plugs.&lt;/li&gt;
&lt;li&gt;Measure the indoor and outdoor temperature to regulate it.&lt;/li&gt;
&lt;li&gt;Opening the building door with voice commands via Siri.&lt;/li&gt;
&lt;li&gt;Opening the home door via fingerprint and detect its closure. In addition add a button to facilitate opening from inside.&lt;/li&gt;
&lt;li&gt;Notification system and historical records of all door activity&lt;/li&gt;
&lt;li&gt;Installation of several security measures, to guarantee the integrity of the home.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The advantage of opening the home door from the mobile device apart from providing access and control of who enters and leaves, increases security since many families don’t usually lock the door, just close it using the latch. So it makes the work of thieves more easy and we don’t want that.&lt;/p&gt;

&lt;p&gt;To do this, I used the Rasberry Pi a small single-board computer where you would end up connecting and controlling all the devices in the home that you would like to add through the Domoticz automation system.&lt;/p&gt;

&lt;p&gt;In the market there are several options when we talk about smart devices of many brands and for all pockets. From a light bulb to cameras, thermostats, refrigerators, etc. At the end anything no matter how small, that can be connected to WiFi/bluetooth is called an IoT device.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe458v6gqvwb1e9zhx5s4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe458v6gqvwb1e9zhx5s4.png" alt="IoT device types" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, apart from acquiring some and installing them, they can also be created by oneself depending on the needs we have. In my case I used the ESP8266 chips together with the relay module powered at 5V for example to turn on/off the electrical circuit of a mini water fountain.&lt;/p&gt;

&lt;p&gt;Moreover for all the control home temperature, the Node MCU chip has been used for taking measurements every X time interval updating data to Domoticz, which would be able to start up the heating system if is necessary. Also I decided to add a display to visualize temperature and time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1tjwt1muv37imld85bop.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1tjwt1muv37imld85bop.png" alt="On the left the module ESP8266 and on the right the Node MCU" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dashboar
&lt;/h2&gt;

&lt;p&gt;Once all the devices are configured, this would be the Domoticz interface, also accessible from the mobile. Basically from here we can control all connected devices, add, delete and much more. Accessing of course, only from the local network.&lt;/p&gt;

&lt;p&gt;In addition we can program each device and add additional logic, for example when it should turn on, off, with specific intensity. Depends on our case we may be interested in one state or another.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhxi8sc8qs6kp05a346je.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhxi8sc8qs6kp05a346je.png" alt="Desktop dashboard" width="800" height="556"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my case as you can see, I have relevant information about the Raspberry Pi, the temperature outside and inside the house. Also some plugs, lights from different rooms or areas of the house.&lt;/p&gt;

&lt;p&gt;Also the possibility of enabling/disabling the door mechanism, and some other options.&lt;/p&gt;

&lt;h2&gt;
  
  
  3D Modeling and Printing
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F876zgmojyhtfuc5a02f3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F876zgmojyhtfuc5a02f3.png" alt="Sketch" width="800" height="693"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To open the home door, a signal that arrives is not enough. That signal has to launch an action, in this case turn the key, an action that we perform daily. Although I saw some “smart lock” mechanisms, but none fitted with the type of my door.&lt;/p&gt;

&lt;p&gt;Moreover who wants a battery-based system? We wouldn’t like him to run out of battery with us outside the home. So the system should be directly connected to the power and only in case of emergency be powered by an electric accumulator.&lt;/p&gt;

&lt;p&gt;For do this, it was necessary to begin to take measures and build something from scratch that made it possible to turn the key, taking into account that it is a reinforced door.&lt;/p&gt;

&lt;p&gt;After making the plastic structure and the handlebar, I began to design the sustenance of the servo motor. My main intention was to split the key in 2 parts to make all the support more compact, but when I couldn’t do it, I decided to leave the idea. There was also the possibility of making a gear system but taking into account the durability that this required and the turning force I decided to opt for something more simple. I started to design the 3D pieces and then print them and after some readjusting this is the final result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fixobdduugh9o52wwp3np.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fixobdduugh9o52wwp3np.png" alt="Assembly of all the components, in red it would be other parts like the servo and the key" width="800" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These components are accessible and can be downloaded from the website thingiverse.com (website dedicated to the sharing of user-created digital design files).&lt;/p&gt;

&lt;h2&gt;
  
  
  Assemble
&lt;/h2&gt;

&lt;p&gt;The assemble may take a long time but we don’t want to see the cables hanging because apart from being unsightly can cause greater consequences such as short circuits. To ensure that doesn’t happen, we have to use a property cable holding.&lt;/p&gt;

&lt;p&gt;This would be the result in my case, trying to make the cables barely notice even though they travel through the door frame until they reach the lock.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezbxbbai41wuz32h11kv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fezbxbbai41wuz32h11kv.png" alt="On the left we can see the intercom that is connected to the Raspberry Pi. And on the right the servo motor hold by the piece printed in 3D." width="800" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the same time, a button can be seen halfway up the door, it is the DashButton he has the responsibility to open the door from inside in a very simple way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Electrical Circuit
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2fjxi63ibtteqjz1f88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2fjxi63ibtteqjz1f88.png" alt="Diagram of connection of the different components" width="800" height="687"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once seen the assemble part I will explain the components that form it, as well as the connection with the Raspberry Pi. To be able to build it, I perform different proof of concept on a small scale, testing different configurations before making the final assembly.&lt;/p&gt;

&lt;p&gt;This circuit could be perfectly soldered instead of a breadboard, although it can always be done at another step.&lt;/p&gt;

&lt;p&gt;These are the different components used for its construction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1x Servo Motor: Whose function is to turn the key to open and close the door.&lt;/li&gt;
&lt;li&gt;1x Power supply: 9V DC current supplied to the servo motor for proper operation.&lt;/li&gt;
&lt;li&gt;1x Magnetic Switch: Detects when the door closes and send the command to the servo to turn the key.&lt;/li&gt;
&lt;li&gt;2x Relays: One responsible for closing the intercom button and the other to power the servo only when it required.&lt;/li&gt;
&lt;li&gt;2x Transistors NPN: Solving common Raspberry Pi problem of stepping up &lt;/li&gt;
&lt;li&gt;3.3 GPIO to 5V for power the relay.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This sketch is accessible and can be downloaded from the website fritzing.com (open-source hardware initiative that makes electronics accessible as a creative material for anyone).&lt;/p&gt;

&lt;h2&gt;
  
  
  Mobile Application
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fspcwm1l0ikz9dkxjtdrz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fspcwm1l0ikz9dkxjtdrz.png" alt="The different parts of the application." width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To maximize the security for all entire engine, I decided to create an application where all the information passed through my own server, in order to register and control all the traffic, as well the access, instead of using Domoticz for this critical part. I used React-Native framework for this development.&lt;/p&gt;

&lt;p&gt;The application is not public and is completely for internal use, consisting of the following functionalities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fingerprint scanner when trying to launch an action&lt;/li&gt;
&lt;li&gt;Add Siri shortcut command only available for the building door&lt;/li&gt;
&lt;li&gt;Notifications and alerts system&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;The door opening engine has gone through several phases throughout the development from alpha versions, to the current one, paying special attention to security and giving stability to work properly. Since we don’t want the engine to stop responding or fail. So today and with all the members of the family using daily the engine has been functioning correctly for more than a month.&lt;/p&gt;

&lt;p&gt;Here is the demo of how it works:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=_gGbyX5ESdY" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpg5xo4zilzhr6h6qc5hf.png" alt="Demo prototype door engine" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Basically the intercom system keeps the building door opened for a few seconds after receiving the action sended from Siri command, enough to be able to enter from the outside. This action is received by the Raspberry Pi that closes the intercom system button circuit through the relay, executing the same logic as if we had pressed it.&lt;/p&gt;

&lt;p&gt;On the other hand, the action of opening the reinforced door can only be released by fingerprint and the door will remain open until the magnetic switch detects the closure of the door, as can be seen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technologies and libraries
&lt;/h2&gt;

&lt;p&gt;In terms of technologies used in the project, the server and the Raspberry Pi running in nodeJS. Using SSE (Server Send Events) for such communication, together with AWS Lambdas for the execution of different actions.&lt;/p&gt;

&lt;p&gt;Without forgetting the PM2 (Process Manager2) production runtime and process manager to allow to keep applications alive forever, to reload them without downtime and facilitate common DevOps tasks.&lt;/p&gt;

&lt;p&gt;To control the GPIO (General Purpose Input Output) have used node library pigpio, a wrapper for the pigpio C library. Although other alternatives like johnny-five used for IoT and Robotics programming.&lt;/p&gt;

&lt;p&gt;The mobile application use a specific npm libraries for the following features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fingerprint scanner feature: &lt;a href="https://www.npmjs.com/package/react-native-fingerprint-scanner" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/react-native-fingerprint-scanner&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Siri commands feature: &lt;a href="https://www.npmjs.com/package/react-native-siri-shortcut" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/react-native-siri-shortcut&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The driver control of the different microchips used for ESP8266 and Node MCU in the assembly, as well as the different device modules connected to them, such as the temperature and humidity sensor (DTH11), 4-digit display (TM1637), relay module and others, have used with specific libraries recommended by the manufacturer that some of them can be found here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Software
&lt;/h2&gt;

&lt;p&gt;To build the different parts of the project such as the system of monitoring and devices controller, 3D modeling and printing, the design and programming the circuit, I have been used different third-party software like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automation System: Domoticz&lt;/li&gt;
&lt;li&gt;Electronic prototyping: Arduino, Fritzing&lt;/li&gt;
&lt;li&gt;3D Printing: Ultimaker Cura, Simplify3D&lt;/li&gt;
&lt;li&gt;3D Modeling: Fusion360, SketchUp&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvdknvyznp6xhl6i0wub.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvdknvyznp6xhl6i0wub.jpg" alt="Summary" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nowadays more and more people talking about smart home, companies are involve their efforts to conquer a growing market and makes people life easier. For this purpose they design and sell many kinds of devices and kits like sensors, controllers, lights, switches and more .. So everyone could make their own smart home and control it by their phone, voice and gestures.&lt;/p&gt;

&lt;p&gt;Think about having the possibility of scheduling the temperature before arriving at home, being able to monitor your home through an installed security camera, controlling the different electronic devices by voice commands, lifting the blinds at the morning automatically and why not, enter in your home without keys only from mobile phone.&lt;/p&gt;

&lt;p&gt;Although the possibilities are endless as one wants. The technology is available to be used to facilitate our lives.&lt;/p&gt;

&lt;p&gt;Support me:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/vmadalin" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb0ecb7amtsksnqwwh6my.png" alt="Buy me a tea" width="159" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for your time and reading.&lt;/p&gt;

&lt;p&gt;V.Madalin&lt;/p&gt;

</description>
      <category>android</category>
      <category>ios</category>
      <category>javascript</category>
      <category>reactnative</category>
    </item>
    <item>
      <title>Building my smart home</title>
      <dc:creator>Madalin Valceleanu</dc:creator>
      <pubDate>Fri, 04 Oct 2019 06:55:28 +0000</pubDate>
      <link>https://dev.to/vmadalin/building-my-smart-home-e5e</link>
      <guid>https://dev.to/vmadalin/building-my-smart-home-e5e</guid>
      <description>&lt;p&gt;I explain experiences, anecdotes about a personal project of how I turned my home into smart and how can I also control the different electronic devices, enter in home by phone with a simple gesture or open the building door using a Siri voice command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/hackernoon/my-smart-home-2bfc9da635c1" rel="noopener noreferrer"&gt;https://medium.com/hackernoon/my-smart-home-2bfc9da635c1&lt;/a&gt;&lt;/p&gt;

</description>
      <category>android</category>
      <category>ios</category>
      <category>javascript</category>
      <category>reactnative</category>
    </item>
  </channel>
</rss>
