Skip to content
CAI
Software that uses CAICheck a score

kosi-libs/Kodein

58.0

Adequate · 28 September 2026

17.2k

lines of production code

Kotlin

primary language

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is the Kodein dependency injection library for Kotlin, providing a framework for managing object lifecycles and dependencies across multiple platforms. It offers core container management with compile-time validation via KSP, alongside specialized integrations for Android (including ViewModels and lifecycle scopes), Jetpack Compose, and Ktor server applications. The library supports multiplatform development with implementations for JVM, JS, and Native targets, and includes compatibility layers for standard Java injection annotations.

How it got here

2015–2018 — Android framework and JSR-330 integration

12 changes.

This period focused on modernizing the build infrastructure and introducing comprehensive support for Android development, including lifecycle-aware scopes and context-based resolution. It also expanded interoperability by adding a new JSR-330 (javax.inject) compatibility module and a KSP-based compile-time resolver to enhance type safety and stability.

2019–2020 — Ktor integration and core API restructuring

15 changes.

This period focused on expanding framework support with a new Ktor server integration featuring request and session scoping, alongside a major restructuring of the core DI library's binding and retrieval APIs. The work also included refactoring internal thread-safety mechanisms, deprecating the TornadoFX integration, and adding comprehensive test coverage for these new features and core changes.

2021–2025 — Compose and multiplatform integration

9 changes.

This period focused on expanding Kodein's support for Jetpack Compose and multiplatform targets, introducing new APIs for retrieving ViewModels and managing DI scopes within Compose trees. It also added DirectDI implementations for JavaScript and Native platforms, alongside a new KSP-based resolver for compile-time dependency validation.

Features

Add Android-specific ViewModel retrieval for Jetpack Compose

The \framework/compose/kodein-di-framework-compose\ module now includes \rememberViewModel\ functions for Android, allowing Compose UI code to retrieve Android \ViewModel\ instances directly from the Kodein DI container. This enables seamless integration of Kodein-managed dependencies with the standard Android \ViewModel\ lifecycle within Jetpack Compose applications.

framework/compose/kodein-di-framework-compose/src/androidMain · high confidence

Add Compose Multiplatform ViewModel support with rememberViewModel

The Compose Multiplatform integration now includes support for AndroidX ViewModels via the new \rememberViewModel\ composable function. This feature allows developers to retrieve ViewModel instances directly from the Kodein DI container within Compose trees, supporting both singleton-scoped ViewModels and those requiring constructor arguments. The implementation introduces \KodeinViewModelScopedFactory\ and \KodeinViewModelScopedSingleton\ to bridge Kodein's dependency resolution with the \ViewModelProvider.Factory\ interface, while deprecating the previous \KodeinViewModelScopedFactory\ and \KodeinViewModelScopedSingleton\ functions in favor of this new API.

framework/compose/kodein-di-framework-compose/src/commonMain · high confidence

Add ViewModel extension with SavedStateHandle support for AndroidX

The \kodein-di-framework-android-x-viewmodel-savedstate\ module now provides \viewModelWithSavedStateHandle()\ extension functions for \AppCompatActivity\ and \Fragment\. This allows developers to inject ViewModels that require a \SavedStateHandle\ argument directly from the Kodein DI container, enabling seamless integration of saved state management with dependency injection in Android components.

framework/android/kodein-di-framework-android-x-viewmodel-savedstate · high confidence

Added DirectDI implementations for JS and Native targets

The library now provides concrete implementations of the DirectDI interface for JavaScript and Native platforms. This includes the DirectDI interface definitions, internal implementation classes (DirectDIImpl), factory functions (createDirectDI), and platform-specific collection utilities (concurrent maps and linked lists) for both the jsBasedMain and nativeMain source sets, enabling direct dependency injection capabilities on these targets.

kodein-di/src/jsBasedMain, kodein-di/src/nativeMain · high confidence

