Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [onion-architecture]

The *Onion Architecture* is a software architecture proposed by Jeffrey Palermo. It is similar to the *Hexagonal Architecture* (Ports and Adapters) proposed by Alistair Cockburn.

Filter by
Sorted by
Tagged with
1 vote
1 answer
175 views

Onion Architecture: Where to put Hangfire specific logic

We have a .net core app with the following folder / onion structure: WidgetApp -> Core -> Application -> JobAutoStarter -> JobAutoStarter.cs WidgetApp -> Core -> Domain -> ...
dot's user avatar
  • 571
1 vote
2 answers
264 views

How to structure libraries/solution for Onion Architecture with Model View Presenter pattern?

Hobby coder here, so please be gentle! My coding is taking me into the necessary realms of architecture due to increasingly complex apps. I'm wondering how to structure my solutions which will involve ...
stigzler's user avatar
  • 129
1 vote
1 answer
143 views

Where to perform conditional mapping in Domain Driven Design?

How can I do conditional mapping in Domain Driven Design? Let's say my application is structured like this: - Core - Domain - Application - Presentation - DTOs - API I have an aggregate root ...
J.Kirk.'s user avatar
  • 121
2 votes
3 answers
414 views

Is having many build-once factories a sign of bad dependency injection design?

I have a form. It contains things like grids. Users do things with these grids and what they do with them is sent to a SQL server. Clearly, the server is a volatile dependency and should be dependency ...
J. Mini's user avatar
  • 1,017
1 vote
1 answer
172 views

deciding where to put "formatting" logic - database or in application layer

We have an application that fetches user data from an Azure tenant via MS Graph. We need to distinguish between guests and regular members. Guests come back with Usernames that look like this: ...
dot's user avatar
  • 571
2 votes
3 answers
508 views

Why is the dependency flow in the onion architecture are the way they are?

Why does the infrastructure layer depend on the application layer, and the application layer depend on the domain layer in the onion architecture ? In its definition, the dependency flow inwards. But ...
EEAH's user avatar
  • 174
2 votes
1 answer
2k views

onion architecture - calling external APIs

Umbrella Question In an onion architecture, where do all the components needed to consume an external API fit in? The following is the architecture I have so far, based off an example found here: ...
dot's user avatar
  • 571
1 vote
2 answers
323 views

Where to save entity metadata in a Ports-And-Adapters Architecture

I’m using a hexagonal/clean/ports-and-adapter architecture. For the sake of simplicity, I’ll only talk about domain and infrastructure here, where the infrastructure has dependencies on the domain but ...
Mirco's user avatar
  • 661
2 votes
2 answers
450 views

High level 'implementation' of a use case in a layered/DDD architecture

I am trying to understand layered architectures and apply some DDD fundamentals to improve my architecture. I am finding that determining "what" an application service actually is, what its ...
Patrick Christie's user avatar
0 votes
0 answers
118 views

Identify Domain Entities for a search tool interface - Clean Architecture

I am pretty new to Clean Architecture / Onion Achitecture, I actually not sure if the 2 terms are exchangeable. So it pretty clear to me, considering is a few days I am reading and study about it. It ...
Carmine Tambascia's user avatar
1 vote
3 answers
6k views

Mapping to and from domain entities

I am in the process of implementing onion / clean architecture, and would like to understand better how and when to map to my domain entities. So if we take a specific example where we have a Post and ...
dendog's user avatar
  • 201
0 votes
2 answers
2k views

Onion architecture: Dependency Inversion Principle within the Service layer

I'm trying to implement a project using the Onion Architecture (aka Hexagonal, aka Ports and Adapters, aka Clean Architecture). I understand that the user interface uses Service interfaces instead of ...
Quido's user avatar
  • 326
0 votes
1 answer
2k views

Encapsulation of External API in Infrastructure Layer AS Persistence

My question is about DDD, the Infrastructure layer, it's relation to the Domain, and specifically how we can take advantage of the ability to "swap out" one persistence implementation for ...
apriestley's user avatar
7 votes
2 answers
7k views

What layer do third party API request/response models go in and what do you call them?

I have a RESTful API service that has three layers: Application/Domain, Infrastructure, and Presentation. Application/Domain contain my interfaces and models. I currently have three different types of ...
brandon d tran's user avatar
1 vote
2 answers
643 views

Catch "foreign" exception in adapter and convert them in own business exception is a good practice?

I am currently thinking about some design choices regarding exception handling. My current architecture looks a little like this: You can see that I have a UI where a try-catch middleware is cathing ...
David Mason's user avatar
0 votes
3 answers
747 views

Pattern for passing request context to business logic

I'm working on a project in which I have a clear separation between domain logic and the logic that exposes these features using an API (or whatever). For this I'm using the Onion Architecture. Now I ...
Quido's user avatar
  • 326
