• Stars
    star
    1,299
  • Rank 34,918 (Top 0.8 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An implementation of Clean Architecture for ASP.NET Core 3.1 WebAPI. Built with loosely coupled architecture and clean-code practices in mind.

ASP.NET Core WebApi - Clean Architecture

.NET Core GitHub stars Twitter Follow


An Implementation of Clean Architecture with ASP.NET Core 3.1 WebApi. With this Open-Source BoilerPlate Template, you will get access to the world of Loosely-Coupled and Inverted-Dependency Architecture in ASP.NET Core 3.1 WebApi with a lot of best practices.

Check out the Project Page to learn more about this Open Source Project.

Read the Changelog file to see the new changes.

Annoucement : fullstackhero - .NET 6.0 Clean Architecture WebAPI !

I am no longer supporting this project. No more new features will be added to this repository. I am building a .NET WebApi 6.0 Clean Architecture Boilerplate Project with better features and Multitenancy ofcourse! Visit the new project - https://github.com/fullstackhero/dotnet-webapi-boilerplate

fullstackhero

0.0.1 RC is available now!

This is the first pre-release version of the fullstackhero .NET WebAPI Boilerplate package. Newer versions will be available on a weekly basis with newer updates and patches. Read the getting-started guide for more.

The Release Version is expected to be out by Novemeber, 2021 as soon as .NET 6 LTS is launched by Microsoft. Preview versions of this project is available for Initial Developer Testing.

Important Links & Documentations

[Documentation] Overview - Read

[Documentation] Getting Started - Read

[Documentation] Development Environment - Learn about setting up the DEV environment

Track Progress - Release 1.0 Milestones

Participate in Discussions - QNA & General Discussions

Join our Discord - fullstackhero @ Discord

Releases - ASP.NET Core 3.1 Template

v1.1 - Stable Release - Download the Stable Release

v1.0-preview - Download the first Preview here

v1.1

Follow these steps to get started with this Boiler Plate Template.

Download the Extension

Make sure Visual Studio 2019 is installed on your machine with the latest SDK. Download from Visual Studio Marketplace. Install it on your machine.

Follow these Steps to get started.

alt text

alt text

You Solution Template is Ready!

alt text

Visit the Project Page to learn more - Click Here

Alternatively you can also clone the Repository.

  1. Clone this Repository and Extract it to a Folder.
  2. Change the Connection Strings for the Application and Identity in the WebApi/appsettings.json - (WebApi Project)
  3. Run the following commands on Powershell in the WebApi Projecct's Directory.
  • dotnet restore
  • dotnet ef database update -Context ApplicationDbContext
  • dotnet ef database update -Context IdentityContext
  • dotnet run (OR) Run the Solution using Visual Studio 2019

Check out my blog or say Hi on Twitter!

How to use MySQL or PostgreSQL as your Data Provider

The Project currently uses MSSQL as the default Data Provider. If you are more comfortable with MySQL or PostgreSQL, here is how to migrate to them easily.

  1. delete all existing file inside migrations folder on both project

    • {YourProjectName}.Infrastructure.Identity
    • {YourProjectName}.Infrastructure.Persistence
  2. In in ServiceExtensions.cs and ServiceRegistration.cs change from options.UseSqlServer to:

For MySql

options.UseMySql

For PostgreSQL

options.UseNpgsql

  1. Add NuGet packages to both projects (Infrastructure.Identity and Infrastructure.Persistence):

For MySql:

run dotnet add package Pomelo.EntityFrameworkCore.MySql --version 3.1.2 (remember to do this on both projects)

For PostgreSQL:

run

dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL.Design

(remember to do this on both projects)

  1. on IdentityContext.cs comment builder.HasDefaultSchema("Identity"); because ef doesn't support that on mysql

  2. cd to {YourProjectName}.Infrastructure.Identity and run

    • dotnet ef database update --startup-project ../{YourProjectName}.WebApi/{YourProjectName}.WebApi.csproj -c "IdentityContext"
    • dotnet ef migrations add Initial --startup-project ../{YourProjectName}.WebApi/{YourProjectName}.WebApi.csproj -c "IdentityContext"
  3. cd to {YourProjectName}.Infrastructure.Persistence and run

    • dotnet ef database update --startup-project ../{YourProjectName}.WebApi/{YourProjectName}.WebApi.csproj -c "ApplicationDbContext"
    • dotnet ef migrations add Initial --startup-project ../{YourProjectName}.WebApi/{YourProjectName}.WebApi.csproj -c "ApplicationDbContext"

The above guide (To use MySQL) was contributed by geekz-reno.

Default Roles & Credentials

As soon you build and run your application, default users and roles get added to the database.

Default Roles are as follows.

  • SuperAdmin
  • Admin
  • Moderator
  • Basic

Here are the credentials for the default users.

You can use these default credentials to generate valid JWTokens at the ../api/account/authenticate endpoint.

Purpose of this Project

Does it really make sense to Setup your ASP.NET Core Solution everytime you start a new WebApi Project ? Aren't we wasting quite a lot of time in doing this over and over gain?

This is the exact Problem that I intend to solve with this Full-Fledged ASP.NET Core 3.1 WebApi Solution Template, that also follows various principles of Clean Architecture.

The primary goal is to create a Full-Fledged implementation, that is well documented along with the steps taken to build this Solution from Scratch. This Solution Template will also be available within Visual Studio 2019 (by installing the required Nuget Package / Extension).

  • Demonstrate Clean Monolith Architecture in ASP.NET Core 3.1
  • This is not a Proof of Concept
  • Implementation that is ready for Production
  • Integrate the most essential libraries and packages

Give a Star โญ๏ธ

If you found this Implementation helpful or used it in your Projects, do give it a star. Thanks! Or, If you are feeling really generous, Support the Project with a small contribution!

Technologies

  • ASP.NET Core 3.1 WebApi
  • REST Standards
  • .NET Core 3.1 / Standard 2.1 Libraries

Features

  • Onion Architecture
  • CQRS with MediatR Library
  • Entity Framework Core - Code First
  • Repository Pattern - Generic
  • MediatR Pipeline Logging & Validation
  • Serilog
  • Swagger UI
  • Response Wrappers
  • Healthchecks
  • Pagination
  • In-Memory Caching
  • Redis Caching
  • In-Memory Database
  • Microsoft Identity with JWT Authentication
  • Role based Authorization
  • Identity Seeding
  • Database Seeding
  • Custom Exception Handling Middlewares
  • API Versioning
  • Fluent Validation
  • Automapper
  • SMTP / Mailkit / Sendgrid Email Service
  • Complete User Management Module (Register / Generate Token / Forgot Password / Confirmation Mail)
  • User Auditing

Brief Overview

alt text

Prerequisites

  • Visual Studio 2019 Community and above
  • .NET Core 3.1 SDK and above
  • Basic Understanding of Architectures and Clean Code Principles
  • I Recommend that you read Onion Architecture In ASP.NET Core With CQRS โ€“ Detailed article to understand this implementation much better. This project is just an Advanced Version of the mentioned article.

Getting Started

Changelog

Every changes / additions / deletions will be recorded in the Changelog file.

Questions? Bugs? Suggestions for Improvement?

Having any issues or troubles getting started? Get in touch with me or Raise a Bug or Feature Request. Always happy to help.

Support

Has this Project helped you learn something New? or Helped you at work? Do Consider Supporting.

Buy Me A Coffee

Share it!

I have personally not come across a clean implementation on a WebAPI, which is the reason that I started building this up. There are quite a lot of improvements and fixes along the way from the day I started out. Thanks to the community for the support and suggestions. Please share this Repository within your developer community, if you think that this would a difference! Thanks.

About the Author

Mukesh Murugan

Licensing

iammukeshm/CleanArchitecture.WebApi Project is licensed with the MIT License.

More Repositories

1

OnionArchitecture

The onion architecture, introduced by Jeffrey Palermo, overcomes the issues of the layered architecture with great ease. With Onion Architecture, the game-changer is that the Domain Layer (Entities and Validation Rules that are common to the business case ) is at the Core of the Entire Application. This means higher flexibility and lesser coupling. In this approach, we can see that all the Layers are dependent only on the Core Layers.
C#
417
star
2

CustomUserManagement.MVC

Letโ€™s go in-depth and understand the functionalities you can achieve with the help of Microsoft Identity. We will build a small yet practical implementation of Custom User Management in ASP.NET Core MVC with Identity.
C#
244
star
3

AspNetCoreHero-Boilerplate

ASP.NET CORE HERO - Boilerplate template for your next project!
CSS
181
star
4

PermissionManagement.MVC

Let's implement Permission-Based Authorization in ASP.NET Core
C#
162
star
5

Dapper.WebApi

Let's Learn Dapper with ASP. NET Core! Here is an Implementation of Dapper in ASP.NET Core with Repository Pattern / Unit Of Work and a Clean Architecture.
C#
132
star
6

modular-monolith-aspnet-core-sample

C#
118
star
7

RepositoryPattern.WebApi

We will go through everything you will need to know about Repository Pattern in ASP.NET Core, Generic Repository Patterns, Unit of Work and related topics. We will build a project right from scratch where we implement a clean architecture to access data.
C#
116
star
8

CQRS.WebApi

Here is an implementation of CQRS with MediatR in ASP.NET Core 3.1. Read the step by step guide in my blog post.
C#
90
star
9

AdminLTE.StarterKit

AdminLTE Starter Kit for ASP.NET Core 3.1. Let's build up a full-fledged Open Source Project designed to provide our fellow developers a better way to get started. Saves tons of Dev-Hours too!
JavaScript
84
star
10

BlazorChat

Building a Complete Chat Application in Blazor WebAssembly 5.0 with SignalR and Identity. UI is taken care by MudBlazor Component Library.
C#
83
star
11

multitenancy-aspnet-core

Multitenancy in ASP.NET Core
C#
76
star
12

Pagination.WebApi

Pagination is one of the most important concepts while building RESTful APIs. You would have seen several public APIs implementing this feature for better user experience and security. We will go in detail and try to build an ASP.NET Core 3.1 WebApi that implements advanced pagination.
C#
71
star
13

AuditTrail.EFCore.Demo

Audit Trail Implementation in ASP.NET Core with Entity Framework Core
C#
69
star
14

AdminLTE.MVC

We will learn about Integrating AdminLTE with ASP.NET Core 3.1 MVC or really any other Bootstrap based UI Frameworks completely from scratch. We will also go through about integrating Identity Authentication to our MVC Applicaiton. Also, you will gain quite a lot of practical knowledge on Views, Layouts, Partial Views, Conditional Rendering, Navigation Indicatior and much more.
JavaScript
65
star
15

specification-pattern-asp-net-core

C#
60
star
16

MailService.WebApi

Let's Build an ASP.NET Core Api that Sends Mail using Gmail SMTP. Read more on my blog post.
HTML
54
star
17

Blazor.Learner

Let's Learn Blazor!
C#
53
star
18

JWTAuthentication.WebApi

Security is a vital part of any kind of application. Since APIs can expose highly sensitive data like user details, email adressses , it is highly critical that these API endpoints are secured.In this Guide let's build a Secure ASP.NET Core API with JWT Authentication. Read my detailed blog post for implementation.
C#
50
star
19

Microservice.WebApi

We will be building a Simple Microservice Application for demonstrating various Concepts including Microservice Architecture in ASP.NET Core, API Gateways, Ocelot, Ocelot Configuration , Routing and much more.
C#
48
star
20

EFCoreAndDapper

Learn to Work with Dapper and Entity Framework within the Same ASP.NET Core Solutions. This is an implementation taking Transactions into concern as well. Probably a Facade Pattern too!
C#
38
star
21

RazorCRUD.jQueryAJAX

Razor Page CRUD in ASP.NET Core with Onion Architecture, Razor Partial Views, jQuery Datatable, jQuery AJAX , Repository Pattern, Unit Of Work, Bootstrap Modal and much more!
CSS
37
star
22

RepositoryPatternWithCachingAndHangfire

Let's builder a SUPER-FAST Repository Implementation with Unit Of Work , Caching and Hangfire!
C#
36
star
23

Multilingual.ASPNETCore

We will discuss in detail, Globalization and Localization in ASP.NET Core Application and go through various approaches on changing the Culture of the Application via Request. We will also do some advanced configuration where we store the Selected Language Information to the Cookie in the client browser.
C#
34
star
24

Microservices.Ticketing.WebApi

RabbitMQ and MassTransit for ASP.NET Core Microservice Communication. Let's learn and build a small Ticketing Application to demonstrate the concepts.
C#
33
star
25

Datatables.ServerSide

Let's build a jQuery Datatable in ASP.NET Core 3.1 with Server-Side Processing! We will also cover Paging, Sorting, Searching and much more
TSQL
33
star
26

jwt-authentication-golang

Implementing JWT Authentication in Golang REST APIs and securing it with Authentication Middleware.
Go
30
star
27

FileUpload.MVC

Uploading Images or other documents is a very basic and common requirement when it comes to building anything from a simple application to an enterprise-level solution. Letโ€™s build a small application with which you could upload files of any type to a file system location or to a centralized database table.
C#
29
star
28

golang-crud-rest-api

Implementing CRUD in Golang REST API with Mux & GORM
Go
22
star
29

GettingStartedWithIdentityServer4.ASPNETCore

C#
22
star
30

GraphQL.WebApi

A simple implementaion of GraphQL for ASP.NET Core 3.1 WebAPI. Demonstrated using GraphQL Playground Package.
C#
21
star
31

COVID19.Tracker

Here is a Simple COVID-19 Dashboard for India built with ASP.NET Core 3.1 Backend. A Small Side-Project.
CSS
21
star
32

CoreEssentials

Essential NuGet Packages for your ASP.NET Core Applications.
C#
20
star
33

CleanArchitecture.WebApplication

Project Moved to
CSS
19
star
34

mediatr-response-caching

Response Caching with MediatR in ASP.NET Core
C#
19
star
35

aspnet-core-json-localization

JSON Based Localization in ASP.NET Core
C#
19
star
36

global-exception-handling-aspnet-core

C#
19
star
37

HealthChecks.WebApi

In this article, we will go through Healthchecks in ASP.NET Core, itโ€™s uses, variations and implementing your own custom health-checks. This is one of the integral parts to consider while building ASP.NET Core Applications for production. Here are the topics covered.
C#
18
star
38

MudblazorDemo.CRUD

Implementing CRUD Operations in Blazor .NET 5 using the Mudblazor Component Library.
HTML
16
star
39

gRPC.Dotnet.Learner

Let's learn gRPC in ASP.NET Core and build Faster APIs!
C#
16
star
40

cowin-vaccine-notifier

A Small POC Project that sends out a notification message on your Mobile Devices whenever there are vaccinations available in your District. In-Depth Details are also available as a part of the notification message via the IFTTT application. Written in C# .NET 5.0.
C#
14
star
41

BlazorWithTailwindCSS

Integrating Tailwind CSS with Blazor.
HTML
14
star
42

Caching.WebApi

Let's learn Caching in ASP.NET Core. Caching is a technique of storing the frequently accessed/used data so that the future requests for those sets of data can be served much faster to the client.
C#
14
star
43

Hangfire.WebApi

Hangfire is an open-sourced library that enables the developers to schedule events in the background with the utmost ease. It is a highly flexible library offering various features needed to make the job scheduling task a cake-walk. Hangfire in ASP.NET Core is the one library that you canโ€™t miss out on. Read my blog post for step-by-step guide on implementing Hangfire in ASP.NET Core Applications.
C#
14
star
44

PointOfSales.DataCenter

This will be the Core of the entire solution. This Api will be responsible for overall data distribution and authorization.
C#
13
star
45

FluentValidation.WebApi

When it comes to Validating Models, arenโ€™t we all leaning towards Data Annotations? There are quite a lot of serious issues with this approach for a scalable system. We will discuss the preferred alternative and implement it in an ASP.Net core API. Read more at my blog post.
C#
13
star
46

WorkingWithMongoDB.WebAPI

Let's Integrate MongoDB in ASP.NET Core 3.1 WebAPI!
C#
12
star
47

Versioning.WebApi

API versioning in ASP.NET Core is a technique by which different clients can get different implementations of the same Controller based on the request or the URL.So essentially, you build an API that has multiple versions that may behave differently. Read my complete blog post about the implementation and best practices.
C#
12
star
48

built-in-container-support-for-dotnet-7

You no longer need a Dockerfile for your .NET Applications!
C#
11
star
49

dotnet-on-aws-series

C#
11
star
50

CoreLibrary

A Helper Library for all my future .NET Core Projects
C#
11
star
51

aws-s3-dotnet-webapi

Guide on working with AWS S3 using ASP.NET Core Web API to upload, download and delete files from Amazonโ€™s Super Scalable S3
C#
11
star
52

Serilog.WebApplication

Serilog is a third-party logging library that plugs into the default ILogger of our application with its own implementations. It enables the developers to log the events into various destinations like console, file, database, and more. Now, if you are already using a database in your ASP.NET Core Application, logging events to a database can be a good option. Read the complete GUIDE in my blog post.
C#
11
star
53

CWM.StoreManager

DDD with Clean Architecture.
C#
10
star
54

EFCore.CodeFirst.WebApi

Entity Framework Core is a lightweight, extensible, open-sourced version of the Entity Framework Data Access Technology built for .NET Core Applications. It is essentially a way to read and write data in a flexible and easier way. Read my Blog Post.
C#
10
star
55

eStore

eCommerce Application on .NET Core to demonstrate various Architecture , Design Patterns and Best Practices for Clean and Scalable Code.
C#
10
star
56

Select2.WebApplication

Let's Learn Select2 jQuery Plugin in ASP. NET Core.
C#
9
star
57

iammukeshm

About me!
9
star
58

WPF.CleanArchitecture

Prototype for Clean Architecture in WPF using UI Components and DI
C#
9
star
59

LoggingWithNLog.WebApi

Let's learn NLog! One of the popular Logging Framework for ASP.NET Core Applications.
C#
9
star
60

aws-serverless-dotnet

C#
9
star
61

aws-dynamodb-crud-aspnet-core

C#
8
star
62

BusinessManager

C#
8
star
63

aws-lambda-dotnet-6

AWS Lambda with .NET 6
C#
7
star
64

options-pattern-aspnet-core

How do you load & validate your Configurations in ASP.NET Core applications from appsettings.json? ๐Ÿค”
C#
7
star
65

cowin

C#
7
star
66

securing-dotnet-webapi-with-amazon-cognito

C#
7
star
67

express-mongodb-api-architecture

Build a Scalable REST API using Node.js, Express.js and MongoDB
JavaScript
7
star
68

WordPressOnCore.PeachPie

Let's run Wordpress on ASP.NET Core with PeachPie!
C#
7
star
69

hosting-aspnet-core-webapi-on-amazon-ec2

hosting-aspnet-core-webapi-on-amazon-ec2
C#
7
star
70

Automapper.WebApi

We will go through the features of Automapper and the problems it solves by practical use cases. In order to maintain a separation of concern between various of your layers in an ASP.NET Core Project, it is advisable to have different models / Data transfer objects that are associated with a specific layer. This is a very good practice. But with time, you end up with lots and lots of code. Here is where Automapper helps. Read More.
C#
7
star
71

BlazorBazaar

Open Sourced eCommerce Solution built with .NET 5.0 / Blazor WebAssembly / Clean Architecture
HTML
6
star
72

dotnet-tips

C#
6
star
73

webapi-token-authentication-role-based-authorization-asp.net-core-3.1

C#
6
star
74

send-emails-from-aspnet-core-using-amazon-ses

Send Emails from ASP.NET Core using Amazon SES
C#
6
star
75

amazon-api-gateway-lambda-authorizer-dotnet

Securing Amazon API Gateway with Lambda Authorizer in .NET!
C#
6
star
76

face-recognition

JavaScript
5
star
77

PointOfSales.SalesCenter

C#
5
star
78

aws-secrets-manager-with-aspnet-core-webapi

Do this to secure your Sensitive Data in ASP.NET Core with AWS Secrets Manager.๐Ÿ”’
C#
5
star
79

todo-list-javascript

JavaScript
4
star
80

CWM.CleanArchitecture

An Implementation of Clean Architecture for ASP.NET Core 3.1 Application with MVC + API.
C#
4
star
81

CleanOnion.Api

Implementation / Template / Boilerplate for ASP.NET Core 3.1 Api following clean and SOLID code principles. Supports Scalability and Deep Testing.
C#
4
star
82

Elmah.IO.WebApi

elmah.io is a full-fledged error management system for anything from simple console applications to enterprise-level web applications. To get you guys more excited, elmah.io lets you push the logs of your .NET applications directly to the cloud. This is something really innovative to get started with. Read the entire blog post.
C#
4
star
83

CWM.DotNetCore

Collection of .NET Core Nuget Packages.
C#
3
star
84

deploying-aspnet-core-webapi-to-aws-apprunner

C#
3
star
85

structured-logging-golang-zap

Structured Logging in Golang with Zap from Uber!
Go
3
star
86

mongodb-expressjs-nodejs-crud-api

a restful api built on express js connected to mongoDb to demonstrate crud operations
JavaScript
3
star
87

first-expressjs-api

a very simple express js api that explains the basics of the api's workflow
JavaScript
3
star
88

aws-codepipeline-dotnet-demo

Deploying ASP.NET Core Web API to AWS Elastic Beanstalk using AWS CodePipeline
C#
3
star
89

hosting-aspnet-core-web-api-with-aws-lambda

we will learn about hosting ASP.NET Core Web API with AWS Lambda in a rather simple-to-follow manner. It is going to be as simple as developing a .NET 6 Web API as you would normally do using Controllers or Minimal APIs, and uploading the published files over to AWS Lambda (or using the standard AWS Templates shipped with the AWS Toolkit).
C#
3
star
90

amazon-cloudwatch-serilog-dotnet

Logging to Amazon Cloudwatch with Serilog in .NET
C#
2
star
91

webapi-basic-authentication-middleware-asp.net-core-3.1

Sample Code for Basic Authentication in WebAPI .NET Core using Middleware.
C#
2
star
92

CWM.CoreExtensions

C#
2
star
93

MiniProfiler.MVC

HTML
2
star
94

aws-cdk-for-dotnet-developers

C#
2
star
95

PointOfSales.ControlCenter

JavaScript
2
star
96

dotnet-lambda-annotations-framework

Cleaner way to write .NET AWS Lambdas - using the Annotations Framework!
C#
2
star
97

n-tier-architecture-asp.net-core-mvc

n-Tier Architecture Implemented on ASP.NET Core MVC 3.1.
C#
2
star
98

swagger-implementation-asp.net-core-3.1-webapi

Sample Code for Swagger Implementation in ASP.NET Core 3.1 WebApi
C#
2
star
99

DeliVeggie

C#
2
star
100

learn-react

2
star