8000 GitHub - Amitpnk/Vertical-Slice-Architecture: A clean and modular .NET 9 template using Vertical Slice Architecture. Ideal for building scalable, maintainable APIs with CQRS, Mediator DP, FluentValidation, and EF Core/Dapper.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A clean and modular .NET 9 template using Vertical Slice Architecture. Ideal for building scalable, maintainable APIs with CQRS, Mediator DP, FluentValidation, and EF Core/Dapper.

License

Notifications You must be signed in to change notification settings

Amitpnk/Vertical-Slice-Architecture

Repository files navigation

Vertical-Slice-Architecture

.NET Build & Test GitHub license

A clean, modular .NET 9 template using Vertical Slice Architecture — ideal for building scalable, maintainable APIs with CQRS, Mediator Design Pattern, FluentValidation, and EF Core/Dapper.

Give a Star! ⭐

If you like or are using this project to learn or start your solution, please give it a star. Thanks!

Support This Project

If you have found this project helpful, either as a library that you use or as a learning tool, please consider buying me a coffee:

Buy Me A Coffee

What is Vertical Slice Architecture?

Vertical Slice Architecture organizes code by features rather than technical layers. Each “slice” encapsulates all aspects of a specific feature, including the UI, business logic, and data access. This contrasts with traditional architectures that segregate applications into horizontal layers like Controllers, Services, and Repositories.

VA

Figure: Representation of Vertical Slice Architecture emphasizing feature-centric organization. The image above illustrates the concept of Vertical Slice Architecture, where each feature, represented as a vertical slice, integrates all necessary components across the UI, Application, Domain, and Infrastructure layers. This ensures each feature is self-contained and simplifies scaling, testing, and maintaining code

✅ Features

  • Vertical slice structure organized per use case (CQRS style)
  • Minimal API with Carter for clean endpoint definitions
  • Mediator Design Pattern for command/query dispatching (withou MediatR library)
  • FluentValidation for request validation
  • EF Core-based persistence layer (with optional Dapper support)
  • Docker and Docker Compose support
  • Testable, modular, and decoupled architecture

🚀 Getting Started

1. Clone the Repository

git clone https://github.com/Amitpnk/Vertical-Slice-Architecture.git
cd Vertical-Slice-Architecture

2. Build and Run with Docker

To build and start the containers:

docker-compose up --build

To run the containers in detached mode:

docker-compose up -d

Note: Building the Docker image manually is not usually required, but if needed, use:

docker build -f src/VA.API/Dockerfile -t va-api .

3. Rebuild and Restart Containers

If you need to rebuild and restart the containers (for example, after making changes):

docker-compose down -v
docker-compose up --build

4. Open the Application

Once the containers are running, open your browser and navigate to:

http://localhost:5000

You should see the API running. Adjust the port if you have changed it in the Docker configuration.

📁 Project Structure

Vertical-Slice-Architecture/
.github/
    └── workflows/
        └── dotnet.yml
docs/
    ├── gchr.md
    └── README.md
src/
    ├── docker/
        ├── .dockerignore
        ├── docker-compose.dcproj
        ├── docker-compose.override.yml
        ├── docker-compose.yml
        └── launchSettings.json
    ├── VA.API/
        ├── Customers/
            ├── CreateCustomer/
                ├── CreateCustomer.cs
                ├── CreateCustomerCommandHandler.cs
                ├── CreateCustomerCommandValidator.cs
                └── CreateCustomerEndpoint.cs
            ├── DeleteCustomer/
                ├── DeleteCustomer.cs
                ├── DeleteCustomerCommandValidator.cs
                ├── DeleteCustomerEndpoint.cs
                └── DeleteCustomerHandler.cs
            ├── GetCustomerById/
                ├── GetCustomer.cs
                ├── GetCustomerByIdEndpoint.cs
                └── GetCustomerByIdQueryHandler.cs
            ├── GetCustomers/
                ├── GetCustomer.cs
                ├── GetCustomersEndpoint.cs
                └── GetCustomersQueryHandler.cs
            └── UpdateCustomer/
                ├── UpdateCustomer.cs
                ├── UpdateCustomerCommandHandler.cs
                ├── UpdateCustomerCommandValidator.cs
                └── UpdateCustomerEndpoint.cs
        ├── Data/
            ├── CustomerContext.cs
            └── Extentions.cs
        ├── Migrations/
            └── CustomerDb/
                ├── 20250519180837_Init.cs
                ├── 20250519180837_Init.Designer.cs
                └── CustomerContextModelSnapshot.cs
        ├── Models/
            ├── Customer.cs
            ├── CustomerDto.cs
            └── CustomerExtensions.cs
        ├── Properties/
            └── launchSettings.json
        ├── appsettings.Development.json
        ├── appsettings.json
        ├── docker-compose.md
        ├── Dockerfile
        ├── Dockerfile.original
        ├── dotnet-cli.md
        ├── GlobalUsing.cs
        ├── my-sql.md
        ├── Program.cs
        ├── VA.API.csproj
        └── VA.API.http
    └── VA.CrossCutting/
        ├── Behaviors/
            ├── LoggingBehavior.cs
            └── ValidationBehavior.cs
        ├── CQRS/
            ├── Dispatcher.cs
            ├── ICommand.cs
            ├── ICommandHandler.cs
            ├── IDispatcher.cs
            ├── IQuery.cs
            └── IQueryHandler.cs
        ├── Exceptions/
            ├── Handler/
                └── CustomExceptionHandler.cs
            ├── BadRequestException.cs
            ├── InternalServerException.cs
            └── NotFoundException.cs
        ├── Pagination/
            ├── PaginatedResult.cs
            └── PaginationRequest.cs
        └── VA.CrossCutting.csproj
test/
    └── VA.API.Tests/
        ├── Customers/
            └── GetCustomers/
                ├── GetCustomersQueryHandlerTests.cs
                └── GetCustomersQueryTests.cs
        ├── Data/
            └── CustomerContextTests.cs
        ├── Models/
            ├── CustomerDtoTests.cs
            ├── CustomerExtensionsTests.cs
            └── CustomerTests.cs
        └── VA.API.Tests.csproj
.dockerignore
.gitignore
docker-compose.dcproj
docker-compose.override.yml
docker-compose.yml
launchSettings.json
LICENSE
VA.sln

📄 License

GitHub license

This project is licensed under the MIT License — see the LICENSE file for details.

📬 Contact

Having issues or need help getting started? Email amit.naik8103@gmail.com or raise a bug or feature request. Always happy to help.

About

A clean and modular .NET 9 template using Vertical Slice Architecture. Ideal for building scalable, maintainable APIs with CQRS, Mediator DP, FluentValidation, and EF Core/Dapper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 
0