-
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
-
For the detail about the features I build on this template, please download and check out this Excel File or take a look at this image below:
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.
I used to build projects by following tutorials, but their suggested structures caused problems. I struggled with:
- Massive service files: These became unwieldy and hard to maintain as they grew.
- Dispersed context: It was difficult to find all the pieces of a feature because they were scattered across different files and folders.
- Overloaded controllers: Controllers became bloated and hard to manage.
This traditional, technical-based architecture, which groups files by type (e.g., all services in a Services
folder), seemed organized at first, but it became inefficient. I then explored feature-based architecture, which offers:
- Clearer organization: Each feature gets its own folder, making navigation easier.
- Simplified maintenance: All related files are together.
However, feature-based architecture also presented challenges as projects scaled:
- Class naming collisions: With many feature-related classes, it was easy to mix up or mistype names (e.g.,
FM1Endpoint
vs.FM2Endpoint
).
To address this, I moved each feature into its own assembly (class library)
. This prevents accidental calls between features, as you must explicitly reference the correct assembly (e.g., you can't call FM1Endpoint
from the FM2Endpoint
assembly). This also allows for simpler, more consistent naming within each feature, eliminating the need for feature prefixes (e.g., FM1Endpoint
becomes simply Endpoint
).
While this could lead to duplicate class names across libraries, this is easily resolved by using the full class name (namespace + class). For example:
I have 2 classes that have the same name like this:
I can decide which one to use by writing the full class name, like this:
System.Reflection.Metadata.Constant
Beside, you can check out for more things related to this template:
-
Explanations about idea and structure of template: Here
-
Detail of each config files: Here
-
How to customize scripts that are used to support for this project: Here
-
For the detail about the features I build on this template, please download and check out this Excel File or take a look at this image below:
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
you can confirm the results by running the following command:
docker ps
It should give out an image like this:
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
After script runs successfully, you are going to see the result like this:
-
Click the link http://localhost:5245, a swagger page is going to pop up for API testing purpose.
.\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.