-
The ASP.NET Core template follows the Vertical Slice Architecture (VSA).
-
Please leave everything as default in order to make the scripts work or check out how to customize scripts Here.
-
For explanations about idea and structure of template, please check out Here
-
For more information about each config file, please check out Here
-
For how to start the project, please check out Getting Started
Welcome to the ASP.NET Core Vertical Slice Architecture Template! This template helps you build maintainable, scalable, and testable web applications by organizing code around business features. It addresses the challenges of traditional layered architectures, such as bloated controllers and scattered code, by promoting a modular and feature-centric approach.
In the past, I often followed tutorials to build projects, but I encountered significant challenges with the project structures they suggested. Here are some common issues I faced:
- Long service files: These became difficult to maintain as they grew in size.
- Scattered context: Retrieving all the information related to a feature was challenging because methods and classes were spread across multiple files and folders.
- Fat controllers: Controllers often became bloated and hard to manage.
I realized that this approach, known as technical-based architecture, groups all files of the same type (e.g., services in a Services
folder). While this approach seemed organized, it often led to inefficiencies. To address this, I researched feature-based architecture, which has the following advantages:
- Each feature has its own dedicated folder, making the structure easier to navigate.
- All files related to a feature are stored together, simplifying maintenance.
However, even with a feature-based architecture, I encountered new challenges as the project grew:
- Class naming conflicts: With multiple feature-related classes in one project, it was easy to mistype or confuse class names (e.g.,
FM1Endpoint
vs.FM2Endpoint
).
To solve this, I decided to move each feature into its own class library. This approach makes it impossible to call classes from one feature without explicitly referencing its assembly (e.g., FM1Endpoint
cannot be called from assembly containing FM2Endpoint
), reducing the chances of errors.
And that’s how this template was born!
Ensure you have the following installed:
-
.NET SDK
8.0.404
-
Docker (Any version but at least
20.10.17
)- please make sure it supports docker compose
-
Text editor
(Vs code, fleet,..) orIDE
(Visual Studio 2022, Rider, ...)
Clone this project via this command:
git clone https://github.com/Jackpieking/ASPNET_CORE_VSA_Template.git
cd E:\CODE_PROJECTS\ASPNET_CORE_VSA_Template\
cd /home/CODE_PROJECTS/ASPNET_CORE_VSA_Template/
.\Scripts\Init\init.ps1
./Scripts/Init/init.sh
For example:
Currently, in .env
there is a section at the top expressing docker server IP:
# ======================
# GLOBAL
# ======================
HOST_IP=192.168.56.104
But your docker server IP is 192.168.1.10
, so you must change it to:
# ======================
# GLOBAL
# ======================
HOST_IP=192.168.1.10
docker compose up -d --build
5: Find and update the all parts that have IP
in all files
that start with appsettings
in Src/Entry
folder
For example:
Currently, in appsettings.Development.json
in Src/Entry
ther was a connection string for postgressql database like this:
"Database": {
"Main": {
"ConnectionString": "Server=192.168.56.104; Port=6102; Database=todoappdb; User ID=admin; Password=Admin123@; SSL Mode=Prefer; Pooling=true; Minimum Pool Size=64; Maximum Pool Size=120; Connection Idle Lifetime=300; Connection Lifetime=500",
// ... other settings
}
}
The current postgres server IP is 192.168.56.104
, but your server IP is 192.168.1.10
, so you must change it to:
"Database": {
"Main": {
"ConnectionString": "Server=192.168.1.10; Port=6102; Database=todoappdb; User ID=admin; Password=Admin123@; SSL Mode=Prefer; Pooling=true; Minimum Pool Size=64; Maximum Pool Size=120; Connection Idle Lifetime=300; Connection Lifetime=500",
// ... other settings
}
}
.\Scripts\Run\run.ps1
./Scripts/Run/run.sh
.\Scripts\Build\build.ps1
./Scripts/Build/build.sh
.\Scripts\Test\test.ps1
./Scripts/Test/test.sh
--> The result will be in TestResults
folder, the content inside will be always the newest.
.\Scripts\PublishApp\publish.ps1
./Scripts/PublishApp/publish.sh
--> The result will be in out
folder, the content inside will be always the newest.
.\Scripts\Clean\clean.ps1
./Scripts/Clean/clean.sh
This project is licensed under the MIT License, allowing you to freely use, modify, and distribute it under the terms of the license.
Please submit any problems or questions related to this project on GitHub issues.