Convert Figma logo to code with AI

jasontaylordev logoCleanArchitecture

Clean Architecture Solution Template for ASP.NET Core

19,643
4,140
19,643
51

Top Related Projects

Clean Architecture Template for Blazor WebAssembly Built with MudBlazor Components.

Web Application ASP.NET 9 using Clean Architecture, DDD, CQRS, Event Sourcing and a lot of good practices

Full-stack .Net 10 Clean Architecture (Microservices, Modular Monolith, Monolith), Blazor, Angular 21, React 19, Vue 3.5, BFF with YARP, NextJs 16, Domain-Driven Design, CQRS, SOLID, Asp.Net Core Identity Custom Storage, OpenID Connect, EF Core, OpenTelemetry, SignalR, Background Services, Health Checks, Rate Limiting, Clouds (Azure, AWS, GCP), ...

Quick Overview

The jasontaylordev/CleanArchitecture repository is a template for building applications with the Clean Architecture pattern. It provides a well-structured and scalable foundation for developing .NET Core applications, focusing on separation of concerns, testability, and maintainability.

Pros

  • Clean Architecture: The project follows the Clean Architecture principles, which promote a clear separation of concerns and a modular design, making the codebase more maintainable and testable.
  • Comprehensive Documentation: The repository includes detailed documentation, covering topics such as project structure, testing, and deployment, making it easier for developers to understand and get started with the project.
  • Extensive Test Coverage: The project includes a comprehensive suite of unit and integration tests, ensuring the codebase is well-tested and reducing the risk of regressions.
  • Flexible and Extensible: The project's modular design allows for easy customization and extension, making it suitable for a wide range of .NET Core applications.

Cons

  • Complexity: The Clean Architecture pattern and the project's comprehensive structure may be overwhelming for developers new to the concept, requiring a steeper learning curve.
  • Overhead: Implementing the Clean Architecture pattern can introduce additional complexity and boilerplate code, which may not be necessary for smaller or less complex projects.
  • Opinionated: The project follows a specific set of conventions and best practices, which may not align with the preferences of all developers or teams.
  • Limited Support for Newer .NET Features: The project is primarily focused on .NET Core and may not fully leverage the latest features and improvements in newer .NET versions.

Code Examples

N/A (This is not a code library)

Getting Started

N/A (This is not a code library)

Competitor Comparisons

Clean Architecture Template for Blazor WebAssembly Built with MudBlazor Components.

Pros of Blazor Starter Kit

  • Focuses specifically on Blazor, providing a tailored solution for Blazor developers
  • Includes more comprehensive features like multi-tenancy and localization out of the box
  • Offers a modular architecture with clear separation of concerns

Cons of Blazor Starter Kit

  • Less established and mature compared to Clean Architecture
  • May have a steeper learning curve due to its more complex feature set
  • Limited to Blazor development, whereas Clean Architecture is more versatile

Code Comparison

Clean Architecture:

public class CreateTodoItemCommand : IRequest<int>
{
    public int ListId { get; set; }
    public string Title { get; set; }
}

Blazor Starter Kit:

public class CreateProductRequest : IRequest<Result<Guid>>
{
    public string Name { get; set; }
    public string Description { get; set; }
    public decimal Rate { get; set; }
}

Both projects use CQRS patterns, but Blazor Starter Kit tends to include more properties and uses Result<T> for better error handling.

Web Application ASP.NET 9 using Clean Architecture, DDD, CQRS, Event Sourcing and a lot of good practices

Pros of EquinoxProject

  • Implements Event Sourcing and CQRS patterns, providing a more comprehensive approach to domain-driven design
  • Includes a more extensive set of technologies, such as RabbitMQ for message queuing and Swagger for API documentation
  • Offers a more detailed example of a real-world application structure, including user management and authentication

Cons of EquinoxProject

  • May be more complex for beginners due to the additional architectural patterns and technologies used
  • Less frequently updated compared to CleanArchitecture, potentially lacking the latest best practices
  • Requires more setup and configuration due to the broader range of technologies involved

Code Comparison

EquinoxProject (Domain Event):

public class CustomerRegisteredEvent : Event
{
    public CustomerRegisteredEvent(Guid id, string name, string email, DateTime birthDate)
    {
        Id = id;
        Name = name;
        Email = email;
        BirthDate = birthDate;
        AggregateId = id;
    }
    // ... properties
}

CleanArchitecture (Domain Event):

public class TodoItemCompletedEvent : DomainEvent
{
    public TodoItemCompletedEvent(TodoItem item)
    {
        Item = item;
    }

