Skip to content

The Clean Architecture Template built on top of .NET 10

License

Notifications You must be signed in to change notification settings

Genocs/clean-architecture-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

197 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

License Build Packages Downloads Prev Downloads Contributors Forks Stargazers Issues Discord Gitter Twitter Twitterx LinkedIn

Exagonal Architecture

Genocs Clean Architecture Template

A comprehensive .NET 10 project template that follows Clean Architecture principles and Domain-Driven Design (DDD). This template helps you rapidly scaffold microservices applications with built-in support for multiple databases, message brokers, and enterprise patterns.

✨ Features

  • πŸ—οΈ Clean Architecture - Domain, Application, Infrastructure, and Presentation layers
  • 🎯 Domain-Driven Design - Rich domain models with proper separation of concerns
  • πŸ“¨ CQRS Pattern - Command Query Responsibility Segregation with MediatR
  • 🚌 Message Brokers - Support for RabbitMQ, Azure Service Bus, and more
  • πŸ—ƒοΈ Multiple Databases - SQL Server, MongoDB, Redis integration
  • πŸ” Observability - OpenTelemetry tracing and monitoring
  • 🐳 Containerization - Docker and Kubernetes ready
  • ⚑ Background Services - Worker services for async processing
  • πŸ§ͺ Comprehensive Testing - Unit, Integration, and Acceptance tests

πŸ“‹ Table of Contents

πŸ“‹ Prerequisites

πŸš€ Quick Start

Install the Template

# Install the latest version
dotnet new install Genocs.CleanArchitecture.Template

# Or install a specific version
dotnet new install Genocs.CleanArchitecture.Template::5.0.0

# View all available options
dotnet new cleanarchitecture --help

# Example with custom options
dotnet new cleanarchitecture \
  --name "CompanyName.ServiceName" \
  --database inmemory \
  --service-bus rebus \
  --use-cases full

πŸ—οΈ Architecture Overview

The template generates a solution with the following structure:

src/
β”œβ”€β”€ AcceptanceTests/ # Acceptance Tests
β”œβ”€β”€ Application/ # Use cases and application services
β”œβ”€β”€ Contracts/ # API and ServiceBus contracts and commansd, events and messages
β”œβ”€β”€ Contracts.NServiceBus/ # API and ServiceBus contracts and commansd, events and messages, used by NServiceBus
β”œβ”€β”€ Domain/ # Core business logic and entities
β”œβ”€β”€ Infrastructure/ # Data access and external services
β”œβ”€β”€ IntegrationTests/ # Integration Tests
β”œβ”€β”€ UnitTests/ # Unit Tests
β”œβ”€β”€ WebApi/ # REST API controllers and middleware
β”œβ”€β”€ Worker/ # Background services and message handlers
└── Contracts/ # API contracts and events

Key Components

  • Domain Layer: Entities, value objects, domain services
  • Application Layer: CQRS handlers, interfaces, DTOs
  • Infrastructure Layer: Repositories, message brokers, databases
  • Presentation Layer: Controllers, middleware, API documentation

How to build and install the template locally

To build the package run the following commands:

# To clone the repository
git clone https://github.com/Genocs/clean-architecture-template
cd clean-architecture-template

# To pack and install the template
dotnet pack ./src/Package.Template.csproj -p:PackageVersion=5.0.0 --configuration Release --output ./out

dotnet new install ./out/Genocs.CleanArchitecture.Template.5.0.0.nupkg

# To verify the installation and see available options
dotnet new cleanarchitecture --help

# To uninstall the template
dotnet new uninstall Genocs.CleanArchitecture.Template

# Example of creating a new project with InMemory database and Rebus as service bus
dotnet new cleanarchitecture --name {CompanyName.ServiceName} -da inmemory -sb rebus

Official Documentation:

Miscellaneous

Useful commands:

# How to get the list of installed templates
dotnet new -u

# How to get the list of templates
dotnet new list

πŸ’¬ Community & Support

Get Help

Stay Connected

Show Your Support

  • ⭐ Star this repository
  • πŸ”„ Share with your team

buy-me-a-coffee

πŸ”§ Troubleshooting

Common Issues

For more details on getting started, read the documentation

Please check the documentation for more details.

Changelogs

View Complete Changelogs.

License

This project is licensed with the MIT license.

Community

Code Contributors

This project exists thanks to all the people who contribute. Submit your PR and join the team!

genocs contributors

Financial Contributors

Become a financial contributor and help me sustain the project.

Support the Project on Opencollective

Opencollective

Acknowledgements

βš™οΈ Template Options

Option Description Values Default
--name Project name {Company.Project.Service} Required
--database Database provider inmemory, sqlserver, mongodb inmemory
--servicebus Message broker particular, masstransit, rebus masstransit
--use-cases Use case complexity basic, full, readonly basic

About

The Clean Architecture Template built on top of .NET 10

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors