Skip to main content

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
204 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 -> ...
1 vote
2 answers
277 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 ...
14 votes
2 answers
13k views

Onion architecture vs 3 layered architecture

I see only benefits to the onion architecture over the 3 layered architecture where the BL had responsibility to call methods on DAL (or an interface of DAL) to do CRUD. The onion has better ...
1 vote
1 answer
149 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 ...
2 votes
3 answers
416 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 ...
10 votes
1 answer
5k views

Where should I place configuration classes in Onion Architecture

We are redesigning one of our API projects from an n-layered architecture into onion architecture. In the previous design, we had configuration classes in a common library project being referenced ...
1 vote
1 answer
174 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: ...
2 votes
3 answers
539 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 ...
1 vote
2 answers
325 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 ...
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 ...
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: ...
132 votes
7 answers
73k views

Clean Architecture: Use case containing the presenter or returning data?

The Clean Architecture suggests to let a use case interactor call the actual implementation of the presenter (which is injected, following the DIP) to handle the response/display. However, I see ...
4 votes
2 answers
3k views

why exposing service instead of repository in onion architecture

I'm digging on how to structure projects and so I stumble into Onion Architecture. As to how I understand it, its more on a domain-centered-focus architecture instead of a database-driven type. I'm ...
2 votes
2 answers
470 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 ...
0 votes
0 answers
120 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 ...
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 ...
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 ...
1 vote
2 answers
650 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 ...
7 votes
2 answers
8k 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 ...
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 ...
0 votes
1 answer
3k 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 ...
3 votes
3 answers
3k views

Architecture: How to pass models between controllers, services and repositories

I'm trying to build an architecture where I have a Domain project with all my domain models, an Infrastructure project with my Services and Infrastructure.Entity with my Repositories and entities. ...
5 votes
2 answers
12k views

How to structure a Domain Driven Design in an Onion Architecture?

I am studying Domain Driven Design and was introduced to the concept of Onion Architecture, which uses the terms of Core, Domain, API, and Infrastructure. I am from Java background and am familiar ...
0 votes
3 answers
767 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 ...
-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 ...
1 vote
2 answers
920 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, ...
-1 votes
3 answers
974 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) \ --- ...
1 vote
1 answer
861 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 ...
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 ...
6 votes
3 answers
525 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 ...
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 ...
0 votes
1 answer
162 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 ...
0 votes
1 answer
146 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 ...
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 ...
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 ...
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 ...
-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 ...
1 vote
0 answers
111 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 ...
-3 votes
1 answer
314 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 ...
-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 ...
1 vote
1 answer
363 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 ...
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 ...
0 votes
0 answers
103 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, ...
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 / ...
1 vote
1 answer
845 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 ...
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 ...
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 ...
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 ...
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) ...
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 ...