Genocs.CleanArchitecture.Template 5.0.0

dotnet new install Genocs.CleanArchitecture.Template::5.0.0
                    
This package contains a .NET Template Package you can call from the shell/command line.

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

๐Ÿ”ง Development Workflow

Local Development

# Start infrastructure services
docker-compose -f ./infrastructure/docker/docker-compose-infrastructure.yml up -d

# Run the API
dotnet run --project src/WebApi/Host.csproj

# Run the Worker
dotnet run --project src/Worker/Host.csproj

# Run all tests
dotnet test

# Run specific test projects
dotnet test src/UnitTests
dotnet test src/IntegrationTests
dotnet test src/AcceptanceTests

# Stop infrastructure services
docker-compose -f ./infrastructure/docker/docker-compose-infrastructure.yml down


# Build Docker WebApi image
docker build -t genocs/clean-architecture-template -f ./src/WebApi/Dockerfile .

# Run Docker WebApi container
docker run -d -p 8080:80 --name clean-architecture-template genocs/clean-architecture-template

# Stop and remove Docker WebApi container
docker stop clean-architecture-template
docker rm clean-architecture-template

๐Ÿ’ฌ 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

Financial Contributors

Become a financial contributor and help me sustain the project.

Support the Project on Opencollective

<a href="https://opencollective.com/genocs"><img src="https://opencollective.com/genocs/individuals.svg?width=890"></a>

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

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.0 209 1/25/2026
4.0.1 5,097 10/22/2025
4.0.0 349 10/16/2025
3.1.0 26,187 5/11/2024
3.0.0 4,205 4/14/2024

Release notes:
- Release 5.0.0:
 - Updated to .NET 10
 - Improved Docker support
 - Added new templates for CQRS and Event Sourcing