Vertical Slice Architecture - Jimmy Bogard
Why Stack Overflow recommends it
Stack Overflow users link it when answering .NET architecture questions about layers, CQRS with MediatR, folder structure and DRY, as the standard introduction to vertical slices.
Recommended by 4 people across 6 different months, 2018 to 2025.
What it is
A conference talk by Jimmy Bogard (creator of MediatR and AutoMapper) at NDC Sydney on moving from layered architecture to vertical slice architecture. It covers patterns, tools and techniques for slices, how CQRS and DDD fit, and how slices apply to MVC, SPA and desktop apps.
What people said
Strong rec Michał K. · 2018-12 · Stack Overflow · on “What happens if we don't use DTOs in our API?”
I can't agree. Not all long running projects must have layered architecture. You should watch Jimmy Bogard talk about vertical slice architecture. It's absolutely beautiful and simple. And this is a best part - He have Github with complete solution how to. So it's not only theoretical. [this video]
Recommends Leaky · 2021-03 · Stack Overflow · on “Is it appropriate to use IHttpcontextAccessor in service layer?”
In my experience, in ASP.NET developers tend not to worry much about these segregation concerns (nor about e.g. anemic domains). In most systems, especially smaller ones, there is a lot of coupling between the business logic and the API; for example through the use of filters and middleware. So, in this sense it can be seen as 'appropriate', as long as it doesn't block you from an important project requirement, for example being able to run the application core independently of the API. But if you want to architect your solution in a decent and modern way, it makes sense to avoid doing things like this. Straightforward solution One straightforward solution is to extract the given data into a
Recommends Tore Nestenius · 2021-11 · Stack Overflow · on “Does we need keep Business Logic Layer when we use CQRS + MediatR in net core?”
No, you don't need to keep the BLL or DAL layer when you move to a CQRS + MediatR based architecture. I recommend that you look into vertical slices architecture combined with CQRS/MediatR. See these videos: Vertical Slice Architecture - Jimmy Bogard [this video] Restructuring to a Vertical Slice Architecture [LINK] Think an important rule is that you should aim for is code that changes together should also be located together.
Recommends Guru Stron · 2022-12 · Stack Overflow · on “dotnet core API folder structure”
I just wonder how everyone suggest doing it, or if there's an official way to do it that I'm ignoring There is no one right approach, there are ones that can work for you, your team and your project. As for "official" guides - you can look into Common web application architectures [LINK] guide from Microsoft. It mentions several popular options: Traditional "N-Layer" architecture applications [LINK] Clean architecture [LINK] (which I would argue is quite similar to Hexagonal Architecture and Onion architecture which are based more or less on the same concept, but differs in terms and nuances) There are multiple resources on those you can read about those. One more which is worth mentioning i
Recommends Guru Stron · 2022-12 · Stack Overflow · on “Type and namespace naming when the type and namespace are the same”
Both approaches can be used (personally I would go with second one if selecting from the two), but there are other possibilities worth considering: Add Entities suffix to the namespace name i.e. Company.Entities.CustomerEntities . Switch from the "group by type" approach (i.e. root level folders for entities/repos/controllers/views etc.) to Vertical Slice Architecture [LINK] ( video presentation [this video] )/Feature Folders approach which personally I've grown fond of over the last years (see this [LINK] , this [LINK] and this [LINK] ).
Recommends Guru Stron · 2023-03 · Stack Overflow · on “The Clean Architecture and the dependency rule for the 3rd and 4th layer”
But that means that the 3rd layer knows about the 4th one, since it's asking something from it. No. 3rd layer does not need to directly depend on and/or know about 4th layer. 3rd layer uses gateways to interact with database, i.e. it declares contracts which are implemented in 4th layer. So for example you can have a repository interface declared on this level, but actual implementation is done on the 4th, so 3rd layer actually does not know anything about SQL, or even outbound HTTP/GRPC/GraphQL requests (which can also be used to query for data in some cases). P.S. If you are looking into different architecture approaches I would also recommend to look into Vertical Slice Architecture [LINK
Recommends Guru Stron · 2023-07 · Stack Overflow · on “Does Vertical Slice Architecture Violate the DRY Principle?”
Vertical Slice Architecture does not mean you can't share things between slices (but you do not share "by default") You still can use some shared domains, helper methods, etc. For instance, user authentication information might be needed in multiple slices Authentication is so called cross-cutting and cross-cutting concerns (auth, logging, monitoring, etc.) usually are another dimension which is handled separately (i.e. the login/logout itself is a feature but the authentication information and authorization is a cross-cutting concern which is shared, if you imagine handling request as pipeline it will be "before" the feature slices) There is a common misconception about DRY principle you sh
Cites Leaky · 2021-03 · Stack Overflow · on “Is using CQRS with not separated services and repositories really affecting the quality of code?”
Admittedly I'm not a veteran software developer, but I thought a lot about this subject in recent months, and the following are my observations and conclusions. You're quite right to think that CQRS is more involved than prefixing some MediatR-consumed classes as 'commands', and others as 'queries'. Unfortunately, for some reason I don't understand, people started to equate MediatR with CQRS recently, even though Jimmy Bogard usually talks about MediatR in the context of vertical slice architecture [this video] . Vertical slicing The general benefits come from the fact that you're creating vertical slices instead of using a traditional, layered, service-heavy approach. This decouples the use case
Cites Luke George · 2025-01 · Stack Overflow · on “How to update an entity when implementing DDD using the repository and unit of work patterns with ASP.NET MVC?”
I think your questions arise from the architecture you propose. One big concern about your solution is encapsulation: who does what? The repository pattern should abstract the data access layer to the consumer. So the consumer is essentially telling the interface: I want you to update this entity in the database, how you do that is none of my business. But in your implementation you assume that the object returned by FindById is EF tracked and therefore can track changes in your MVC controller. This is a leaky abstraction. If we don't follow this logic, FindById will return an entity that is not tracked by EF. The entity will be updated in the MVC controller and then the repository's Update