Convert Figma logo to code with AI

jasontaylordev logoCleanArchitecture

Clean Architecture Solution Template for ASP.NET Core

16,821
3,617
16,821
71

Top Related Projects

Clean Architecture Template for Blazor WebAssembly Built with MudBlazor Components.

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

Full-stack .Net 8 Clean Architecture (Microservices, Modular Monolith, Monolith), Blazor, Angular 18, React 18, Vue 3, BFF with YARP, Domain-Driven Design, CQRS, SOLID, Asp.Net Core Identity Custom Storage, OpenID Connect, Entity Framework Core, OpenTelemetry, SignalR, Hosted Services, Health Checks, Rate Limiting, Cloud Services (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 8 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 8 Clean Architecture (Microservices, Modular Monolith, Monolith), Blazor, Angular 18, React 18, Vue 3, BFF with YARP, Domain-Driven Design, CQRS, SOLID, Asp.Net Core Identity Custom Storage, OpenID Connect, Entity Framework Core, OpenTelemetry, SignalR, Hosted Services, Health Checks, Rate Limiting, Cloud Services (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 Single Page App (SPA) with ASP.NET Core and Angular or React, while adhering to the principles of Clean Architecture. Getting started is easy - simply install the .NET template (see below for full details).

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

Getting Started

The following prerequisites are required to build and run the solution:

  • .NET 8.0 SDK (latest version)
  • Node.js (latest LTS, only required if you are using Angular or React)

The easiest way to get started is to install the .NET template:

dotnet new install Clean.Architecture.Solution.Template::8.0.6

Once installed, create a new solution using the template. You can choose to use Angular, React, or create a Web API-only solution. Specify the client framework using the -cf or --client-framework option, and provide the output directory where your project will be created. Here are some examples:

To create a Single-Page Application (SPA) with Angular and ASP.NET Core:

dotnet new ca-sln --client-framework Angular --output YourProjectName

To create a SPA with React and ASP.NET Core:

dotnet new ca-sln -cf React -o YourProjectName

To create a ASP.NET Core Web API-only solution:

dotnet new ca-sln -cf None -o YourProjectName

Launch the app:

cd src/Web
dotnet run

To learn more, run the following command:

dotnet new ca-sln --help

You can create use cases (commands or queries) by navigating to ./src/Application and running dotnet new ca-usecase. Here are some examples:

To create a new command:

dotnet new ca-usecase --name CreateTodoList --feature-name TodoLists --usecase-type command --return-type int

To create a query:

dotnet new ca-usecase -n GetTodos -fn TodoLists -ut query -rt TodosVm

To learn more, run the following command:

dotnet new ca-usecase --help

Database

The template is configured to use SQL Server by default. If you would prefer to use SQLite, create your solution using the following command:

dotnet new ca-sln --use-sqlite

When you run the application the database will be automatically created (if necessary) and the latest migrations will be applied.

Running database migrations is easy. Ensure you add the following flags to your command (values assume you are executing from repository root)

  • --project src/Infrastructure (optional if in this folder)
  • --startup-project src/Web
  • --output-dir Data/Migrations

For example, to add a new migration from the root folder:

dotnet ef migrations add "SampleMigration" --project src\Infrastructure --startup-project src\Web --output-dir Data\Migrations

Deploy

The template includes a full CI/CD pipeline. The pipeline is responsible for building, testing, publishing and deploying the solution to Azure. If you would like to learn more, read the deployment instructions.

Technologies

Versions

The main branch is now on .NET 8.0. The following previous versions are available:

There is also a 9.0 preview version available.

Learn More

Support

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

License

This project is licensed with the MIT license.