SlideShare a Scribd company logo
Project Onion
Project Architecture
By Abhinav Jha
Created On: 7th March 2018
What Is Onion Architecture?
The Onion Architecture term was coined by Jeffrey Palermo in 2008.
This architecture provides a better way to build applications for better testability,
maintainability, and dependability on the infrastructures like databases and
services.
This architecture's main aim is to address the challenges faced with 3-tier
architecture or n-tier architecture, and to provide a solution for common problems,
like coupling and separation of concerns. There are two types of coupling - tight
coupling and loose coupling.
This architecture relies heavily on the Dependency Inversion Principle.
Tight Coupling
When a class is dependent on a concrete dependency, it is said to be tightly
coupled to that class.
A tightly coupled object is dependent on another object; that means changing one
object in a tightly coupled application, often requires changes to a number of other
objects.
It is not difficult when an application is small but in an enterprise level application,
it is too difficult to make the changes.
Loose Coupling
It means two objects are independent and an object can use another object
without being dependent on it.
It is a design goal that seeks to reduce the inter-dependencies among components
of a system with the goal of reducing the risk that changes in one component will
require changes in any other component.
Layering
This is 4 layer architecture.
Type Project Name
API Layer ProjectOnion.Http
Business Layer ProjectOnion.Service
Repository Layer ProjectOnion.Repository
Middleware ProjectOnion.MongoDB
Domain Entity ProjectOnion.Model
Data Flow Diagram
Public Layer Private Layer
API Controllers
API Loggers
View Models
Business Logic
Utility Services
Data
Manipulator
Data
Provider
Models
Utilities
Constants
ProjectOnion.Http
Middlewares
ProjectOnion.Model
ProjectOnion.Repository
ProjectOnion.MongoDB
ProjectOnion.Service
Implement Onion Architecture
To implement the Onion Architecture in the ASP.NET Core application, create five
projects as described in the above section. These five projects represent five layers
of the onion architecture. Let’s see each one by one.
Domain Entities Layer ProjectOnion.Model
This is Infrastructure Layer for all the projects in the service and repository.
What are the things this layer contains?
Entity
Interfaces
Base
Entity
Model
Project
Models
Global
Constant
Extensions Serializers
This is how it looks.
Middleware ProjectOnion.MongoDB
This is the layer which will communicate with the database and gives you results based
on that.
What are the things this layer contains?
Mongodb Interface Mongodb Provider
This is how it looks.
1. Task<IEnumerable<TEntity>> GetAll()
2. Task<TEntity> Get(Guid objectId)
3. Task<IEnumerable<TEntity>> Get(FilterDefinition<TEntity> filters)
4. Task<IEnumerable<TEntity>> Get(FilterDefinition<TEntity> filters,
FindOptions<TEntity> options)
5. Task<TEntity> Insert(TEntity entityObject)
6. Task<TEntity> Update(TEntity entityObject)
7. Task<TEntity> Upsert(TEntity entityObject)
8. Task<DeleteResult> Remove(Guid objectId)
9. void RemoveCollection()
10. Task<long> Count(TEntity instance);
Middleware Methods ProjectOnion.MongoDB
Repository Layer ProjectOnion.Repository
The layer is intended to create an Abstraction layer between the Middleware and
Business Logic layer of an application.
Entity
Implementation
Interfaces Repositories
This is how it looks.
We create a generic repository, which queries the data
source for the data, maps the data from the data
source to a business entity and persists changes in the
business entity to the data source.
1. Task<IEnumerable<TEntity>> GetAll()
2. Task<TEntity> Get(Guid objectId)
3. Task<TEntity> Insert(TEntity entityObject)
4. Task<TEntity> Update(TEntity entityObject)
5. Task<DeleteResult> Remove(TEntity entityObject)
6. Task<long> Count(TEntity instance);
Repository Layer Methods ProjectOnion.Repository
Business Layer ProjectOnion.Service
The layer is intended to create an Abstraction layer between the Repository layer and
Web Api Layer of an application.
Entity
Implementation
Interfaces Repositories
This is how it looks.
It holds business logic for an entity so it’s called
business logic layer as well.
1. Task<IEnumerable<TEntity>> GetAll()
2. Task<TEntity> Get(Guid objectId)
3. Task<TEntity> Insert(TEntity entityObject)
4. Task<TEntity> Update(TEntity entityObject)
5. Task<DeleteResult> Remove(TEntity entityObject)
6. Task<long> Count(TEntity instance);
Business Layer Methods ProjectOnion.Service
API Layer ProjectOnion.Http
This layer has an implementation of the Dependency Inversion Principle so that
application builds a loosely coupled application.
Dependencies View Models
Web API
Controllers
This is how it looks.
It communicates to internal layer via interfaces.
You can divide Web API’s into different versions.
Or even create Entity Model Conversion for
converting one model layer to another.
I have used this approach to reduce my work.
Dependency Injection
ProjectOnion.Http.ServiceDependencyProvider.cs
This will be the class to inject application dependencies.
Setting Client IP ProjectOnion.Http.EntityController.cs
Setting Added and Modified Date
ProjectOnion.Http.Model.cs
Application Startpage ProjectOnion
You will see this application start page.
Upcoming changes.
● Implement swagger for api documentation.
● Unit Test Environment
● Integration Test Environment
● Scenario Test Environment
● Middleware for Relational Database
My References
“Onion Architecture can be a default approach for building enterprise
applications.”
http://jeffreypalermo.com/blog/the-onion-architecture-part-1/
https://www.c-sharpcorner.com/article/onion-architecture-in-asp-net-core-mvc/
Find the Git Repo for Code:
https://github.com/abhinav2127/ProjectOnion
PPT Link:
Project onion - Project Architecture for .Net Core Application

