Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2373 feature add: Vertical Slice Architecture. #2828

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added better explanation and updated README.md
  • Loading branch information
sugan0tech committed Oct 17, 2023
commit 24d5063125b237c4df83c0142c20a379760440a9
43 changes: 30 additions & 13 deletions vertical-slice-architecture/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Vertical-Slice-Architecture
aka: Layer-By-Feature
title: Vertical Slice Architecture
aka: Layer By Feature
sugan0tech marked this conversation as resolved.
Show resolved Hide resolved
category: Architectural
language: en
tag:
Expand All @@ -9,21 +9,38 @@ tag:

## Intent

package the application based on features. Each feature will have its own set of layers (
Models, Services, Repository and Controllers ).
Organize the application according to its features.
Each feature will comprise its distinct set of layers (Models, Services, Repository, and Controllers).

## Explanation

> With vertical slice architecture we can have high cohesion within package and low coupling
> among the packages. In Conceptual term
Real-World Examples (Consider E-commerce)

> Consider that you are going to make a backend service for a online e-commerce application.
> initially you make it with usual grouping of controllers, models etc. but as the application
> grows more it's requires implementation of new features. Let's say that you thought of having
> orders, customers and products associated layers. But now you need to include another set of
> features with Cart system and wishlists. Now it's really hard to integrate those features it
> requires lot's of dependency modifications and mocking. So if you make the package by feature
> it will be really feasible for future additions. General example.
> In the context of an e-commerce application, the concept of vertical slice architecture becomes clear.
> Imagine you're building a backend service for an online store.
> Initially, you may organize it with the typical grouping of controllers, models, and other components.
> As the application grows, the need arises to implement new features.

> For instance, you might have distinct layers for orders, customers, and products. However, as the application
> evolves, you realize the necessity of integrating additional features like a Cart system and wishlists.
> At this point, integrating these new features into the existing structure becomes challenging.
> It demands significant dependency modifications and mocking, which can be time-consuming and error-prone.

> This is where vertical slice architecture proves its value.
> By structuring the application based on features,
> you create self-contained modules that encapsulate all the necessary components
> (Models, Services, Repository, and Controllers) for a particular feature.
> When you need to add new features, you can do so in a more isolated and manageable manner.

In Plain Words

> Vertical slice architecture is like organizing your toolbox.
> Instead of having all your tools mixed together, you group them based on the type of task they perform.
> This way, when you need a specific tool for a particular job,
> you can quickly find it without rummaging through a jumble of items.

> Similarly, in software development, vertical slice architecture involves organizing the codebase based on features.
> Each feature has its own self-contained set of components, making it easier to add, modify, or remove features without disrupting the entire application.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add a minimal code example here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of code examples, can it be project file structure?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we can improvise a bit here. Whatever describes the pattern most effectively.

## Class diagram

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* Main application.
* The main objective of this code sample is for you to have a look at how the view, entity, repository and Service are
* organized.
* No matter what application you are building Layer by Feature will always give the upper hand of better
* maintainability.
* This application is designed with a vertical slice architecture, organizing features such as
* customer management, order processing, and product catalog in separate modules. Each feature encapsulates
* its own set of components (Models, Services, Repository, and Controllers), promoting high cohesion
* within each module and low coupling between them. This architecture allows for seamless integration of new
* features and functionalities as the application evolves over time.
*/

@SpringBootApplication
Expand Down