How imaanmzr/todoapp works
Main Components
• Frontend (ToDoApp.BlazorUI): The Blazor-based user interface for interacting with the ToDo application.
• API Layer (ToDoApp.Api): A .NET Web API that acts as the entry point for client requests. It contains controllers (e.g., AuthController, CategoriesController, UserTasksController) and middleware (ExceptionMiddleware).
• Application Layer (ToDoApp.Application): Implements business logic using the CQRS pattern. This includes commands, queries, validators, and mapping profiles. It also registers application services.
• Domain/Core (ToDoApp.Core): Contains domain entities, common models, and contracts for repositories and other operations.
• Identity (ToDoApp.Identity): Manages user authentication/authorization. It includes DbContext configuration, identity models (like ApplicationUser), and services related to authentication.
• Infrastructure (ToDoApp.Infrastructure): Provides auxiliary services such as email (EmailSender) and logging (LoggerAdapter). This also handles the registration of these services.
• Persistence (ToDoApp.Persistence): Uses EF Core for database access. It includes database context (ToDoDbContext), configurations for entities (Category, UserTask), migrations, and repository implementations.
Relationships and Interactions
• The Blazor UI communicates with the API layer via HTTP (via NSwag-generated clients or custom HTTP service clients) and relies on service contracts (see Contracts in BlazorUI).
• The API layer serves as a façade that invokes the Application layer using the CQRS pattern (for instance, calling command/query handlers through Mediator).
• The Application layer encapsulates business logic, mapping incoming requests into commands/queries and delegating data access to repositories (abstracted in the Core, implemented in Persistence).
• The Identity component is responsible for authentication/authorization; it interacts with the API layer (auth controllers) and Application layer (via service interfaces) to validate user credentials.
• The Infrastructure layer is used by the Application and API layers to send emails and provide logging functionality.
• The Persistence layer hosts the repositories that actually interact with the database using EF Core.
Architectural Patterns & Design Principles
• Clean Architecture: Separates concerns into different layers ensuring dependency inversion (e.g., the Application does not directly depend on Persistence or Infrastructure).
• CQRS Pattern: Commands and queries for both UserTask and Category management are organized into dedicated folders with command/query handlers and validators.
• Domain-Driven Design (DDD) aspects: With the Core project holding domain entities, including shared logic in BaseEntity classes.
• Use of MediatR: Implied for orchestrating command and query handling.
• AutoMapper: For mapping between domain entities and DTOs in both the API and Blazor UI layers.