More Related Content

What's hot

Clean architecture with ddd layering in php
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in php
Leonardo Proietti
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
Zahra Heydari
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design Patterns
Michael Heron
 
Mikrofrontend a Module Federation
Mikrofrontend a Module FederationMikrofrontend a Module Federation
Mikrofrontend a Module Federation
The Software House
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
Surendra Shukla
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
Andreas Enbohm
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
Bhavin Shah
 
Laravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web ArtisansLaravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web Artisans
Windzoon Technologies
 
Clean architecture
Clean architectureClean architecture
Clean architecture
Travis Frisinger
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable Design
Victor Rentea
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
Asma CHERIF
 
What is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | EdurekaWhat is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | Edureka
Edureka!
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
Santosh Kumar Kar
 
Micro-frontend
Micro-frontendMicro-frontend
PHP, Java EE & .NET Comparison
PHP, Java EE & .NET ComparisonPHP, Java EE & .NET Comparison
PHP, Java EE & .NET Comparison
Haim Michael
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferences
Ajay Panchal
 
React Architecture & Best Practices.pptx
React Architecture & Best Practices.pptxReact Architecture & Best Practices.pptx
React Architecture & Best Practices.pptx
AleksandarKondov
 
Gaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docxGaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docx
Gaganjot kaur
 
INTRODUCTION TO FLUTTER BASICS.pptx
INTRODUCTION TO FLUTTER BASICS.pptxINTRODUCTION TO FLUTTER BASICS.pptx
INTRODUCTION TO FLUTTER BASICS.pptx
20TUCS033DHAMODHARAK
 
React native
React nativeReact native

What's hot (20)

Clean architecture with ddd layering in php
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in php
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design Patterns
 
Mikrofrontend a Module Federation
Mikrofrontend a Module FederationMikrofrontend a Module Federation
Mikrofrontend a Module Federation
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Laravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web ArtisansLaravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web Artisans
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable Design
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
What is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | EdurekaWhat is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | Edureka
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Micro-frontend
Micro-frontendMicro-frontend
Micro-frontend
 
PHP, Java EE & .NET Comparison
PHP, Java EE & .NET ComparisonPHP, Java EE & .NET Comparison
PHP, Java EE & .NET Comparison
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferences
 
React Architecture & Best Practices.pptx
React Architecture & Best Practices.pptxReact Architecture & Best Practices.pptx
React Architecture & Best Practices.pptx
 
Gaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docxGaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docx
 
INTRODUCTION TO FLUTTER BASICS.pptx
INTRODUCTION TO FLUTTER BASICS.pptxINTRODUCTION TO FLUTTER BASICS.pptx
INTRODUCTION TO FLUTTER BASICS.pptx
 
React native
React nativeReact native
React native
 

