This repository contains examples and implementations of three popular software architecture patterns. Each pattern has its own directory with a complete implementation to demonstrate its principles and benefits.
Clean Architecture is a software design philosophy introduced by Robert C. Martin (Uncle Bob). It emphasizes separation of concerns and dependency rules to create maintainable and testable applications.
- Independent of frameworks
- Testable
- Independent of UI
- Independent of database
- Independent of any external agency
- Entities (Enterprise Business Rules)
- Use Cases (Application Business Rules)
- Interface Adapters
- Frameworks & Drivers
Hexagonal Architecture, also known as Ports and Adapters, was introduced by Alistair Cockburn. It focuses on creating a core application that is independent of external concerns.
- Core business logic is isolated
- External concerns are handled through ports and adapters
- Dependencies point inward
- Business rules are protected from external changes
- Core (Domain)
- Ports (Interfaces)
- Adapters (Implementations)
N-Layered Architecture is a traditional approach that organizes an application into distinct layers, each with specific responsibilities.
- Clear separation of concerns
- Each layer has specific responsibilities
- Dependencies flow from top to bottom
- Layers communicate through well-defined interfaces
- Presentation Layer
- Business Logic Layer
- Data Access Layer
- Domain Layer
Each architecture pattern has its own directory with a complete implementation. Navigate to the respective directories to explore the implementations:
clean-architecture/- Clean Architecture implementationhexagonal-architecture/- Hexagonal Architecture implementationn-layered/- N-Layered Architecture implementation
- Highly testable
- Framework independent
- Easy to maintain
- Clear separation of concerns
- Domain-centric
- Flexible and adaptable
- Easy to test
- Technology agnostic
- Simple to understand
- Clear responsibilities
- Easy to implement
- Good for smaller applications
- Large, complex applications
- Long-lived projects
- When framework independence is crucial
- When testability is a priority
- Domain-driven applications
- When external systems need to be easily swapped
- Microservices
- When core business logic needs to be protected
- Smaller applications
- When simplicity is preferred
- Traditional business applications
- When quick development is needed
Feel free to contribute to any of these architecture implementations by submitting pull requests or creating issues for improvements.
This project is open source and available under the MIT License.