Skip to content

The Zero To Hero - App consuming a Rick and Morty API to display Characters has been built with clean architecture principles, Repository Pattern, and MVVM pattern as well as Architecture Components.

msddev/Sample-MVVM-Clean-Arch

Repository files navigation

Zero-to-Hero

The Zero To Hero - App consuming a Rick and Morty API to display Characters it has been built with clean architecture principles, Repository Pattern, and MVVM pattern as well as Architecture Components.

This app shows the usage of the new Navigation Architecture Component in collaboration with the Bottom Navigation view with separate back stack history for each tab.

App features:

  • List of Rick and Morty characters
  • Detail of characters
  • Bookmark character
  • Light/ Dark theme.

Screenshots

Light01 Light02 Light03 Light04 Dark11 Dark12 Dark13 Dark14

Architecture

Uses concepts of the notorious Uncle Bob's architecture called Clean Architecture.

  • Better separation of concerns. Each module has a clear API., Feature related classes life in different modules and can't be referenced without explicit module dependency.
  • Features can be developed in parallel eg. by different teams
  • Each feature can be developed in isolation, independently from other features
  • faster compile time

Modules:

  • rick-and-morty-ui - It uses all the components and classes related to Android Framework. It gets the data from presentation layer and shows on UI. (access all the modules)
  • data - The data layer implements the repository interface that the domain layer defines. This layer provide a single source of truth for data. (Kotlin module that can only access domain module)
  • remote - Handles data interacting with the network. (can only access data module)
  • cache - Handles data interacting with the local storing (Room DB). (can only access data module)
  • domain - The domain layer contains the UseCases that encapsulate a single and very specific task that can be performed. This task is part of the business logic of the application. (Kotlin module that cannot access any other module)
  • presentation - MVVM with ViewModels exposing LiveData that the UI consume. The ViewModel does not know anything about it's consumers. (Android module that can only access domain module)

Tech stack - Library:

  • Kotlin
  • Coroutines - A coroutine is a concurrency design pattern that you can use on Android to simplify code that executes asynchronously
  • Flow - Flow is used to pass (send) a stream of data that can be computed asynchronously
  • Dagger-Hilt - for dependency injection.
  • Kotlin-DSL - Used to handle gradle dependencies and config versions
  • JetPack
    • LiveData - For reactive style programming (from VM to UI).
    • Lifecycle - Used get lifecyle event of an activity or fragment and performs some action in response to change
    • ViewModel - Stores UI-related data that isn't destroyed on UI changes.
    • Room - Used to create room db and store the data.
    • Navigation - Used to navigate between fragments
    • Data Binding - Used to bind UI components in your XML layouts.
  • Material-Components - Material design components like ripple animation, cardView.
  • Retrofit - Used for REST api communication.
  • OkHttp - HTTP client that's efficient by default: HTTP/2 support allows all requests to the same host to share a socket
  • Moshi - Used to convert Java Objects into their JSON representation and vice versa.
  • Timber - Used for logging.
  • Glide - Glide is a fast and efficient image loading library for Android

Reference repository

This repository code is mostly inspired by Android-Clean-Architecture-Boilerplate.

License & Copyright

Copyright 2021 Masoud Khoshkam.

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

The Zero To Hero - App consuming a Rick and Morty API to display Characters has been built with clean architecture principles, Repository Pattern, and MVVM pattern as well as Architecture Components.

Topics

Resources

Stars

Watchers

Forks

Languages