Layered Architecture in a Kotlin Multiplatform project

This project was created by a series of posts you can find on my blog https://jflavio.com

The domain and data layers are both inside the shared module of the Kotlin Multiplatform project. The final architecture looks like this: Basic architecture of the project

Core or shared module

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.

androidMain

Here we only have an implementation of the database driver interface defined in the commonMain package but for Android.

iOSMain

Here we only have an implementation of the database driver interface defined in the commonMain package but for the iOS project.

commonMain

Here is where magic happens. We define the domain and data layers inside this package. By the way, we support Kotlin Coroutines ?.

Android module

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.

iOS 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.

GitHub

View Github