How dennitorf/asp-net-core-project-template works
Main Components
• Application Layer: Encompasses the business logic, command and query handlers (for TodoItems and Todos), behaviors (like logging, performance, validation), mapping profiles, and interfaces that abstract dependencies (like the email service).
• Persistence Layer: Responsible for data storage and database interactions using Entity Framework Core. It includes the AppDbContext, Fluent API configuration classes, migrations, and seeders.
• Infrastructure Layer: Provides implementations for accessing external resources. For example, the EmailService is implemented here based on interfaces defined in the Application layer.
• WebUI (Web API) Layer: Implements the RESTful API using ASP.NET Core. It hosts controllers (for health checks, TodoItems, and Todos), middleware (such as exception filters), and configuration (Startup, Program, appsettings).
Relationships and Interactions
• The WebUI layer (ASP.NET Core API) is the presentation endpoint. It receives HTTP requests, routes them to the appropriate controllers, and then delegates to the Application layer.
• The Application layer contains business workflows (commands and queries) and is responsible for processing requests. It makes use of Domain models and interacts with the Persistence layer to read or modify data.
• When external resources are needed (like sending emails), the Application layer calls interfaces whose concrete implementations exist in the Infrastructure layer.
• The Persistence layer not only handles data access (DbContext, EF configurations, migrations) but also ensures that domain models are persisted consistently.
• There is a clear separation of concerns with dependencies typically moving inward from WebUI/Application to Domain.
Architectural Patterns and Technologies
• Clean Architecture / Onion Architecture: Each layer has its own responsibility, and dependencies move in a single direction (from outer layers to inner layers).
• CQRS Pattern: Evident from the separation of commands (create, delete, update) and queries (get all, get by id) for TodoItems and Todos.
• Dependency Injection: Seen through the DependencyInjection.cs files in various layers which help decouple components.
• Entity Framework Core: Used in the Persistence layer for data access, migration management, and configuration.
• ASP.NET Core: The main technology for building the Web API, managing controllers, middleware, and application startup configuration.
• Testing: The Tests folder indicates unit tests for Application and Domain layers ensuring quality and correctness.