How to implement Dependency Injection without a library?

Updated Apr 28, 2026

Short answer

Dependency Injection is achieved by passing dependencies through constructors, often orchestrated by a Main component.

Deep explanation

In Clean Architecture, we avoid coupling to DI frameworks within the business logic. We use 'Constructor Injection'. A 'Main' or 'Composition Root' is responsible for instantiating the database, passing it to the repository, passing the repository to the use case, and so on.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Clean Architecture interview questions

View all →