This document describes how modules must be structured.
Each module use Clean architecture aproach and contains at least 3 sub-packages. domain, data and presentation.
Execute business logic which is independent of any layer
-
models: Contains models annotated with Room annotations. These classes containstoPresentationModel()which converts models to be usen inpresentationlayer.- Name convention:
<Name>Model.kt - Dependencies: no dependencies
- Name convention:
-
repositories: Behavior descriptions implemented by real repositories indatalayer. Only interfaces are allowed here.- Name convention:
<Name>Repository.kt - Dependencies: no dependencies
- Name convention:
Dispense the required data for the application to the domain layer by implementing interface exposed by the domain
-
databases: Contains Room database implementation. It should bind all required entities implemented indomainlayer. Each database should provide aDAOobject which will perfom queries in Database. 1.1daos: Contains interfaces that works over the database to perform queries- Name convention:
<Name>Database.kt - Dependencies: zero or more
DAOinterfaces
- Name convention:
-
repositories: These aredomainimplementation of repositories. You should be use it only inusecases.- Name convention:
<Name><BaseName>Repository.kt(Basenameis thedomainrepository implemented) - Dependencies: a
Databaseobject
- Name convention:
-
usecases: Classes which depends ondomain.repositoriesimplementations written indata.repositories.- Name convention:
<Name>UseCase.kt - Dependencies: zero or more
domain.repositoriesobjects implemented indatalayer
- Name convention:
Include both domain and data layer and is android specific which executes the UI logic
-
activities: Contains at least oneActivityclass which will be the entry point of the module (does not apply for Services)- Name convention:
<Name>Activity.kt - Dependencies: zero or one
ViewModelobject
- Name convention:
-
fragments: ContainsFragmentclasses that can be reached by adestinationdescribed in some*_navigation.xmlin module.destinations are references to fragment that are used by aCoordinator(does not apply for Services).Fragments can be injected by oneViewModel`- Name convention:
<Name>Fragment.kt - Dependencies:
- zero or one
ViewModelobject - zero or one
Presenterobject
- zero or one
- Name convention:
-
models: Presentation models used to render inViewprovided by some Presenter.- Name convention:
<Name>PresentationModel.kt - Dependencies: no dependencies
- Name convention:
-
presenters: The "glue" between aViewStateandView. Its classes must implementsPresenterinterface which provides methodsgetView()which returns aViewto be usen in someFragment|Activityanupdate(state: ViewState)which changesViewrendering data described instate. Name convention:<Name>Presenter.ktDependencies: no dependencies -
viewmodels: These stores and manage UI-related data in a lifecycle conscious way. It allows data to survive configuration changes such as screen rotations. These classes must be implemented only inFragments orActivitys. ViewModels should be injected only withdata.usecasesclasses- Name convention:
<Name>ViewModel.kt - Dependencies: zero or more
UseCaseobjects
- Name convention:
Dependencies of all previous layers are injected by Kodein. All dependencies are described in <module_name>/Dependencies.kt which contains a object with dependency bindings.
Typical bindings
domain.repositoriesimplementationsdata.usecasesimplementationsdata.databaseimplementationspresentation.presentersimplementationspresentation.viewmodelsimplementations
- Modules should be named as
<name>Featureor<name>Service(lowercaseUppercase classic java notation). - The proposed directory structure per module is as follows:
<ModuleName>/
/domain
/models
/repositories
/data
/databases
/repositories
/usecases
/presentation
/activities
/fragments
/models
/presenters
/viewmodels
Dependencies.kt