What problem does it solve?
Separates business logic from external systems so applications remain testable, maintainable, and agnostic to database, network, and framework changes.
Core Features & Use Cases
- Ports and Adapters: Define primary (driving) and secondary (driven) ports in the application core and implement adapters in infrastructure.
- Testability: Swap real adapters for mocks to run unit tests without external systems and use console or in-memory adapters for integration tests.
- Composition Root & DI: Wire concrete adapters to ports at the composition root to enable one-line adapter swaps (e.g., Postgres → Mongo, SendGrid → SES).
- Use Case Example: Implement RegisterUserUseCase in the core with IUserRepository and IEmailService ports, provide Postgres and SendGrid adapters for production, and inject mock adapters in tests.
Quick Start
Define interfaces for required ports in the application core, implement adapters for your external systems, and wire them together at the composition root so you can run use cases with mock adapters for tests.