docs/en/solution-templates/guide.md
//[doc-seo]
{
"Description": "Explore ABP's guide to selecting the right startup template for your project, covering architectures like Microservices, N-Layered, and more."
}
ABP provides several startup templates to you. It is important to start with the right startup template that is suitable for your project and team. This guide aims to lead you to select the most proper startup template for your requirements.
The following architectures will be discussed based on ABP startup templates:
In the following section, you will understand what a startup template is and what it provides.
A startup solution template is a pre-architected structure. For example, the layered startup template is a great starting point if you want to build a layered application code-base based on Domain-Driven Design principles and patterns.
However, starting with any startup template doesn't limit you on adding or removing projects, layers, integration packages, and creating other applications/services. You can even start with a single-layer application template and convert it to a microservice solution. However, if you want to build a microservice solution, starting with the microservice startup template is the best.
So, it is best to start with the most suitable startup template for your purpose and then modify the solution to fit your custom requirements.
Besides the overall solution structure, the internals of each project in a solution template are well-structured. It is clear where will you place your entities, repositories, data access code, application services, API controllers, UI elements, etc. You don't spend time thinking about how to organize your codebase in every new project. If you prefer to build automated tests for your application, the test projects are also included and pre-configured.
When you use ABP startup solution templates to create a new solution, some fundamental library installations (Serilog, Autofac, Mapperly, Swagger, HealthCheck and others..) and their fine-tuned configurations are already prepared for you. Also, required ABP packages are just installed based on your preferences and configured for development and production environments.
When you create a new solution, or when a new teammate starts to work on your existing solution, it is pretty easy to understand the solution structure, design decisions and the development flow by the help of solution structure documents and development tutorials.
ABP's startup templates are ready for production out of the box. You can just create a new solution and deploy it to your production environment. It is not only about technical readiness, but also about functional readiness.
When you create a new ABP solution, fundamental modules are already installed. Your application has a robust account module (user registration, login, social logins, 2-factor authentication, user lockout, password complexity control...), an advanced identity module (user, role and permission management), and many other production-ready pre-built application modules are just working as a part your application in the first day.
Up to this point, it is explained what a startup template is and the features it offers. In the following section, you will see the types of startup solution templates and which one is best for you.
The single-layer solution template is the simplest. It provides a minimal solution architecture while starting a new project. Your .NET solution typically contains a single, or a few .NET projects depending on your UI and other preferences while creating your solution.
The following figure shows a single-project web application that has MVC (Razor Pages) UI and Entity Framework Core database provider with the default configuration:
As you see in the preceding figure, all the application code (entities, data access, services, UI pages, etc.) are located in a single .NET project.
In the following conditions, you may consider to use the single-layer solution template:
If the preceding conditions are met with your case, you can consider starting with this solution template. However, keep in mind that your solution can quickly become a big ball of mud. We think that only a very small portion of applications are suitable for that kind of solution structure.
Note that the single-layer solution template doesn't provide the following options/features:
These options are not implemented to keep the solution structure as simple as possible. If you need some of these, please feel free to use the layered solution template.
The layered application startup template is a .NET solution that consists of several projects. Each project represents a layer of the application or has a specific functionality for the solution.
The exact project count in your solution depends on the options you have selected. The following figure shows a solution with MVC (Razor Pages) UI and Entity Framework Core database provider with the default configuration:
The solution is layered based on Domain-Driven Design principles and extended based on real-world business application requirements. It includes test projects for each layer. Layering the solution has great benefits:
While it may seem a little complicated at the beginning, once you complete the Book Store tutorial, you will easily understand the purpose and usage of each project.
In the following conditions, you may consider to use the layered solution template:
ABP does not provide a specific modular monolith application startup template. However, it is not needed. Let us explain why.
The ABP Framework and ABP Studio are already designed to support modular application development from their beginning. ABP framework provides all the necessary infrastructure for modularity and all other framework features are compatible with modular solutions.
On the other hand, the main purpose of ABP Studio's Solution Explorer panel is to architect and build modular and complex software solutions. You can easily create new modules, arrange dependencies between the modules and import/install these modules into a monolith application. While you can do all these manually yourself, ABP Studio makes it extremely easy to do and understand it.
A modular monolith application consists of a single host application and multiple sub-modules. Typically, each module has its own .NET solution that contains the code related to that module. So, the general structure is shown in the following figure:
In this example, MyCrm.Host is an almost-empty host application that has package references to other modules. Every module consists of two packages: implementation and contract packages.
You can follow the steps below to create such a modular solution with ABP Studio:
You can follow the Modular Monolith Application Development Tutorial to learn how to build a modular application step by step.
So, both single-layer and layered application startup templates are inherently modular. Just use one of them and start your modular solution. You may wonder which one to start:
In the following conditions, you may consider to build a modular software solution:
While all these are also suitable for microservice solutions (which will be discussed in the next section), a modular solution is more suitable than microservices for most of the projects. Especially if you don't need to have technology diversity, deploy and scale services independently and serve too many users concurrently with a fault-tolerant system, a modular monolith application would be a better choice to not deal with the complexity of a microservice system. Also, it is better to start with a thin architecture when you have a small team that can focus on building features without spending time managing distributed architecture complexities. Another advantage is that the modular monoliths avoid the network latency and communication overhead inherent in microservices, so debugging and monitoring are easier as all modules run within a single application. In summary, if you anticipate that your application may grow to require a microservices architecture in the future, a modular monolith is a great starting point.
Build for Now, Scale for Tomorrow
Even if you are considering building a microservice architecture, it is usually advised to start with a monolith modular first, then migrate to microservices later once your business and module boundaries are more stable.
ABP's microservice startup template includes multiple services, API gateways and applications that are well integrated into each other and ready to be a great base solution for your microservice system. In the following picture, you can see an overall diagram that shows the main components of the solution (they vary based on the options while you are creating your solution):
In the following conditions, you may consider to build a microservice system:
Use Case Examples
In summary, the ABP Platform offers a variety of solution templates tailored to different architectural needs, including layered applications, microservices, and modular development. These templates provide a great foundation for building robust applications by implementing best practices and providing essential features. By selecting the right template, you can streamline the development process, ensuring scalability and maintainability in your project.