CleanArch.msavarian 2.0.1

dotnet new install CleanArch.msavarian::2.0.1
                    
This package contains a .NET Template Package you can call from the shell/command line.

Clean Architecture Solution Template

Clean Architecture .NET GitHub

The "Clean Architecture Solution" template provides a complete structure for implementing Clean Architecture in .NET 9 projects. This template is designed for developing microservices with a focus on clean architecture principles.

Installation

To install the template from NuGet.org:

dotnet new install CleanArch.msavarian

How to Use

After installation, you can create a new project using the following command:

dotnet new ca-service -n MyProject

Parameters

The template supports the following parameters:

Parameter Description Allowed Values Default
-n, --name Project name Any valid name -
--dbType Database type sqlserver, postgresql, sqlite sqlserver
--authType Authentication type none, jwt, identity none
--enableSwagger Enable Swagger true, false true
--includeTests Include test projects true, false true

Examples

Project with default settings:

dotnet new ca-service -n MyService

Project with PostgreSQL and JWT:

dotnet new ca-service -n MyService --dbType postgresql --authType jwt

Project without tests and Swagger:

dotnet new ca-service -n MyService --includeTests false --enableSwagger false

Project Structure

The template creates a standard folder structure based on clean architecture principles:

MyService/
├── src/
│   ├── 00.Framework/
│   │   └── MyService.Framework
│   ├── 01.Core/
│   │   └── MyService.Domain
│   ├── 02.Application/
│   │   └── MyService.Application
│   ├── 03.Infrastructure/
│   │   ├── MyService.Infrastructure.Validators
│   │   ├── MyService.Persistence.Repositories
│   │   └── MyService.Persistence.SqlServer (or PostgreSQL/SQLite)
│   └── 04.Presentation/
│       └── MyService.Presentation.Api
└── tests/
    ├── 01.UnitTests/
    │   └── MyService.Domain.UnitTests
    ├── 02.IntegrationTests/
    │   └── MyService.Application.IntegrationTests
    └── 04.AcceptanceTests/
        └── MyService.Api.PlaywrightTests

Note on Solution Folders

If the solution folders are not created correctly after project generation, you can manually run the restoration script:

.\restore-solution-folders.ps1

This script is located in the root directory of your generated solution.

Technologies and Features

  • .NET 9: Core development platform
  • ASP.NET Core 9: For API development
  • CQRS with MediatR: Command Query Responsibility Segregation pattern
  • Entity Framework Core: For data access
  • FluentValidation: For data validation
  • Swagger / OpenAPI: For API documentation
  • xUnit, Moq, FluentAssertions: For testing
  • Playwright: For automated tests
  • Docker & Docker Compose: For containerization
  • JWT / ASP.NET Identity: For authentication (if selected)

Additional Notes

  • The template automatically creates Solution Folders in Visual Studio
  • Includes Docker configuration for quick setup
  • Supports CI/CD with GitHub Actions

Improvement Suggestions for template.json

  1. Add suppressPrompt: Add "suppressPrompt": true in the postActions section to prevent prompting when running post-processing scripts.

  2. Fix paths in modifiers: If you're using the authType and enableSwagger parameters, make sure to properly configure the modifier paths:

    "modifiers": [
      {
        "condition": "(!enableSwagger)",
        "exclude": ["src/*/Presentation.Api/Extensions/SwaggerExtensions.cs"]
      },
      {
        "condition": "(authType == 'none')",
        "exclude": ["src/*/Infrastructure/Auth/**/*"]
      }
    ]
    

Contribution and Support

This template was developed by Mahmoud Savarian. To report issues or request new features, please create an issue in the GitHub repository.

License

This project is released under the MIT license.


We hope this template enables you to start your projects faster and more standardized.

  • net9.0

    • 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
2.0.1 73 5/9/2025
2.0.0 68 5/9/2025

v1.0.1:
     - Initial release with core Clean Architecture structure
     - Support for .NET 9
     - Docker and Docker Compose integration
     - Full MediatR CQRS implementation
     - Entity Framework Core with SQL Server