    public TodoItem Item { get; }
}

Both projects demonstrate the use of domain events, but EquinoxProject's implementation is more detailed and includes additional properties specific to the event.

Full-stack .Net 10 Clean Architecture (Microservices, Modular Monolith, Monolith), Blazor, Angular 21, React 19, Vue 3.5, BFF with YARP, NextJs 16, Domain-Driven Design, CQRS, SOLID, Asp.Net Core Identity Custom Storage, OpenID Connect, EF Core, OpenTelemetry, SignalR, Background Services, Health Checks, Rate Limiting, Clouds (Azure, AWS, GCP), ...

Pros of Practical.CleanArchitecture

  • More comprehensive, covering additional aspects like caching, logging, and health checks
  • Includes practical examples of integrating with external services (e.g., SendGrid, Twilio)
  • Demonstrates implementation of both monolithic and microservices architectures

Cons of Practical.CleanArchitecture

  • Less focused on core Clean Architecture principles, potentially overwhelming for beginners
  • Not as actively maintained, with fewer recent updates and contributions
  • Documentation is less structured and detailed compared to CleanArchitecture

Code Comparison

Practical.CleanArchitecture (Domain Entity):

public class Product : AuditableEntity, IAggregateRoot
{
    public string Name { get; set; }
    public string Description { get; set; }
    public decimal Price { get; set; }
}

CleanArchitecture (Domain Entity):

public class TodoItem : AuditableEntity, IHasDomainEvent
{
    public int Id { get; set; }
    public int ListId { get; set; }
    public string Title { get; set; }
    public string Note { get; set; }
    public PriorityLevel Priority { get; set; }
}

Both repositories implement Clean Architecture principles, but Practical.CleanArchitecture offers a broader scope with more real-world examples. CleanArchitecture provides a more focused and well-documented approach, making it potentially more suitable for learning the core concepts. The code comparison shows similar entity structures, with Practical.CleanArchitecture using the IAggregateRoot interface and CleanArchitecture implementing IHasDomainEvent for domain events.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Clean Architecture Solution Template

Build CodeQL Nuget Nuget Twitter Follow

The goal of this template is to provide a straightforward and efficient approach to enterprise application development, leveraging the power of Clean Architecture and ASP.NET Core. Using this template, you can effortlessly create a new app with Angular, React, or Web API only, powered by ASP.NET Core and Aspire. Getting started is easy - simply install the .NET template (see below for full details).

For full documentation, visit cleanarchitecture.jasontaylor.dev.

If you find this project useful, please give it a star. Thanks! ⭐

Getting started

Prerequisites

  • .NET 10.0 SDK or later
  • Node.js (LTS) — only required if you plan to use the Angular or React frontend
  • Docker Desktop or Podman (or any OCI-compliant container runtime) — only required when using SQL Server or PostgreSQL. Not required when using SQLite (the default).

Install the template

dotnet new install Clean.Architecture.Solution.Template

Create a new solution

Create a new solution using the template. Specify the client framework using --client-framework (-cf) and the database provider using --database (-db):

dotnet new ca-sln --client-framework [angular|react|none] --database [postgresql|sqlite|sqlserver] --output YourProjectName
OptionValuesDefault
--client-frameworkangular, react, noneangular
--databasepostgresql, sqlite, sqlserversqlite

Examples:

🅰️ Angular SPA with ASP.NET Core Web API and PostgreSQL:

dotnet new ca-sln -cf angular -db postgresql -o YourProjectName

⚛️ React SPA with ASP.NET Core Web API and SQL Server:

dotnet new ca-sln -cf react -db sqlserver -o YourProjectName

🔌 ASP.NET Core Web API only with SQLite:

dotnet new ca-sln -cf none -db sqlite -o YourProjectName

💡 Tip: Run dotnet new ca-sln --help to see all available template options.

Run the app

dotnet run --project .\src\AppHost

The Aspire dashboard will open automatically, showing the application URLs and logs.

To learn more, see the Getting started guide and Architecture overview.

Technologies

Versions

The main branch is on .NET 10.0. Previous versions are available:

VersionBranch
.NET 9.0net9.0
.NET 8.0net8.0
.NET 7.0net7.0
.NET 6.0net6.0
.NET 5.0net5.0
.NET Core 3.1netcore3.1

Architectural decisions

Key design decisions are documented as Architecture Decision Records.

Learn more

Support

If you are having problems, please let me know by raising a new issue.

License

This project is licensed under the MIT License.