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.
- ⚖️ EditorConfig - comes with the SSW.EditorConfig
- Maintain consistent coding styles for individual developers or teams of developers working on the same project using different IDEs
- as per ssw.com.au/rules/consistent-code-style/
- 📦 Slim - no authentication provider, no authorization & no UI framework
- You can add these yourself or use one of our reference architectures from awesome-clean-architecture
- as per ssw.com.au/rules/choosing-authentication/
- 🌐 Minimal Endpoints - because it's fast & simple. ⚡
- Extension methods to ensure consistent HTTP Verbs & Status Codes
- 🔑 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
- 📝 OpenAPI/Swagger - easily document your API
- 🗄️ Entity Framework Core - for data access
- Comes with Migrations & Data Seeding
- as per ssw.com.au/rules/rules-to-better-entity-framework/
- 🧩 Specification Pattern - abstract EF Core away from your business logic
- 🔀 CQRS - for separation of concerns
- 📦 MediatR - for decoupling your application
- 📦 FluentValidation - for validating requests
- 📦 AutoMapper - for mapping between objects
- 🆔 Strongly Typed IDs - to combat primitive obsession
- e.g. pass
CustomerId
type into methods instead ofint
, orGuid
- Entity Framework can automatically convert the int, Guid, nvarchar(..) to strongly typed ID.
- e.g. pass
- 🔨
dotnet new
cli template - to get you started quickly - 📁 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
- Consistent build configuration across all projects in the solution
- 🧪 Testing
- as per ssw.com.au/rules/rules-to-better-testing/
- Simpler Unit Tests for Application
- No Entity Framework mocking required thanks to Specifications
- as per ssw.com.au/rules/rules-to-better-unit-tests/
- 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
- Architecture Tests
- Using NetArchTest
- Know that the team is following the same Clean Architecture fundamentals
- The tests are automated so discovering the defects is fast
Template will be published to NuGet.org when changes are made to CleanArchitecture.nuspec
on the main
branch.
- Update the
version
attribute inCleanArchitecture.nuspec
- Merge your PR
package
GitHub Action will run and publish the new version to NuGet.org
- Install the SSW CA template
dotnet new install SSW.CleanArchitecture.Template
NOTE: The template only needs to be installed once. Running this command again will update your version of the template.
- Create a new directory
mkdir Northwind365
cd Northwind365
- Create a new solution
dotnet new ssw-ca
NOTE:
name
is optional; if you don't specify it, the directory name will be used as the solution name and project namespaces.
Alternatively, you can specify the name
and output
directory as follows:
dotnet new ssw-ca --name {{SolutionName}} --output .\
- Create a query
cd src/Application/Features
mkdir {{FeatureName}}
cd {{FeatureName}}
dotnet new ssw-ca-query --name {{QueryName}} --entityName {{Entity}} --namespaceRoot {{Namespace}}
- Create a command
cd src/Application/Features
mkdir {{FeatureName}}
cd {{FeatureName}}
dotnet new ssw-ca-command --name {{CommandName}} --entityName {{Entity}} --namespaceRoot {{Namespace}}