juniorClean Architecture
What is Dependency Inversion (DIP) in Clean Architecture?
Updated Apr 28, 2026
Short answer
High-level modules should not depend on low-level modules; both should depend on abstractions.
Deep explanation
DIP is the mechanism that allows us to follow the Dependency Rule. Since the Use Case (high-level) needs to save data (low-level DB), we place an Interface in the Use Case layer. The DB implementation then implements that interface, effectively 'inverting' the dependency.
Real-world example
A plugin system where the main app defines the 'Plugin' interface and external developers provide the actual code.
Common mistakes
- Confusing Dependency Inversion with Dependency Injection.
Follow-up questions
- What is Dependency Injection?