This project was created by a series of posts you can find on my blog https://jflavio.com Follow the series here 👉 https://jflavio.com/categories/kmm-serie/
The domain and data layers are both inside the shared
module of the Kotlin Multiplatform project. The final architecture looks like this:
Here is where all the business logic is defined. It contains cross code for all platform. This includes: repositories interfaces, repositories implementations, data sources implementation, networking access for consuming REST APIs, interactors and main domain models.
We are using the following libraries:
- ktor for networking access
- kotlinx serialization for transforming JSON responses into DTOs
- SQDelight as database management. Each platform implement its own driver.
- Kotlin Coroutines
- BuildKonfig for having build configuration fields across platforms (such as API Key).
Here we only have an implementation of the database driver interface defined in the commonMain
package but for Android.
Here we only have an implementation of the database driver interface defined in the commonMain
package but for the iOS project.
Here is where magic happens. We define the domain and data layers inside this package. By the way, we support Kotlin Coroutines 😉.
Implements the MVVM pattern using Jetpack Compose. The ViewModels depends on the interactors interfaces that are defined in the domain layer inside the shared
module.
Implements the MVVM pattern using SwiftUI. The ViewModels depends on the interactors interfaces that are defined in the domain layer inside the shared
module (currently in progress).