Skip to content

gonzaloguzzardi/android-clean-arquitecture

Repository files navigation

Android Clean Arquitecture

Simple proyect to showcase clean arquitecture and and modern android development skills.

Kotlin Version AGP Gradle

API CircleCI Awesome Kotlin Badge

Require Android Studio 4.1

Project characteristics

Tech-stack

Min API level is set to 21

Architecture

App layer (Presentation layer)

This layer is closest to what the user sees on the screen. The app layer uses MVVM using ViewModel to preserve data on configuration changes)

App layer depends on Domain and Data layers.

Components:

  • Views (Fragment) - presents data on the screen and pass user interactions to View Model
  • ViewModel - dispatches (through LiveData) state changes to the view and deals with user interactions
  • ViewState - common state for a single view

Domain layer

This is the core layer of the application. Notice that the domain layer is independent of any other layers. This allows to make domain models and business logic independent from other layers.

Components:

  • UseCase - contains business logic
  • DomainModel - defines the core structure of the data that will be used within the application
  • Repository interface - required to keep the domain layer independent from the data layer

Data layer

Manages application data and exposes these data sources as repositories to the domain layer. Used to retrieve data from the internet using retrofit and caching this data locally in a SQLite database using room.

Data layer depends only on Domain, implementing interfaces domain layer exposes.

Components:

  • Repository - Handles data and exposes it to the domain layer.
  • Mapper - maps data model to domain model (to keep domain layer independent from the data layer). Here mappers are implemented as functions in Model classes.
  • RetrofitService - defines a set of API endpoints.
  • DataModel - defines the structure of the data retrieved from the network or databases and contains annotations

Getting started

To open this project follow any of the next steps:

Android Studio 4.1

  1. Android Studio -> File -> New -> From Version control -> Git
  2. Enter https://github.com/gonzaloguzzardi/android-clean-arquitecture.git into URL field

Command-line + Android Studio 4.1

  1. Run git clone https://github.com/gonzaloguzzardi/android-clean-arquitecture.git
  2. Android Studio -> File -> Open