Skip to content

Vertical Slice Architecture and Clean Architecture

The Vertical Slice Architectural conceptually organises code around specific use cases, distinct features or technical concerns. It is implemented across all layers of the software from UI to back-end or database interfaces, and is often used to help make the development complex and feature rich applications easier.

The Vertical Slice Architectural style organises code into feature folders, so each feature resides under its own base folder in the source tree and cuts through all layers.

A traditional n-tier or layered architecture would divide the application horizontally, for example by presentation, business logic and data layers.

Clean Architecture by comparison focuses on separation of concerns and dependency roles. It organises code into layers with the most stable and business agnostic layers at the centre of the entities and use cases, with external concerns such as UI and data access layers on the outer layers.

By comparison a vertical slice architecture is divided into feature slices with each slice being self contained and independent. This results in fewer dependencies between different parts of the application, each slice is almost a mini-application which handles a specific piece of functionality and communicates with other services through well defined interfaces, so is suited for cross-functional teams, is more easily scalable and easier to maintain. These slices can also be more easily individually tested and deployed as a result with each team focusing on delivering a complete feature.

The downside of this is that a Clean Architecture approach is more structured and ensures business logic is decoupled from external concerns. This can be more beneficial for long term maintainability and can be more scalable.

Vertical Slice Architecture lends itself better for agile teams working on complex applications with many features tht may change or evolve independently over time. For such applications this can provide for easier maintenance as the application adapts to changes but leaves the core business logic largely untouched.

When to use Vertical Slice Architecture (VSA)

  • Rapid Development and Deployment where features are developed independently.
  • Agile and Scrum Teams that need to deliver independent complete features in short cycles.
  • Microservices where each service is often responsible for a distinct feature or business requirement.

The final choice comes down to the work that needs to be delivered. While VSA is more agile and works well with rapid development and deployment, CA is better suited for large scale long lived applications where the business rules must remain protected from external changes.

Both approaches can be used by Microservices.