SSW Clean Architecture Template
[![SSW TV | YouTube](https://img.shields.io/youtube/channel/views/UCBFgwtV9lIIhvoNh0xoQ7Pg?label=SSW%20TV%20%7C%20Views&style=social)](https://youtube.com/@SSWTV)
[![Build and Test](https://github.com/SSWConsulting/SSW.CleanArchitecture/actions/workflows/build-and-test.yml/badge.svg?branch=main)](https://github.com/SSWConsulting/SSW.CleanArchitecture/actions/workflows/build-and-test.yml)
[![Code Scanning](https://github.com/SSWConsulting/SSW.CleanArchitecture/actions/workflows/codeql.yml/badge.svg)](https://github.com/SSWConsulting/SSW.CleanArchitecture/actions/workflows/codeql.yml)
[![Package](https://github.com/SSWConsulting/SSW.CleanArchitecture/actions/workflows/package.yml/badge.svg)](https://github.com/SSWConsulting/SSW.CleanArchitecture/actions/workflows/package.yml)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)
[![ADRs](https://sswconsulting.github.io/SSW.CleanArchitecture/badge.svg)](https://sswconsulting.github.io/SSW.CleanArchitecture/)
![SSW.CleanArchitecture Repo Analytics](https://repobeats.axiom.co/api/embed/3abf953e88642f725e44f5b300f6eddaf8fd9bee.svg "SSW.CleanArchitecture Repo analytics")
π€ What is it?
This is a template for creating a new project using Clean Architecture, leveraging SSW Rules & SSW's over 30 years of experience developing software in the Microsoft space.
β¨ Features
-
π¨ dotnet new
cli template - to get you started quickly
-
π Aspire
- Dashboard
- Resource orchestration
- Observability
- Simple dev setup - automatic provisioning of database server, schema, and data
-
π― Domain Driven Design Patterns
-
π Minimal Endpoints - because it's fast & simple. β‘
- Extension methods to ensure consistent HTTP Verbs & Status Codes
-
π OpenAPI/Scalar - easily document your API
-
π Global Exception Handling - it's important to handle exceptions in a consistent way & protect sensitive information
- Transforms exceptions into a consistent format following the RFC7231 memo
-
ποΈ Entity Framework Core - for data access
-
𧩠Specification Pattern - abstract EF Core away from your business logic
-
π CQRS - for separation of concerns
-
π¦ MediatR - for decoupling your application
-
π¦ ErrorOr - fluent result pattern (instead of exceptions)
-
π¦ FluentValidation - for validating requests
-
π¦ AutoMapper - for mapping between objects
-
π Strongly Typed IDs - to combat primitive obsession
- e.g. pass
CustomerId
type into methods instead of int
, or Guid
- Entity Framework can automatically convert the int, Guid, nvarchar(..) to strongly typed ID.
-
π Directory.Build.Props
- Consistent build configuration across all projects in the solution
- e.g. Treating Warnings as Errors for Release builds
- Custom per project
- e.g. for all test projects we can ensure that the exact same versions of common packages are referenced
- e.g. XUnit and NSubstitute packages for all test projects
-
βοΈ EditorConfig - comes with the SSW.EditorConfig
-
π§ͺ Testing
- as per ssw.com.au/rules/rules-to-better-testing/
- Simpler Unit Tests for Application
- Better Integration Tests
- Using Respawn and TestContainers
- Integration Tests at Unit Test speed
- Test Commands and Queries against a Real database
- No Entity Framework mocking required
- No need for In-memory database provider
π Learn More
Training
If you're interested in learning more about Clean Architecture SSW offers two events:
Learning Resources
You're interested learning more about Clean Architecture, please see this excellent video by Matt Goldman:
Alternatively, SSW has many great rules about Clean Architecture:
You can also find a collection of commumity projects built on Clean Architecture here:
π€ Contributing
Contributions, issues and feature requests are welcome! See Contributing for more information.