Skip to content

zprima/road-to-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Road to Android

Projects

Links

Project Structure

Guide to app arhitecture

  • ui (outer layer - it includes domain and data)
    • theme
    • navigation
    • screens
      • viewmodel
      • uistate
    • components
  • domain (its the most inner layer in the clean arhitecture. OPTIONAL - depends on app size. For small apps its just not worth it.)
    • usecase (verb in present tense + noun/what (optional) + UseCase)
    • repository (interfaces only)
    • models or packages by context
  • data (mid layer - it includes domain)
    • repository (implementations of interfaces) (type of data + Repository)
    • data sources (type of data + type of source + DataSource) (NewsLocalDataSource, NewsRemoteDataSource)
      • local
        • entity
        • dao
        • database
      • remote
        • dao
        • retrofit
    • work managers* (if any)
    • mappers (from db/remote model to domain model we want to use in our app/domain)
  • di
    • modules (network, app, database, ...)
  • util
    • constants
    • converters (date, uuid, ...)

In case DOMAIN module exists, the following is set:
UI module interacts with the DOMAIN module, does not interact with DATA module directly.
DATA module implements DOMAIN interfaces, does not interact with UI module directly.

Wrote a post about it: Android Jetpack Compose: Clean Arhitecture — 2022

Resource class for utils:

sealed class Resource<T>(val data: T? = null, val error: String? = null){
    class Success<T>(data: T?): Resource<T>(data)
    class Error<T>(error: String?, data: T? = null): Resource<T>(data, error)
    class Loading<T>(val isLoading: Boolean = true): Resource<T>(null)
}

sealed class NetworkResult<T : Any> {
    class Success<T: Any>(val data: T) : NetworkResult<T>()
    class Error<T: Any>(val code: Int, val message: String?) : NetworkResult<T>()
    class Exception<T: Any>(val e: Throwable) : NetworkResult<T>()
}

About

My roadmap to become an Android Developer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published