Introduction of KSP-based compile-time DI resolver and Ktor 2.0 plugin support

This release introduces a new KSP-based compile-time resolver (DIResolverGenerator) that generates type-safe, checkable DI resolver implementations to validate binding consistency at compile time. It also adds a new Ktor 2.0 server plugin (DIPlugin) that installs a global DI container accessible via Application.di, and updates the core DI framework to use kotlinx.atomicfu for synchronization, swap to the TypeToken from Kodein-Type for better multiplatform support, and deprecate ScopeCloseable in favor of Kotlin's standard AutoCloseable.

test-utils · high confidence

New Android DI API with closestDI and retained scopes

The Android core module introduces a new dependency injection API centered around the \closestDI()\ property delegate, which automatically resolves the nearest available DI container by walking up the Android context hierarchy (supporting Context, Activity, Fragment, View, Dialog, and other Android components). It also adds \retainedDI()\ for creating DI instances that survive activity configuration changes via a retained Fragment, and \subDI()\ / \retainedSubDI()\ for creating child DI containers. The module provides \androidCoreModule\ which binds numerous Android system services (like AudioManager, WifiManager, etc.) and context resources (assets, resources, shared preferences) as providers, along with \androidCoreContextTranslators\ to enable context-based resolution for Fragments, Views, and other Android types.

framework/android/kodein-di-framework-android-core · high confidence

New AndroidX Support module with lifecycle-aware scopes and closestDI helpers

The android-support framework module has been migrated to AndroidX, introducing new capabilities for dependency injection in Android components. It provides \closestDI()\ extension functions for Fragment, Loader, and AndroidViewModel to easily access the nearest dependency injection context. Additionally, it includes \androidSupportContextTranslators\ and \androidSupportModule\ to handle context translation for these components, and implements \AndroidLifecycleScope\ which automatically manages scope registries tied to LifecycleOwner destruction, ensuring resources are cleaned up when components are destroyed.

framework/android/kodein-di-framework-android-support · high confidence

New Compose DI integration APIs and CompositionLocal support

The Compose runtime module now provides a suite of new APIs for integrating Kodein DI with Jetpack Compose. Users can attach DI containers to the Composable tree using \withDI\ and create scoped child containers with \subDI\. Retrieval of dependencies is handled via \rememberDI\, \rememberInstance\, \rememberNamedInstance\, \rememberFactory\, and \rememberProvider\, which leverage a new \LocalDI\ CompositionLocal to access the current container. On Android, \androidContextDI\ allows accessing the DI container attached to the Android Context, while other platforms default to throwing an error if no container is provided.

framework/compose/kodein-di-framework-compose-runtime · high confidence

New ConfigurableDI and global DI configuration API

Introduces the \ConfigurableDI\ class in the \kodein-di-conf\ module, allowing users to build a DI container by adding configuration lambdas, imports, and extensions before the first dependency retrieval. It supports mutable reconfiguration via \clear()\ and chaining on configuration methods. Additionally, a \global\ singleton property is exposed on \DI.Companion\ for a single shared instance, along with a \DIGlobalAware\ interface to access it.

kodein-di-conf/src/commonMain · high confidence

New KSP-based DI resolver module for compile-time dependency validation

This change introduces a new KSP (Kotlin Symbol Processing) module that allows users to define DI resolver interfaces annotated with @Resolved. The processor generates code that creates type-safe accessors for dependencies and provides a check() method to validate that all required bindings exist in the DI container at compile time, reducing runtime errors. The module includes the DIResolver interface, @Resolved and @Tag annotations, the KSP processor implementation, and test cases demonstrating usage with nested resolver interfaces.

compiler/kodein-resolver-api, compiler/kodein-resolver-processor, compiler/kodein-resolver-test · high confidence

New Ktor integration with request/session scoping and sub-containers

