Skip to content
| Marketplace
Sign in
Visual Studio>Tools>SaschasCleanArch
SaschasCleanArch

SaschasCleanArch

Sascha Manns

|
16 installs
| (0) | Free
Clean Architecture Template for Console Apps
Download

Saschas Clean Architecture Project Template

This is a template for a clean architecture project in C# Console. It is based on the clean architecture principles by Uncle Bob. The project is structured in a way that it is easy to understand and to extend. It is also easy to test and to maintain.

I have published this Template on Visual Studio Marketplace. You can download it from there and use it in your projects.

Features

  1. Preconfigured for Dependency Injection
  2. Preinstalled the following Nuget Packages:
    1. Ardalis.GuardClauses
    2. AutoMapper
    3. Automapper.Collection.EntityFrameworkCore
    4. Coverlet.Collector
    5. FluentAssertions
    6. FluentValidationq
    7. JunitXml.TestLogger
    8. Microsoft.Extensions.Hosting
    9. Microsoft.Extensions.Configuration
    10. Microsoft.EntityFrameworkCore
    11. Microsoft.EntityFrameworkCore.Analyzer
    12. Microsoft.EntityFrameworkCore.Design
    13. Microsoft.EntityFrameworkCore.SqlServer
    14. Microsoft.EntityFrameworkCore.Tools
    15. NLog
    16. NLog.Extensions.Logging
    17. Sentry
    18. Sentry.Extensions.Logging
    19. SimdLinq
    20. SonarAnalyzer.CSharp
    21. Spectre.Console

How to use this template

Download the VSIX from Visual Studio Marketplace and install it. Then create a new project in Visual Studio and select the "Clean Architecture Project" template.

Project structure

  1. Application: This layer contains the use cases of the application. It is the most high-level layer and contains the business logic of the application. It is independent of the infrastructure and can be tested without any dependencies.
    1. Entities: This directory contains the entities of the use cases.
    2. Interfaces: This directory contains the interfaces of the use cases in underlying layers.
    3. Mappers: This directory contains the mappers that map entities to DTOs and vice versa.
    4. Models: This directory contains the models of the use cases and other stuff.
    5. Pipelines: This directory contains the pipelines that are used to process the use cases.
    6. Services: This directory contains the services that are used in the use cases.
    7. Validators: This directory contains the validators that are used to validate the input of the use cases.
  2. Assets: This directory contains the assets of the application like images, fonts, etc.
  3. Domain: This layer contains the entities and value objects of the application. It is the most high-level layer and contains the business logic of the application. It is independent of the infrastructure and can be tested without any dependencies.
    1. Aggregates: This directory contains the aggregates of the domain.
      1. Entities: This directory contains the entities of the domain.
      2. Specifications: This directory contains the specifications that are used to query the entities.
      3. ValueObjects: This directory contains the value objects of the domain.
    2. Interfaces: This directory contains the interfaces from underlying layers.
    3. Mappers: This directory contains the mappers that map entities to DTOs and vice versa.
    4. Models: This directory contains the models of the domain and other stuff.
    5. Pipelines: This directory contains the pipelines that are used to process the domain.
    6. Services: This directory contains the services that are used in the domain.
    7. Validators: This directory contains the validators that are used to validate the entities.
  4. Infrastructure: This layer contains the implementations of the interfaces from the application layer. It is the most low-level layer and contains the implementation details of the application. It is dependent on the application and domain layer.
    1. Data: This directory contains the data access layer of the application.
      1. DBContexts: This directory contains the EF Contexts.
      2. EF-Diagrams: This directory contains the EF Diagrams.
      3. Migrations: This directory contains the EF Migrations.
      4. Repositories: This directory contains the EF Repositories.
    2. Entities: This directory contains the EF Entities.
    3. Helpers: This directory contains the helpers that are used in the implementations.
    4. Interfaces: This directory contains the interfaces of the implementations.
    5. Mappers: This directory contains the mappers that map entities to DTOs and vice versa.
    6. Models: This directory contains the models of the implementations and other stuff.
    7. Pipelines: This directory contains the pipelines that are used to process the implementations.
    8. Services: This directory contains the services that are used in the implementations.
    9. Validators: This directory contains the validators that are used to validate the input of the implementations.

Documentation

In Program.cs a host service is set up (ConsoleService). This step was considered to enable both Dependency Injection and configuration via a JSON file. Also, a clean initialization and termination of the application is done via AppLifetime.

Configuration

The configuration is done via the appsettings.json file. Here you can adjust the database connection and the other stuff.

Also, the configuration of the logging is done via the nlog.config file.

Error Handling

We use the NLog framework to log the errors. The configuration for this is in the nlog.config file.

Errors and exceptions are logged in an Sentry instance and the affected developers are informed.

Contributing

If you want to contribute to this project, please fork the repository and create a pull request. I will review it and merge it if it is good.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft