
Complex JVM systems rarely become painful because “dependency injection exists.” They become painful because dependency wiring becomes invisible, magical, or scattered everywhere. Services instantiate repositories directly. Routes know too much. Tests need half the application running. A simple change in billing, pricing, or customer policy triggers a chain reaction through controllers, adapters, and infrastructure code. At that point, DI is no longer helping the architecture; it has become another layer of fog. For Staff Engineers working with Java and Kotlin, the problem to solve is not “which DI tool is coolest?” It is: how do we make dependencies explicit enough to evolve the system safely?
Kotlin allows us to be pragmatic. With Ktor and Koin, dependency injection can stay close to the application without swallowing the design. Koin’s Ktor integration supports module-based organization, scoped dependencies, annotation-based components, and compiler-plugin verification, while keeping the setup readable and lightweight. The key lesson is this: DI should protect the domain from infrastructure, not spread infrastructure concerns everywhere. Your use cases should depend on interfaces. Your adapters should bind concrete implementations. Your Ktor routes should be thin delivery mechanisms, not service locators wearing HTTP clothes.
As a Staff Engineer, turn this into a team practice. Start by defining clear DI boundaries: the domain has no Koin imports; the application exposes use cases; the infrastructure provides repositories, clients, gateways, and config; and delivery/ktor installs Koin and wires modules. Create one module per business capability: orderModule, paymentModule, customerModule, not one giant “appModule monster” from the ninth circle of enterprise YAML. Use single for stateless services, factory for short-lived collaborators, and request scope only when the lifecycle really belongs to the request. Add compiler verification or module checks in CI, so broken wiring fails before production. In tests, override modules with fakes and contract-test adapters independently from the core.
The strategic payoff is huge. Pragmatic DI reduces coupling, makes architecture visible, and keeps feature work from turning into dependency archaeology. Onboarding improves because new engineers can see where things are created, what depends on what, and where to safely replace behavior. Refactoring becomes less scary because the domain is no longer glued to Ktor, databases, or external APIs. Maintenance cost drops because tests run faster and fewer changes require full-stack surgery. Great DI is boring in the best possible way: explicit, modular, testable, and aligned with the system’s business capabilities. That is the Staff Engineer move, not adding ceremony, but creating seams where evolution can happen.