This release introduces the Ktor server integration module, providing \closestDI()\ extension functions on \Application\, \ApplicationCall\, \Routing\, and \Route\ to access the DI container. It adds \CallScope\ for request-scoped dependencies and \SessionScope\ (with \KodeinDISession\ interface) for session-scoped singletons, including a \clearSessionScope()\ helper. Additionally, \Route.subDI()\ allows creating sub-containers with optional silent overrides.

framework/ktor/kodein-di-framework-ktor-server-jvm/src/main · high confidence

New javax.inject compatibility module for Kodein DI

The \kodein-di-jxinject-jvm\ module introduces a new integration layer that allows Kodein DI to work with classes annotated using the standard \javax.inject.\*\ annotations (such as \@Inject\). This includes a \JxInjector\ class for performing field and method injection on existing objects, as well as a \jxInjectorModule\ that registers the necessary bindings. The module also provides custom annotations (\@ErasedBinding\, \@ProviderFun\, \@FactoryFun\, \@OrNull\) to handle specific injection scenarios and utility functions to easily retrieve the injector from a \DI\ or \DirectDI\ instance.

kodein-di-jxinject-jvm/src/main/kotlin/org/kodein/di/jxinject · high confidence

Plain ViewModel extensions for AppCompatActivity and Fragment

The \kodein-di-framework-android-x-viewmodel\ module now provides plain \viewModel()\ extension functions for \AppCompatActivity\ and \Fragment\ classes that implement \DIAware\. These extensions allow developers to access ViewModels directly via property delegation (e.g., \private val model: MyViewModel by viewModel()\) by resolving them from the Kodein DI container, supporting optional tags and custom owner producers for fragments.

framework/android/kodein-di-framework-android-x-viewmodel · high confidence

Project initialization with IDE configuration and documentation scaffolding

The repository has been initialized with standard project scaffolding, including an EditorConfig file to enforce consistent Kotlin code formatting (4-space indentation, 100-character line limit) across IDEs, and an AGENTS.md file documenting the core architecture, binding system, and framework integration patterns for the Kodein-DI dependency injection library. The README has been updated to reflect the current KODEIN SAS copyright, Kotlin Multiplatform support, and modern installation instructions, while the CHANGELOG.md has been created to track version history starting from 7.33.0. Additionally, the .gitignore has been expanded to include Kotlin-specific build artifacts and the Gradle wrapper scripts have been updated to the latest POSIX-compliant versions.

(repo-wide) · high confidence

Removals

Removal of legacy Kodein core implementation files

The core Kodein dependency injection implementation files (Kodein.kt, Scopes.kt, and lazy.kt) have been removed from the src/main directory. This deletion eliminates the previous implementation of the Kodein IoC container, including its Key-based binding mechanism, singleton/thread-singleton/instance scopes, and property delegation helpers (lazyInstance, injectInstance). Users relying on these specific legacy APIs for dependency injection will no longer have access to them in this location.

src/main · high confidence

Behavioural changes

JVM-specific dependency injection extensions and reference types

The JVM module now includes platform-specific implementations for retrieving all factories, providers, and instances via \DIAware\ and \DirectDI\, utilizing \TypeToken\ from the \kodein-type\ library for generic type resolution. Additionally, new \RefMaker\ objects (\threadLocal\, \softReference\, and \weakReference\) are provided to support thread-local, soft, and weak reference binding strategies for singletons and multitons, while \TypeBinderSubTypes\ gains a \with\ function to bind handlers for any subtype of a given type.

kodein-di/src/jvmMain/kotlin/org/kodein/di · high confidence

JVM-specific dependency injection implementation and collection utilities

The library now includes platform-specific implementations for the JVM target, introducing a new DirectDI implementation that leverages the TypeToken from Kodein-Type to resolve factories, providers, and instances. Additionally, JVM-specific collection utilities have been added to use Java's ConcurrentHashMap and LinkedList for internal data structures, ensuring optimal performance and compatibility on the JVM platform.

kodein-di/src/jvmMain/kotlin/org/kodein/di/internal · high confidence

