Skip to content

Genocs/clean-architecture-template

Repository files navigation

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

Hexagonal 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 and event-driven workflows via Genocs.Common.CQRS
  • 🚌 Message Brokers - Azure Service Bus, MassTransit, NServiceBus, and Rebus options
  • 🗃️ Multiple Databases - MongoDB, EF Core (SQL Server), and InMemory options
  • 🔍 Telemetry and Logging - Built-in telemetry/logging integration with monitoring stack assets
  • 🐳 Containerization - Docker and Kubernetes ready
  • ☁️ Infrastructure as Code - Bicep, Terraform, Helm, and Kubernetes manifests included
  • Background Services - Worker services for async processing
  • 🧪 Comprehensive Testing - Unit, Integration, and Acceptance tests
  • 📘 API Versioning and OpenAPI - Versioned endpoints and OpenAPI support out of the box

📋 Table of Contents

📋 Prerequisites

  • .NET 10 SDK
  • IDE (choose one):
  • Optional for local infrastructure (depends on selected template options):
    • Docker Desktop
    • MongoDB for --database mongodb
    • SQL Server for --database sqlserver (default)
    • RabbitMQ for --service-bus masstransit|rebus|nservicebus
    • Azure Service Bus namespace for --service-bus azureservicebus

🚀 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.1.0

# View all available options
dotnet new gnx-cleanarchitecture --help

# Create a project using template defaults
dotnet new gnx-cleanarchitecture --name "CompanyName.ServiceName"

# Create a project with explicit options
dotnet new gnx-cleanarchitecture \
  --name "CompanyName.ServiceName" \
  --database inmemory \
  --service-bus nservicebus \
  --use-cases basic

🏗️ Architecture Overview

The template generates a solution with the following structure:

src/
├── AcceptanceTests/ # Acceptance Tests
├── Application/ # Use cases and application services
├── Contracts/ # API and message contracts (commands, events, messages)
├── Contracts.NServiceBus/ # Included when --service-bus nservicebus is selected
├── 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
└── ...

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.1.0 --configuration Release --output ./out

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

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

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

# Example of creating a new project with InMemory database and Masstransit as service bus
dotnet new gnx-cleanarchitecture --name CompanyName.ServiceName --database inmemory --service-bus masstransit

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.

Contributing

Contributions are welcome. See CONTRIBUTING.md for guidelines and development workflow.

Changelog

View complete Changelog.

License

This project is licensed with the MIT license.

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

⚙️ Template Options

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

About

The Clean Architecture Template built on top of .NET 10

Topics

Resources

License

Code of conduct

Contributing

Stars

108 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors