https://github.com/jawherkl/clean-architecture
This repository exists to bridge the gap between theory and practice in software architecture.
https://github.com/jawherkl/clean-architecture
architecture clean-architecture component dip isp lsp ocp paradigms poo solid srp
Last synced: 4 months ago
JSON representation
This repository exists to bridge the gap between theory and practice in software architecture.
- Host: GitHub
- URL: https://github.com/jawherkl/clean-architecture
- Owner: JawherKl
- License: mit
- Created: 2024-11-05T20:30:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-09T15:26:24.000Z (11 months ago)
- Last Synced: 2025-07-09T16:42:13.406Z (11 months ago)
- Topics: architecture, clean-architecture, component, dip, isp, lsp, ocp, paradigms, poo, solid, srp
- Homepage: https://cleancoders.com/
- Size: 44.9 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Clean Architecture Template
A practical implementation of Clean Architecture principles inspired by Robert C. Martin's "Clean Architecture" book. This repository serves as both a reference implementation and a template for new projects.
## ๐ Table of Contents
- [Core Principles](#-core)
- [Repository Structure](#-repository-structure)
- [Getting Started](#-getting-started)
- [Testing Strategy](#-testing-strategy)
- [Documentation](#-documentation)
- [Case Studies](#-case-studies)
- [Contributing](#-contributing)
- [License](#-license)
## ๐ง Core Principles
This implementation follows the key tenets of Clean Architecture:
1. **Independent of Frameworks**: Core business logic doesn't depend on any external libraries
2. **Testable**: Business rules can be tested without UI, DB, or external services
3. **Independent of UI**: UI can change easily without changing business rules
4. **Independent of Database**: Business rules aren't bound to any specific database
5. **Independent of External Services**: Business rules don't know about external interfaces
## ๐ Repository Structure
```
clean-architecture/
โ
โโโ docs/ # Documentation
โ โโโ foreword.md # Foreword about the project
โ โโโ preface.md # Project introduction and goals
โ โโโ acknowledgments.md # Credits and acknowledgments
โ โโโ principles/ # Architectural principles
โ โ โโโ design/ # SOLID principles
โ โ โ โโโ srp.md # Single Responsibility Principle
โ โ โ โโโ ocp.md # Open/Closed Principle
โ โ โ โโโ lsp.md # Liskov Substitution Principle
โ โ โ โโโ isp.md # Interface Segregation Principle
โ โ โ โโโ dip.md # Dependency Inversion Principle
โ โ โโโ component/ # Component cohesion/coupling
โ โ โโโ architectural/
โ โโโ case-studies/ # Example implementations
โ
โโโ src/ # Source code
โ โโโ core/ # Enterprise business rules
โ โ โโโ entities/ # Business objects with critical business rules
โ โ โโโ usecases/ # Application-specific business rules
โ โ โโโ interfaces/ # Interfaces for outward communication
โ โ
โ โโโ infrastructure/ # Outer layer: frameworks, databases, UI
โ โ โโโ persistence/ # Database implementations
โ โ โโโ web/ # Web framework implementations
โ โ โโโ external-services/ # External service integrations
โ โ โโโ config/ # Configuration management
โ โ
โ โโโ application/ # Interface adapters
โ โ โโโ controllers/ # Web controllers
โ โ โโโ presenters/ # Presenters for response models
โ โ โโโ gateways/ # Gateways to external services
โ โ โโโ mappers/ # Data mappers between layers
โ โ
โ โโโ main/ # Composition root and entry point
โ โโโ di/ # Dependency injection configuration
โ โโโ config/ # Startup configuration
โ โโโ app.js|app.py|etc. # Application entry point
โ
โโโ tests/ # Test suites
โ โโโ unit/ # Unit tests
โ โ โโโ core/ # Tests for business rules
โ โ โโโ application/ # Tests for interface adapters
โ โโโ integration/ # Integration tests
โ โโโ e2e/ # End-to-end tests
โ โโโ test-api/ # Testing API utilities
โ
โโโ examples/ # Example implementations
โ โโโ video-sales/ # Case study: Video Sales
โ โโโ embedded/ # Clean Embedded Architecture example
โ โโโ services/ # Service architecture examples
โ
โโโ scripts/ # Utility scripts
โ โโโ deployment/ # Deployment scripts
โ โโโ code-generation/ # Code generation utilities
โ
โโโ .github/ # GitHub specific files
โ โโโ workflows/ # CI/CD workflows
โ โโโ ISSUE_TEMPLATE/ # Issue templates
โ
โโโ .gitignore
โโโ README.md # Main project documentation
โโโ LICENSE
โโโ Makefile|build.gradle|etc. # Build automation
```
### Key Layers:
1. **Core**: Enterprise business rules and entities
2. **Application**: Application-specific business rules and use cases
3. **Interface Adapters**: Controllers, presenters, and gateways
4. **Infrastructure**: Frameworks, databases, and external services
5. **Main**: Composition root and application entry point
## ๐ Getting Started
### Prerequisites
- Node.js/Python/Java (depending on your implementation)
- Docker (for containerized dependencies)
- Make (for build automation)
### Installation
```bash
git clone https://github.com/JawherKl/clean-architecture.git
cd clean-architecture
npm install # or pip install -r requirements.txt
```
### Running the Application
```bash
make run # or npm start / python main.py
```
## ๐งช Testing Strategy
We employ a multi-layered testing approach:
```bash
make test # Run all tests
make test-unit # Run unit tests only
make test-int # Run integration tests
make test-e2e # Run end-to-end tests
```
## ๐ Documentation
Explore our comprehensive documentation:
- [Design Principles](docs/principles/design)
- [Component Architecture](docs/principles/component)
- [Case Studies](docs/case-studies)
## ๐ Case Studies
Practical implementations included:
1. [Video Sales System](examples/video-sales) - Complete e-commerce example
2. [Embedded Systems](examples/embedded) - Clean Architecture in constrained environments
3. [Microservices](examples/services) - Service-oriented implementations
## ๐ค Contributing
We welcome contributions! Please follow these steps:
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## ๐ License
Distributed under the MIT License. See `LICENSE` for more information.
---
**Inspired by**: "Clean Architecture: A Craftsman's Guide to Software Structure and Design" by Robert C. Martin