Architecture

Domain Layer

The Domain Layer is optional, and we won't be using it in this class. It's overkill for small applications. As your applications grow, it becomes a much more useful.

flowchart LR
    ui[User Interface Layer]
    ui --> uc1
    ui --> uc2
    ui --> uc3
    ui --> data
    data --> repo
    uc1 --> repo
    uc2 --> repo
    uc3 --> repo
    ds1 --> db[(Database)]
    ds2 --> file(((File)))
    ds3 --> ws(((Web Service)))
    subgraph Domain Layer
    direction LR
    data[Data]
    uc1[Use Case 1]
    uc2[Use Case 2]
    uc3[Use Case 3]
    end
    subgraph Data Layer
    direction LR
    repo[Repository] --> ds1[Data Source 1]
    repo[Repository] --> ds2[Data Source 2]
    repo[Repository] --> ds3[Data Source 3]
    end

(Arrows represent dependencies)

The gist of this layer is that is exposes data from the Data Layer along with Use Cases for common data modifications.

For more detail on the Domain Layer, please see https://developer.android.com/topic/architecture/domain-layer.

You may also be interested in learning about "Clean Architecture", which explains the use of a Domain Layer. Be careful though - adding a Domain Layer can increase the complexity of a smaller app and make its maintenance burdensome - you'll have to find that line, and much of depends on how many developers will be working on the same application. If only a few, it's best to keep it simple. If many developers on a larger application, the extra separation and explicit use cases can be a great help.