Building Clean Architecture Application using ASP.NET Core Web API and Angular 11 — Backend

In this article, we are going to learn building a Clean Architecture application using ASP.NET Core Web API and Angular 11 Front End.

Series Links

Building an ASP.NET Core WebAPI using Clean Architecture

Building an Angular 11 Application integrated with WebAPI

Overview

Features:

  • API Versioning
  • Swagger UI.
  • JWT Token Authentication
  • Global Error Handler Middleware
  • CQRS ( Command Query Responsibility Segregation)
  • MediatR
  • NHibernate ORM
  • Generic Repository Pattern
  • Fluent Validation
  • SQLSERVER

Github Project

Onion Architecture

Clean Architecture
The architecture defines where the application performs its core functionality and how that functionality interacts with things like the database and the user interface. Clean architecture refers to organizing the project so that it’s easy to understand and easy to change as the project grows.

Command Query Responsibility Segregation is a design pattern to separate the read and write processes of your application. Read operations are called Queries and write operations are called Commands.

Project Structure

Swagger UI Setup

Installing Swagger packages using NuGet package console with the below command.

Install-Package Swashbuckle.AspNetCore -Version 5.6.3

Swagger Configuration with Bearer token Authentication

JWT Token Implementation

Token Generation On Successful Login

Global Error Middleware

NHibernate ORM and Generic Repository Pattern

User Entity

UserMap

Fluent Validation

<PackageReference Include=”FluentValidation.DependencyInjectionExtensions” Version=”9.3.0" />

To define a set of validation rules for a particular object, you will need to create a class that inherits from AbstractValidator<T>, where T is the type of class that you wish to validate.

Below is the sample Create User Validations.

Summary

Architect and Full Stack Developer in Dotnet Core, C#, WebApi’s, Integrations and Learner on Angular and React FrontEnd

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store