1 vote
2 answers
906 views

Where to put a deffiniton of an external data provider in a DDD/Onion Architecture application?

Consider that when working on an Application which is modelled using DDD and implemented using Onion Architecture, you come along a following business case: The Application, as one of its features, ...
nix's user avatar
  • 533
-1 votes
2 answers
196 views

How to avoid CRUD and layered architectures in REST backends?

I'm creating a .Net 5 API backend and use EF Core for the database part. The simple CRUD way I know: API layer calling a command or query from the application layer using MediatR Application layer ...
Question3r's user avatar
77 votes
11 answers
20k views

Is it really possible to decouple the UI from the business logic?

I'm reading about software architectures like Hexagonal architecture, Onion architecture etc. They put a big emphasis on decoupling. The business logic sits at the centre and the UI sits on the ...
MSOACC's user avatar
  • 945
-1 votes
3 answers
951 views

Preventing presentation layer from directly accessing repositories?

I'm trying to design my application in line with the "onion architecture" principles, and have something like the following: HospitalController (depends on IHospitalService) \ --- ...
Jez's user avatar
  • 1,318
1 vote
1 answer
856 views

How do proto models in gRPC fit into Clean Architecture

I know they say that clean architecture are guidelines, and individual projects will affect implementation, but is there a general thought on the correct implementation? A lot of times I see DTO ...
Jhorra's user avatar
  • 147
0 votes
3 answers
1k views

Do adapters get only called by usecases?

Suppose we have a layered architecture like onion architecture or clean architecture with three modules representing each layer: domain.py usecase.py databaseadapter.py The domain layer contains the ...
David's user avatar
  • 133
3 votes
1 answer
3k views

How should infrastructure be able to reference repository interfaces in onion architecture?

In Jeffrey Palermo's article about Onion Architecture, he claims the following: The first layer around the Domain Model is typically where we would find interfaces that provide object saving and ...
octagon_octopus's user avatar
0 votes
1 answer
159 views

Architecture Layers - Interface project at the top

We have structured our application with typical layers. UI, Database access, services, Helpers etc. However, at the very top we have a project called "Interfaces" which contains the ...
Zuldaan's user avatar
  • 99
0 votes
1 answer
145 views

Mutli tenant app with onion architecture and multiple presentations

Currently I started designing a new multi tenant SaaS application based on the onion architecture in C# Using a rest web API to expose my services and consume them on 3 platforms. Two web apps (one ...
Jesse's user avatar
  • 193
1 vote
1 answer
1k views

Event logging - per Aggregate or one per Bounded Context?

I'm working on an application (using Onion Architecture) and I want to have good log of entities' changes. I'm struggling to find any good examples of what are the best practices - and I want to ...
Maciej Pszczolinski's user avatar
1 vote
2 answers
1k views

How to organize database access logic for the infrastructure and application layer when avoiding ORM tools?

I'm trying create a .NET Core project and followed some guides to create a basic architecture Jason Taylor - Clean Architecture with ASP.NET Core 3.0 Sample project Clean Architecture Template I'm ...
Question3r's user avatar
1 vote
0 answers
110 views

Am I structuring this correctly for a .net mvc web app based on onion architecture?

]1 I am new to MVC. Most of my career I have used Web Forms in Asp.net. Reading about MVC has been really confusing because from what I have learnt is that in Traditional MVC, models were supposed to ...
Emma's user avatar
  • 645
-3 votes
1 answer
310 views

What is the simplest version of best practice application architecture for a backend in C# and ASP.NET Core WebAPI?

I know that in some contexts, best practice would be DDD, CQRS and EventSourcing, but in my case this would be too complicated of two reasons: My team is beginners, and we want them to be productive ...
Terje Kolderup's user avatar
-2 votes
1 answer
556 views

What is a simple implementation of onion architecture for C# ASP.NET Core WebAPI and SQL db that is not full DDD and CQRS?

I'm a programming teacher. My students learn structured and then object oriented programming in JavaScript and C#. They learn SQL, MS SQL Server, Dapper and EntityFramework Core. After this they ...
Terje Kolderup's user avatar
1 vote
1 answer
358 views

Define input and output interfaces for each application layer

I want to create a multi-layered backend architecture with a REST layer and GraphQL layer later on. So let's say you would start with the basic layers controller, service, repository would it make ...
Question3r's user avatar
6 votes
3 answers
523 views

Where to convert primitive types in meaningful types in Clean Architecture / Onion Architecture

The book "Implementing Domain Driven Design" (page 361) suggests to use special types to distinguish several kinds of IDs, e. g. using BookId(1) instead of just 1 of type Int or Long. In my Clean ...
deamon's user avatar
  • 876
10 votes
1 answer
7k views

Error handling in Nest service layer

