.NET Web API Clean Architecture - Key Features

  • Fluent Validation

  • Nswag With .NET Core

  • Call an external WCF Sevice

  • Consume RESTFull API

  • Integration test cases

  • Automation test cases

  • Functional Test cases

  • Performance and Load Testing

  • Redis caching

  • Azure Cosmos DB

  • JWT Token Authentication

  • JWT Refresh Token

  • JWT Authorization

  • Azure Blob storage

  • Azure Portal Access

  • Azure DevOps Access

  • Unit Testing and Code Coverage

  • Source Code Analysis

Lab-2: Clean Architecture Project Structure


Introduction

This is Episode-2 of the sequence of videos on “.NET Core Web API Architecture”. It is always recommended to watch the previous episodes before start the new episode.

In this episode I’ve created project structure for REST API clean architecture.

I’ve started with Feedback service as an example to start the journey.

Agenda

In this Lab we will accomplish following:

  • Create src & test folders

  • Create ASP.NET Core Web API C# version FeedbackService.Api

  • Create .NET Core class library for Core FeedbackService.Core

  • Create .NET Core class library for Infrastructure FeedbackService.Infrastructure

  • Create .Xunit project for API FeedbackService.Api.Tests

  • Create .Xunit project for Core FeedbackService.Core.Tests

  • Create .Xunit project for Infrastructure FeedbackService.Infrastructure.Tests

  • Create .gitignore file

  • Create .gitattribute file

  • Push the code into Git

  • Pull the code from Git

  • Commit changes into remote Git

  • Create new feature branch called feature-branches for next set of changes

  • Create folder structure & files for API

    • ApiConstants.cs
    • AppSettings.cs
    • DependencyInjection.cs
    • FeedbackService.Api.xml
    • KeyVaultCache.cs
    • ServiceDescription.md
    • ServiceExtensions.cs
    • SwaggerConfiguration.cs
    • Middlewares
      • HttpCodeAndLogMiddleware.cs
    • Helper
      • MapperProfile.cs
    • HealthCheck
      • MemoryHealthCheck.cs
    • HealthCheck
      • RemoteHealthCheck.cs
    • SwaggerExamples
      • Requests
        • FeedbackRequestExample.cs
      • Response
        • FeedbackResponseExample.cs
    • V1
      • Controllers
        • FeedbackController.cs
    • V2
      • Controllers
        • FeedbackController.cs
  • Create folder structure & files for Core

    • Constants
      • ContentTypes.cs
    • Exception
    • Interfaces
    • Models
    • Services
    • Exception
      • ApiException.cs
      • DomainException.cs
      • NotFoundException.cs
      • ValidationException.cs
    • Interfaces
      • Repositories
        • IFeedbackRepository.cs
    • Interfaces
      • Services
        • IFeedbackService.cs
    • Models
      • Feedback.cs
    • Services -FeedbackService.cs
  • Create folder structure & files for Infrastructure

    • Context
      • FeedbackDbContext.cs
    • Entities
      • Feedback.cs
    • Repositories
      • FeedbackRepository.cs
  • Add project references (Internal references)

    • Add dependencies in src
      • API
        • Core
        • Infrastructure
        • Swashbuckle.AspNetCore
      • Core
        • Newtonsoft.Json
        • If any shared nuget packages comes here
      • Infrastructure
        • Core
        • Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection -Version 8.1.1
        • Install-Package Microsoft.EntityFrameworkCore -Version 5.0.9
        • Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 5.0.9
        • Install-Package Microsoft.EntityFrameworkCore.Design -Version 5.0.9
        • Uninstall-Package Microsoft.EntityFrameworkCore.Design -Version 5.0.9
    • Add dependencies in test
      • FeedbackService.Api.Tests
        • FeedbackService.Api
      • FeedbackService.Core.Tests
        • FeedbackService.Core
      • FeedbackService.Infrastructure.Tests
        • FeedbackService.Infrastructure
  • Add model in infra called Feedback.cs

  • Create DbContext classes & register in startup

  • Create model in Core - Feedback.cs

  • Create interface in Core - IFeedbackRepository.cs

  • Create interface’s implementation in Infra - FeedbackRepository.cs

  • Configure dependencies for repos

  • Create Service interface & classes – IFeedbackService & FeedbackService

  • Create Service classes - FeedbackService

  • Create controller classes – FeedbackController

PowerPoint Slides

PowerPoint slides userd in the Vide.

slide22

slide23

slide24

slide25

An error has occurred. This application may no longer respond until reloaded. Reload 🗙