kotlin-context-di
STARTER_CHARACTER = 🔌
Manual Dependency Injection with AppDependencies, SystemContext and TestContext
Structure Kotlin applications using manual DI with an interface-first contract (AppDependencies), a production context (SystemContext), and a standalone test context (SystemTestContext). This approach provides type-safe dependency management, full control over initialization, and excellent testability without framework overhead.
Core Pattern: AppDependencies Interface
Define an interface as the contract for all application dependencies. Use nested interfaces to group related components:
interface AppDependencies {
interface Repositories {
val customerRepo: CustomerRepository
val orderRepo: OrderRepository
}
More from anderssv/the-example
kotlin-tdd
Kotlin Test-Driven Development with fakes, object mothers, and Testing Through The Domain. Uses TestContext for dependency injection, extension functions for test data, and fakes instead of mocks. Use when writing Kotlin tests or setting up test infrastructure.
23kotlin-sum-types
Parse, don't validate - using sealed classes for type-safe validation and state representation. Model valid/invalid states explicitly, validate at boundaries, operate on valid types internally.
13