Frameworks and Drivers Layer
What You'll Learn
You'll learn how Clean Architecture keeps external dependencies like databases, web frameworks, and third-party tools as replaceable plugins at the outermost layer.
The Outermost Layer
The Frameworks and Drivers Layer is the most external circle in Clean Architecture. This is where all the "details" live—the things that can change without affecting your core business logic.
Think of this layer like the ports on your laptop. Your laptop's core functionality doesn't care whether you plug in a USB mouse, a Bluetooth mouse, or a touchpad. The mouse is an external detail that can be swapped out.
What Lives Here
This layer contains:
- Web frameworks (Express, Flask, Spring MVC)
- Database systems (PostgreSQL, MongoDB, Redis)
- UI frameworks (React, Vue, Angular)
- External APIs and third-party libraries
- Device drivers and hardware interfaces
- Configuration files and environment variables
These are all plugins to your application. They plug into the Interface Adapters you built in the previous layer but never dictate your business rules.
Why Keep Them Outside
By treating these as external concerns:
- You can swap databases without rewriting business logic
- Framework migrations become less painful
- Testing becomes easier because you're not bound to infrastructure
- Technology decisions can be deferred until you have more information
The Dependency Rule means code in this layer depends on everything inward, but nothing inside depends on these external tools. Your use cases don't know if they're talking to PostgreSQL or MongoDB—they just know they're talking to a repository interface.
Key Takeaway: The Frameworks and Drivers Layer treats all infrastructure, frameworks, and external tools as replaceable plugins at the system's outer edge, protecting your core business logic from technological change.