This guide encompasses best practices and recommended architecture for building robust, high-quality apps
This sample demonstrates how one can
- Setup base architecture of KMM (Kotlin Multiplatform Mobile) app using Clean Architecture
- Use Koin(dependency injection) for layers separation
- Make api calls using Ktor plugin.
βββ androidApp
| βββ di
| βββ presentation/features
βββ iosApp
| βββ iosApp
| βββ Presentation
βββ shared
βββ androidMain
| βββ db
| βββ BaseViewModel.kt
βββ commonMain
| βββ kotlin
| | βββ common
| | βββ db
| | βββ di
| | βββ photo
| | βββ BaseViewModel.kt
| βββ sqldelight
| βββ ForestDatabase.sq
βββ iosMain
βββ db
βββ di
- Kotlinx Coroutines Core : Library support for Kotlin coroutines with multiplatform support.
- Lifecycle ViewModel Kotlin Extensions : Kotlin extensions for 'viewmodel' artifact
- SqlDelight : SQLDelight generates typesafe Kotlin APIs from your SQL statements. It verifies your schema, statements, and migrations at compile-time and provides IDE features like autocomplete and refactoring which make writing and maintaining SQL simple.
- Koin : KOIN - Kotlin simple Dependency Injection Framework
- Ktor : Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
- Coil_Compose : An image loading library for Android backed by Kotlin Coroutines.
There are 3 main modules to help separate the code. They are Data, Domain, and Presentaion.
-
Data contains Local Storage, APIs, Data objects (Request/Response object, DB objects), and the repository implementation.
-
Domain contains UseCases, Domain Objects/Models, and Repository Interfaces
-
Presentaion contains UI, View Objects, Widgets, etc. Can be split into separate modules itself if needed. For example, we could have a module called Device handling things like camera, location, etc.
- View,updates UI
Image | |
---|---|