A showcase project demonstrating how to configure Koin with Annotations in a multi-module Kotlin Multiplatform project, leveraging convention plugins for streamlined build management.
This project illustrates modern dependency injection patterns in KMP using:
- Koin Annotations: Compile-time safe dependency injection with KSP (Kotlin Symbol Processing)
- Multi-Module Architecture: Clean separation of concerns across
domain,framework, and presentation layers - Convention Plugins: Centralized build configuration to reduce boilerplate across modules
- Cross-Platform Support: Targets Android, iOS, Web (Wasm/JS), and Desktop (JVM)
koin-annotations-example/
├── domain/ # Core business entities and models (pure Kotlin)
├── framework/ # Platform implementations and infrastructure
├── composeApp/ # Presentation layer (Compose Multiplatform UI)
└── build-logic/ # Convention plugins for build configuration
-
Convention Plugins: All modules use custom Gradle convention plugins defined in
build-logic/to apply consistent Koin and KSP configuration, eliminating repetitive build script code. -
Expect/Actual Pattern for DI: Platform-specific implementations are injected through Koin modules, keeping business logic free from platform specifics.
-
Compile-Time Safety: KSP processes Koin annotations at compile time, catching configuration errors before runtime.
-
/composeApp: Shared Compose Multiplatform UI code
- commonMain: Common UI code for all platforms
- Platform-specific folders (iosMain, jvmMain, etc.) for platform-specific implementations
-
/domain: Core domain models and entities
-
/framework: Infrastructure layer with platform-specific implementations
-
/iosApp: iOS application entry point
-
/build-logic: Convention plugins for centralized build configuration
To build and run the development version of the Android app, use the run configuration from the run widget in your IDE’s toolbar or build it directly from the terminal:
- on macOS/Linux
./gradlew :composeApp:assembleDebug
- on Windows
.\gradlew.bat :composeApp:assembleDebug
To build and run the development version of the desktop app, use the run configuration from the run widget in your IDE’s toolbar or run it directly from the terminal:
- on macOS/Linux
./gradlew :composeApp:run
- on Windows
.\gradlew.bat :composeApp:run
To build and run the development version of the web app, use the run configuration from the run widget in your IDE's toolbar or run it directly from the terminal:
- for the Wasm target (faster, modern browsers):
- on macOS/Linux
./gradlew :composeApp:wasmJsBrowserDevelopmentRun
- on Windows
.\gradlew.bat :composeApp:wasmJsBrowserDevelopmentRun
- on macOS/Linux
To build and run the development version of the iOS app, use the run configuration from the run widget in your IDE’s toolbar or open the /iosApp directory in Xcode and run it from there.
- Detailed Architecture Guide: Comprehensive guide on implementing Koin Annotations in KMP
- Koin Documentation: Dependency injection framework
- Koin Annotations: Compile-time DI with KSP
- Kotlin Multiplatform: Cross-platform development
- Compose Multiplatform: Declarative UI framework
- KSP (Kotlin Symbol Processing): Kotlin compiler plugin for code generation
This project is licensed under the MIT License - see the LICENSE file for details.
This is a sample project for educational purposes demonstrating Koin Annotations in Kotlin Multiplatform.