Solution structure
Architectural principles affect the design of the solution. The solution is organized in accordance with the separation of business and responsibility layers:
-
The Main folder contains the code that is not related to a specific business domain.
-
The Initialization folder contains the code that is related to initialization procedures: database migration, data seeding, etc.
-
The Classifiers folder contains the code that is related to classifiers data, which is usually not often modified: genders, localities, municipalities, etc.
-
The Security folder contains the code that is related to security: users, roles, permissions, authentication, authorization, etc.
-
The Extensions folder and its projects contains useful extension methods for various packages (.Net, Microsoft.EntityFrameworkCore, Newtonsoft.Json, Microsoft.Logging, Automapper, Autofac, etc).
-
The Documentation folder contains documentation: text files, images, UML diagrams, etc.
Each business layer may be divided into several responsibility sublayers:
-
The Common layer contains the common code which will be used by other layers: models, mappings, filters, configurations, etc. It doesn't contain any business logic.
-
The Application layer contains the code that perform calculations, authentication, data validation, user permissions verification, and much more. This layer concentrates the main functionality of the system. It doesn't load any data from the database or cache and doesn't send it anywhere. This is the processing layer only.
-
The Database layer contains the code that is responsible for loading and saving information in a database. It doesn't process the data. We may have multiple data storage types in the application: SQL databases, search engines (ElasticSearch), caches (Redis) or similar. A separate layer should be created for each data storage type.
-
The External layer contains the code that is available for external clients. Internal and external API requests/responses might differ, so we need to define external requests/responses/mappings in this layer. It doesn't contain any business logic.
-
The Web layer contains the controllers and services which are required by .Net Core. It doesn't contain any business logic.
Each responsibility layer may be divided into several projects:
-
The Api project contains request, responses, filters, configurations for requests and handlers.
-
The Data project contains data objects (models or entities) and mappings.
-
The Schemas project contains database migration schemas.
-
The Handlers project contains handlers with business logic. Handlers may save or load data, validate it, process, calculate, build reports, etc.
-
The Controllers project contains web controllers.
-
The Services project contains services.