Similar to Project onion - Project Architecture for .Net Core Application

Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
David McCarter
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
Stefano Paluello
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast track
Binu Bhasuran
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
naveen kumar
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Enea Gabriel
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity Framework
Akhil Mittal
 
.Net template solution architecture
.Net template solution architecture.Net template solution architecture
.Net template solution architecture
Diogo Gonçalves da Cunha
 
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource GroupLINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
Shahzad
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
Darwin Biler
 
Build Business Web Applications with PHPOpenbiz Framework and Cubi Platform
Build Business Web Applications with PHPOpenbiz Framework and Cubi PlatformBuild Business Web Applications with PHPOpenbiz Framework and Cubi Platform
Build Business Web Applications with PHPOpenbiz Framework and Cubi Platform
Agus Suhartono
 
REACTJS.pdf
REACTJS.pdfREACTJS.pdf
REACTJS.pdf
ArthyR3
 
TheSpringFramework
TheSpringFrameworkTheSpringFramework
TheSpringFramework
Shankar Nair
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
Sam Nasr, MCSA, MVP
 
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Akhil Mittal
 
Data access
Data accessData access
Data access
Joshua Yoon
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
Gary Pedretti
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
Ravi Mone
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
s4al_com
 
Ef Poco And Unit Testing
Ef Poco And Unit TestingEf Poco And Unit Testing
Ef Poco And Unit Testing
James Phillips
 
Domain Driven Design for Angular
Domain Driven Design for AngularDomain Driven Design for Angular
Domain Driven Design for Angular
Jennifer Estrada
 

Similar to Project onion - Project Architecture for .Net Core Application (20)

Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast track
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity Framework
 
.Net template solution architecture
.Net template solution architecture.Net template solution architecture
.Net template solution architecture
 
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource GroupLINQ 2 SQL Presentation To Palmchip  And Trg, Technology Resource Group
LINQ 2 SQL Presentation To Palmchip And Trg, Technology Resource Group
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
 
Build Business Web Applications with PHPOpenbiz Framework and Cubi Platform
Build Business Web Applications with PHPOpenbiz Framework and Cubi PlatformBuild Business Web Applications with PHPOpenbiz Framework and Cubi Platform
Build Business Web Applications with PHPOpenbiz Framework and Cubi Platform
 
REACTJS.pdf
REACTJS.pdfREACTJS.pdf
REACTJS.pdf
 
TheSpringFramework
TheSpringFrameworkTheSpringFramework
TheSpringFramework
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
 
Data access
Data accessData access
Data access
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
 
Ef Poco And Unit Testing
Ef Poco And Unit TestingEf Poco And Unit Testing
Ef Poco And Unit Testing
 
Domain Driven Design for Angular
Domain Driven Design for AngularDomain Driven Design for Angular
Domain Driven Design for Angular
 

Recently uploaded

Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 

Recently uploaded (20)

Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 

