/CleanArch-Core

Clean Architecture Core with movies app as Example

Primary LanguageKotlin

Clean Architecture Core

Android architecture core using Clean Architecture and MVVM as presenter architecture Clean Architecture is used to achieve separation of concerns by dividing the software to layers and that's exactly what we are going to do here : I have divided Core to 3 Layers

  • Domain layer (Business Rules)
  • Data layer
  • Presenter Layer (MVVM)

Our Architecture Layers

1. Domain Layer

Domain layer is the business rules layer. it the baseline of your application . it's abstracted layers contains interfaces for all of your business logic which will be implemented in the upper layers such as Data

Domain

  • Entites Package contains dataclasses that describe the basic data structure you will work with . entities
    data class GuestEntity(@SerializedName("success") val isSuccess: Boolean,
                       @SerializedName("guest_session_id") val guestSessionId: String,
                       @SerializedName("expires_at") val expiredAt: String)
  • Base Interactors It has abstract classes that UseCasesClasses will extend later . Here i have made 3 types (CompletableUseCase , SingleUseCase , FlowableUseCase) They all need observeOnSchedular and subscribeOnSchedular in their constractor Base Interactors

  • BaseData It has interfaces of :

    • BaseCacheI : Interface with functions used in all cache classes
    • BaseRemoteI:Interface with functions used in all cache classes
    • BaseDataStoreFactory : used to get the suitable dataStore(cache , remote) Base data package
  • Business Logic Package contains two packages :

    • UseCaseImplementations : it contains all usecases classes which extend base interactors abstract classes useCases

    • Business case data logic interfaces alt text

-- CaseDataStore : interface has all functions in common in caseCacheI and caseRemoteI

-- CaseCacheI : interface has functions that only needed in the cache class e.g: savingDataToCache implements BaseCacheI

-- CaseRemoteI : interface has functions that only needed in the remote class implements BaseCacheI

.....To Be Continued