I would like to create a REST API with NestJs. But I want to add GraphQL as another top level layer later on. So for the start I have the basic layers controller, service and TypeORM repository. Let's ...
hrp8sfH4xQ4's user avatar
8 votes
2 answers
7k views

Avoiding Repository pattern - implementing Onion Architecture with DbContext only

I am trying to follow the Onion Architecture to design my application where I have the following layers - Domain Layer: is the inner-most layer and defines repository interfaces Infrastructure ...
atiyar's user avatar
  • 203
0 votes
0 answers
102 views

Instantiating adapters in onion architecture

GitHub and NuGet Do you use connection strings to instantiate your adapter services or just always configure it through IoC? I think that connection strings could provide a way more flexibility, ...
Dmitry Nogin's user avatar
3 votes
1 answer
2k views

Onion Architecture: Should Service Layer contain DB Context?

In Onion Architecture, we have repository layer which conducts Crud Operations (simple insert, delete, update). (Applying Entity Framework with database) Onion Architecture Additionally , we have ...
GregDavis's user avatar
5 votes
1 answer
1k views

FP Free Monad vs OOP Dependency Injection

I've written my first moderately large project in functional style (in F#) and can see the advantages. The main challenge was to achieve the "Onion" architecture i.e. large and "smart" pure core / ...
KolA's user avatar
  • 615
1 vote
1 answer
843 views

Data entities in Onion Architecture

I'm trying to build a project using onion architecture (just a "Northwind"ish type app to get more up to speed with .NET Core). I also want to get a better grasp on Onion Architecture principals. I ...
Adam Plocher's user avatar
9 votes
2 answers
9k views

What are application and domain services in onion architecture?

Onion architecture has a core which is composed by domain model, domain services and application services: I'm in doubt about those two service layers, domain services and application services. I've ...
Piovezan's user avatar
  • 481
2 votes
1 answer
3k views

C# .Net Core API design - interfaces vs DTOs

I'm designing a relatively simple web application using .net core. I've mostly done desktop development in my career so far, so I'm a bit new to the nuances between desktop and web development. In ...
Stephen's user avatar
  • 8,838
2 votes
1 answer
1k views

Domain Use Case

In my understanding of Uncle's Bob Clean Architecture, a Use Case (Interactor) is responsible for orchestrating the Entities. At the same time, it represents Application-specific rules. The business ...
grzegorz.kosciolek's user avatar
-1 votes
1 answer
351 views

Onion Architecture - Multiple Apps

Onion Architecture talks about separating the UI, Service, and Data Layers. All the samples usually given for this involve a single deployment model of the application. For example in .net most of the ...
mtron's user avatar
  • 7
0 votes
1 answer
707 views

Am I breaking some Onion Architecture rule?

Based on the project structure below i will have some questions Domain Layer 1) MyApp.Domain.Entities (DLL) Product.cs PagedResult.cs Referentes No References 2) MyApp.Domain.Interfaces (DLL) ...
Harry Axl's user avatar
3 votes
1 answer
4k views

Use case interactions in clean architecture

I'm experimenting with Clean Architecture for my turn-based strategy game project. I have use cases that form hierarchies and need to be coordinated with each other. I would like some advice on how to ...
grzegorz.kosciolek's user avatar
1 vote
1 answer
1k views

Onion architecture applied to an .NET application

I am trying to figure out how to translate the onion architecture into an ASP.NET Core WebAPI solution, this is what I ended up with: Let's say I have an application that takes a file path / uri into ...
Natalie Perret's user avatar
0 votes
2 answers
89 views

Structural problem related to Dependecy Injection and Asynchronous Operations

I'm implementing the onion architecture with webapi, service layer, repository, unit of work and the domain classes. I use also DI, using simple injector. But my issue, is how can I implement a ...
joseFrancisco's user avatar
2 votes
1 answer
1k views

Onion Architecture, Project Architecting and Authentication

I am learning ASP.NET MVC & Web API and trying to implement Onion Architecture with Repository Pattern for one of my Test projects as part of my learning. I have developed single MVC Projects ...
RollsReus's user avatar
3 votes
1 answer
2k views

Reusing business logic layer in multiple applications

I have seen some people asking about sharing business logic with more than one application, and answers generally discuss putting it in a class library. I'm fine with that, but usually the examples ...
Rob L's user avatar
  • 106
0 votes
0 answers
788 views

Clarification on the Onion architecture's Domain Service and Application Service

I am studying Onion Architeture but i got some doubts: All the samples (github) I found over internet are too simple, or are implemented under DDD (which I have not studied at the moment) so I can ...
X.Otano's user avatar
  • 622
21 votes
2 answers
16k views

What data should a repository return

I have a simple project where the controller calls the service, and the service calls the repository in order to get the needed data. Assuming that we have these domain models: // this model has a ...
Uentee's user avatar
  • 401