Project onion - Project Architecture for .Net Core Application

  • 1. Project Onion Project Architecture By Abhinav Jha Created On: 7th March 2018
  • 2. What Is Onion Architecture? The Onion Architecture term was coined by Jeffrey Palermo in 2008. This architecture provides a better way to build applications for better testability, maintainability, and dependability on the infrastructures like databases and services. This architecture's main aim is to address the challenges faced with 3-tier architecture or n-tier architecture, and to provide a solution for common problems, like coupling and separation of concerns. There are two types of coupling - tight coupling and loose coupling. This architecture relies heavily on the Dependency Inversion Principle.
  • 3. Tight Coupling When a class is dependent on a concrete dependency, it is said to be tightly coupled to that class. A tightly coupled object is dependent on another object; that means changing one object in a tightly coupled application, often requires changes to a number of other objects. It is not difficult when an application is small but in an enterprise level application, it is too difficult to make the changes.
  • 4. Loose Coupling It means two objects are independent and an object can use another object without being dependent on it. It is a design goal that seeks to reduce the inter-dependencies among components of a system with the goal of reducing the risk that changes in one component will require changes in any other component.
  • 5. Layering This is 4 layer architecture. Type Project Name API Layer ProjectOnion.Http Business Layer ProjectOnion.Service Repository Layer ProjectOnion.Repository Middleware ProjectOnion.MongoDB Domain Entity ProjectOnion.Model
  • 6. Data Flow Diagram Public Layer Private Layer API Controllers API Loggers View Models Business Logic Utility Services Data Manipulator Data Provider Models Utilities Constants ProjectOnion.Http Middlewares ProjectOnion.Model ProjectOnion.Repository ProjectOnion.MongoDB ProjectOnion.Service
  • 7. Implement Onion Architecture To implement the Onion Architecture in the ASP.NET Core application, create five projects as described in the above section. These five projects represent five layers of the onion architecture. Let’s see each one by one.
  • 8. Domain Entities Layer ProjectOnion.Model This is Infrastructure Layer for all the projects in the service and repository. What are the things this layer contains? Entity Interfaces Base Entity Model Project Models Global Constant Extensions Serializers This is how it looks.
  • 9. Middleware ProjectOnion.MongoDB This is the layer which will communicate with the database and gives you results based on that. What are the things this layer contains? Mongodb Interface Mongodb Provider This is how it looks.
  • 10. 1. Task<IEnumerable<TEntity>> GetAll() 2. Task<TEntity> Get(Guid objectId) 3. Task<IEnumerable<TEntity>> Get(FilterDefinition<TEntity> filters) 4. Task<IEnumerable<TEntity>> Get(FilterDefinition<TEntity> filters, FindOptions<TEntity> options) 5. Task<TEntity> Insert(TEntity entityObject) 6. Task<TEntity> Update(TEntity entityObject) 7. Task<TEntity> Upsert(TEntity entityObject) 8. Task<DeleteResult> Remove(Guid objectId) 9. void RemoveCollection() 10. Task<long> Count(TEntity instance); Middleware Methods ProjectOnion.MongoDB
  • 11. Repository Layer ProjectOnion.Repository The layer is intended to create an Abstraction layer between the Middleware and Business Logic layer of an application. Entity Implementation Interfaces Repositories This is how it looks. We create a generic repository, which queries the data source for the data, maps the data from the data source to a business entity and persists changes in the business entity to the data source.
  • 12. 1. Task<IEnumerable<TEntity>> GetAll() 2. Task<TEntity> Get(Guid objectId) 3. Task<TEntity> Insert(TEntity entityObject) 4. Task<TEntity> Update(TEntity entityObject) 5. Task<DeleteResult> Remove(TEntity entityObject) 6. Task<long> Count(TEntity instance); Repository Layer Methods ProjectOnion.Repository
  • 13. Business Layer ProjectOnion.Service The layer is intended to create an Abstraction layer between the Repository layer and Web Api Layer of an application. Entity Implementation Interfaces Repositories This is how it looks. It holds business logic for an entity so it’s called business logic layer as well.
  • 14. 1. Task<IEnumerable<TEntity>> GetAll() 2. Task<TEntity> Get(Guid objectId) 3. Task<TEntity> Insert(TEntity entityObject) 4. Task<TEntity> Update(TEntity entityObject) 5. Task<DeleteResult> Remove(TEntity entityObject) 6. Task<long> Count(TEntity instance); Business Layer Methods ProjectOnion.Service
  • 15. API Layer ProjectOnion.Http This layer has an implementation of the Dependency Inversion Principle so that application builds a loosely coupled application. Dependencies View Models Web API Controllers This is how it looks. It communicates to internal layer via interfaces. You can divide Web API’s into different versions. Or even create Entity Model Conversion for converting one model layer to another. I have used this approach to reduce my work.
  • 16. Dependency Injection ProjectOnion.Http.ServiceDependencyProvider.cs This will be the class to inject application dependencies.
  • 17. Setting Client IP ProjectOnion.Http.EntityController.cs
  • 18. Setting Added and Modified Date ProjectOnion.Http.Model.cs
  • 19. Application Startpage ProjectOnion You will see this application start page.
  • 20. Upcoming changes. ● Implement swagger for api documentation. ● Unit Test Environment ● Integration Test Environment ● Scenario Test Environment ● Middleware for Relational Database
  • 21. My References “Onion Architecture can be a default approach for building enterprise applications.” http://jeffreypalermo.com/blog/the-onion-architecture-part-1/ https://www.c-sharpcorner.com/article/onion-architecture-in-asp-net-core-mvc/ Find the Git Repo for Code: https://github.com/abhinav2127/ProjectOnion PPT Link: