Skip to content

Latest commit

 

History

History
42 lines (27 loc) · 2.38 KB

readme.md

File metadata and controls

42 lines (27 loc) · 2.38 KB

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 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:

Image of architecture


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.

We are using the following libraries:

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 (currently in progress).