Jetpack Compose ViewModel integration refactored for Android

The \kodein-di-framework-android-x-compose\ module has been restructured to focus exclusively on Android Jetpack Compose, introducing new \rememberViewModel\ and \rememberNavGraphViewModel\ composables that return \ViewModelLazy\ instances for better lifecycle management. The previous \viewModel\ and \navGraphViewModel\ functions are now deprecated in favor of these new APIs, and the underlying factory classes (\KodeinViewModelScopedFactory\ and \KodeinViewModelScopedSingleton\) have been updated to use generic types for improved type safety.

framework/compose/kodein-di-framework-android-x-compose · high confidence

Kodein DI core library restructured with new binding and retrieval APIs

The Kodein DI core module has been reorganized into a new package structure, introducing dedicated files for binding definitions (BindingsMap, DIBuilder), container management (DIContainer, DITree), and instance retrieval (DirectDI, Named, New, ParameterizedNew, Retrieving). This change introduces a new \DirectDI\ interface for non-delegate-based injection, adds a \Named\ extension for property-name-based tagging, and provides new \new()\ overloads for constructor-based dependency resolution with parameterized arguments. The internal binding tree and map structures have been refactored to support these new retrieval patterns and improved debugging capabilities.

kodein-di/src/commonMain/kotlin/org/kodein/di · high confidence

New DIController API for Ktor routing installation

The Ktor server controller module introduces a new \DIController\ interface and \AbstractDIController\ base class, replacing the previous \KodeinControllerFeature\ approach. This change allows developers to define controllers that implement \getRoutes()\ and install them directly into Ktor's \Routing\ or specific \Route\ instances using new extension functions (\Route.controller\). This provides a more flexible, MVC-like architecture where controllers can be installed into existing routing structures rather than requiring a dedicated feature installation.

framework/ktor/kodein-di-framework-ktor-server-controller-jvm/src/main · high confidence

Refactored binding interfaces to expose context and overridden factories

The core binding interfaces in the DI module have been restructured to improve how factory methods interact with retrieval context and binding overrides. The new \BindingDI\ and \NoArgBindingDI\ interfaces now explicitly extend \WithContext\, allowing factory providers to access the current retrieval context. Additionally, these interfaces provide methods like \overriddenFactory\, \overriddenProvider\, and \overriddenInstance\ (along with their nullable variants), enabling bindings that override existing ones to delegate to the previous implementation. The \DIBinding\ interface has been updated to include metadata properties such as \scope\, \contextType\, \argType\, and \createdType\, which are used for debugging descriptions and binding copying. A new \ExternalSource\ interface allows providing fallback factories for unregistered keys, and helper functions for type-safe instance retrieval from overridden bindings have been added.

kodein-di/src/commonMain/kotlin/org/kodein/di/bindings · high confidence

Replaced synchronization with kotlinx-atomicfu and added delayed initialization support

The internal dependency injection container now uses kotlinx-atomicfu for thread-safety instead of standard Kotlin synchronization, which addresses performance concerns on native platforms. Additionally, a new \withDelayedCallbacks\ API allows DI containers to be constructed without immediately running initialization callbacks, enabling deferred initialization to prevent potential freezes during startup.

kodein-di/src/commonMain/kotlin/org/kodein/di/internal · high confidence

TornadoFX integration deprecated and API renamed to DI

The TornadoFX framework integration is now deprecated with a recommendation to migrate to Compose. The public API has been renamed from \\Kodein\\ to \\DI\\ (e.g., \kodeinDI\ to \kodeinDI\ but conceptually part of the new \DI\ naming scheme, and \closestKodein\ aliases updated), and all extension functions for \Component\, \Node\, and \DI.MainBuilder\ are marked as deprecated. This includes changes to how the DI container is retrieved and installed, such as the new \closestKodeinDI\ alias and \installTornadoSource\ method, while maintaining backward compatibility through deprecation warnings.

