OK let's start with the simple usecase of "Fetch User Info", business requirements specify that you should try to fetch fresh data from an API, if that's not possible, fetch the data from your cache if any.
FetchUserInfoUseCase
and wait to receive a UserInfo
data class, now we've entered the data layer.FetchUserInfo
usecase will use the UserRepository
to request this data entity.UserRepository
will try using a UserRemoteDataSource
and on failure will fallback to using a UserLocalDataSource
.UserRemoteDataSource
and the UserLocalDataSource
return a UserInfo
data class.Retrofit
for remote and maybe Room
for local.Retrofit
which will mostly return a POJO Gson
object as a domain entity, this will need to be mapped to a UserInfo
data entity, for that we will need a mapper.Room
's case, it is a database domain entity which will also need to mapped to our UserInfo
data class, so, another mapper.UserInfo
and will report it back to the data layer's UserRepository
which in turn reports back to the FetchUserInfoUseCase
which will report back to the presentation layer.UserInfo
data entity class into a simpler UI version to pass to the view, say a UserInfoViewModel
presentation entity.Hope that clears things up a little.