• Stars
    star
    417
  • Rank 103,829 (Top 3 %)
  • Language
    C#
  • Created over 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

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.

Onion Architecture In ASP.NET Core With CQRS

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 flexbility and lesser coupling. In this approach, we can see that all the Layers are dependent only on the Core Layers.

Give a Star ⭐️

If you found this Implementation helpful or used it in your Projects, do give it a star. Thanks!

Overview

alt text

We will talk about Onion Architecture In ASP.NET Core and it's advantages. We will also together build a WebApi that follows a variant of Onion Architecture so that we get to see why it is important to implement such an architecture in your upcoming projects.

Here is a list of features and tech we will be using for this setup.

  • Onion Architecture
  • Entity Framework Core
  • .NET Core 3.1 Library / .NET Standard 2.1 Library / ASP.NET Core 3.1 WebApi
  • Swagger
  • CQRS / Mediator Pattern using MediatR Library
  • CRUD Operations
  • Inverted Dependencies
  • API Versioning
Read more on my Blog Post - https://www.codewithmukesh.com/blog/onion-architecture-in-aspnet-core/

Full Fledged Clean Architecture Solution for ASP.NET Core WebApi

I am building a more complex variant of this implementation that will be production ready. Check out the Repository @ https://github.com/iammukeshm/CleanArchitecture.WebApi

Questions? Bugs? Suggestions for Improvement?

Having any issues or troubles getting started? Get in touch with me

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

More Repositories

1

CleanArchitecture.WebApi

An implementation of Clean Architecture for ASP.NET Core 3.1 WebAPI. Built with loosely coupled architecture and clean-code practices in mind.
C#
1,299
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

aspnet-core-json-localization

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

mediatr-response-caching

Response Caching with MediatR 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

CoreLibrary

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

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
51

dotnet-on-aws-series

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

LoggingWithNLog.WebApi

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

WPF.CleanArchitecture

Prototype for Clean Architecture in WPF using UI Components and DI
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

securing-dotnet-webapi-with-amazon-cognito

C#
7
star
66

cowin

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

CWM.CoreExtensions

C#
2
star
92

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

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

PointOfSales.ControlCenter

JavaScript
2
star
94

aws-cdk-for-dotnet-developers

C#
2
star
95

dotnet-lambda-annotations-framework

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

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

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

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

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

DeliVeggie

C#
2
star
99

learn-react

2
star
100

MiniProfiler.MVC

HTML
2
star