framework/tornadofx/kodein-di-framework-tornadofx-jvm/src/main · high confidence

Fixes

Improved stability of JSR-330 injection on Android

The JSR-330 injection mechanism now gracefully handles missing runtime types during class introspection. Previously, if a class referenced a type absent on the device (common on Android with SDK version mismatches), the injection process would fail with a \NoClassDefFoundError\. The updated code catches these linkage errors, logs a warning, and continues processing, ensuring that applications remain stable even when some injected members cannot be resolved due to missing platform classes.

kodein-di-jxinject-jvm/src/main/kotlin/org/kodein/di/jxinject/internal · high confidence

Test coverage

Added JVM injection tests for JSR-330 compatibility and reflection resilience; Added JVM-specific tests for ConfigurableDI generic overrides and external sources; Added comprehensive test coverage for the new direct binding API; Added disabled Compose Multiplatform integration tests; Added integration tests for Ktor server DI features; Added integration tests for TornadoFX Kodein DI framework; Added test helper for AutoCloseable validation; Added tests for ConfigurableDI configuration and lifecycle; JVM-specific dependency injection tests for erased and generic type handling; Removal of legacy Kotlin test suite.

Dependencies

Gradle wrapper upgraded to version 9.3.1

The Gradle wrapper has been updated from version 2.2 to 9.3.1. This upgrade brings the build system to a significantly newer version of Gradle, which may affect build performance, plugin compatibility, and build script syntax. Users should ensure their local Gradle installations and CI/CD pipelines are compatible with Gradle 9.3.1 or rely on the wrapper to manage the version automatically.

gradle · high confidence

Migrate build system to Gradle Kotlin DSL and Kosi-libs infrastructure

The project has replaced the legacy Groovy-based build scripts (build.gradle, settings.gradle) with a modern Gradle Kotlin DSL configuration. This migration introduces the Kosi-libs internal Gradle plugin (v9.2.0) to manage multiplatform targets, namespaces, and publishing. The build now utilizes a version catalog (libs.versions.toml) to define dependencies, including KSP 2.3.10, Ktor 3.5.1, Compose Multiplatform 1.11.1, and AndroidX libraries. Additionally, the root project version is set to 7.33.0, and the module structure is reorganized to include core DI, Android frameworks, Ktor integration, and Compose extensions.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 58 → 58 (+0.0)
  • Rubric changed (rubric-2026.09.8 → rubric-2026.09.16) — scores are not directly comparable.

Lenses

  • Code Health 98 → 98 (+0.0)
  • Architecture 100 → 98 (-1.6)
  • Maturity 49 → 49 (-0.0)
  • Readiness 57 → 52 (-4.8)
  • Security 56 → 65 (+8.8)

Resolved (72)

  • Documentation: contradicts the code (modules/migration/pages/migration-j2k.adoc)
  • Documentation: no installation or build instructions
  • Documentation: no usage examples
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • High CVE: [CVE redacted] (kotlin-js-store/yarn.lock)
  • …and 52 more

New (4)

  • High vulnerability: [GHSA redacted] (kotlin-js-store/yarn.lock)
  • Off the main sequence: :framework:android:kodein-di-framework-android-x
  • Off-boarding risk: anonymized user #1
  • Projects may be oversized for their cohesion

Architecture

  • Containers 0 added · 0 removed · contexts 3 added · 1 removed · edges 1 added · 0 removed

Added bounded contexts (3)

  • kodein-di
  • kodein-di-framework-ktor-server-jvm
  • kodein-resolver-processor

Removed bounded contexts (1)

  • test-utils

Added dependency edges (1)

  • kodein-di-framework-ktor-server-jvm → kodein-di

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

kosi-libs/Kodein was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 28 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 4c2a4813e0077017d0bde371649141bd1e420a96 — the exact code this score is about.
  • Scored under rubric-2026.09.16 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-2d9048c36d26.