This repository contains two robust project templates designed for building applications using the Modular Monolith architecture with ASP.NET Core. These templates are intended to accelerate the development process of scalable and maintainable web applications.
These templates integrate several modern technologies and frameworks:
- ASP.NET Core: Framework for building web apps and services with .NET.
- MediatR: Simple mediator implementation in .NET for in-process messaging.
- FastEndpoints: Minimalistic and fast endpoint API library for ASP.NET Core.
- FluentValidation: Library for building strong validation rules.
- Ardalis Result: Library to implement the Result Pattern.
- Main Project Template: Sets up the primary project structure, incorporating all necessary configurations and base setups required for a Modular Monolith architecture.
- Module Template: Allows the creation of additional modules to plug into the main project, facilitating system expansion and maintenance.
Follow these steps to use these templates on your local machine:
- Clone or download this repository to your local machine.
- Navigate to the directory containing the templates.
- Run the following command to install the templates:
dotnet new install ./
Note: Execute this command within both the 'monolith' and 'module' folders located in the 'Content' directory.
After installation, the templates should appear in the Visual Studio 2022 project wizard.
Using Visual Studio 2022, set the name of your project (e.g., Server, Host, etc.).
It is recommended to use the same name for the prefix in all the namespaces of your C# classes.
The solution should be created with two projects: an ASP.NET Core Web API and a library named YourHostName.CrossCuttingConcerns
.
A similar process applies when installing a module. If you want to maintain consistency in your namespaces, it is advisable to use the name of your main project followed by the name of your module (e.g., Host.MyModule
).
In the next screen, specify the name of your main project and the name of your module again. This is important because the template will update the namespaces of all projects to maintain consistency.
Your solution should look like this:
Finally, update the project reference for Host.CrossCuttingConcerns
in Host.MyModule.Module
.
Add the reference of Host.MyModule.Module
to your main project (Host), and you are ready to start working! The Host will automatically add the module to your main project, and you should see a working Swagger UI showing a basic endpoint for testing.
Contributions are welcome! Please feel free to submit pull requests, create issues, or provide feedback on how the templates can be improved.
This project is licensed under the MIT License - see the LICENSE file for details.