I've just read the Guide to App Architecture. In this google demonstrates the basic guidelines for building robust android applications using the new Android Architecture Components. As shown in this year's Google I/O an app should have 4 layers:
Where the dependencies flow from top to bottom with higher layers only having knowledge of the components that are directly below them, eg. UI Controller only knows about ViewModel , ViewModel only know about Repository etc.
So I watched the videos, completed the corresponding codelabs, then I studied the guide and after having a coarse understanding I began to code the use-case that was discussed in this guide.
The object of the guide was to implement an app that simply fetches a User object from the backend and shows it to the user, all with respect to clean Architecture.
My question arose as soon as I started coding this use case. The whole application is dependent in this User Pojo. The Repository fetches it from the backend then it persists it in the DataSource using Room and with the help of LiveData the ViewModel and UI are notified. So **in which layer should the definition of my data model -in this use-case the User Pojo- be **. Or each layer should have a User Pojo that will be mapped from the User Pojo that comes from the lower layer?
I would add one "layer" to the picture: the model, or domain if you will. When it comes to room, the model is a simple set of POJO objects. The model layer does not have relations to other layers, but it can be references from all the other layers in your picture.