How robhutton/blazor-clean-architecture works
Main Components
• UI/Presentation Layer:
• BlazingBlog.WebUI.Client: Contains Blazor client-side features and Razor components.
• BlazingBlog.WebUI.Server: Contains server-side Razor components, controllers, layouts, and routing (e.g., server routes, Blazor Server Pages). This layer handles both SSR and real-time updates (using SignalR) based on Blazor hosting model.
• Application Layer:
• BlazingBlog.Application: Contains business use cases organized by feature (such as Articles and Users). Each feature folder (for example, Articles, Authentication, Users) is structured as a vertical slice with its own set of commands, queries, handlers, and DTOs.
• CQRS Pattern is implemented here with interfaces for ICommand, IQuery and their respective Handlers, meaning commands (e.g., CreateArticleCommand) and queries (e.g., GetArticleByIdQuery) are dispatched via a Mediator.
• Domain Layer:
• BlazingBlog.Domain: Encompasses core business entities (such as Article and User) along with base abstractions (like Entity, Result) and repository interfaces (e.g., IArticleRepository, IUserRepository).
• Infrastructure Layer:
• BlazingBlog.Infrastructure: Implements actual functionality like ApplicationDbContext, repository implementations, authentication services, user services, and migration files. This layer bridges the Application/Domain with external systems (databases, identity providers).
Understand the Relationships and Data Flow
• UI/Presentation interacts with the Application Layer—typically through API endpoints (or direct Mediator calls in the case of Blazor Server) and Razor components that dispatch commands and queries.
• The Application layer uses the Domain entities (for business logic) while sending commands and queries through MediatR. Handlers here call the Infrastructure layer for persistence and external service interactions.
• The Infrastructure layer implements the repository interfaces and other external integrations (e.g., Authentication, Database Migrations) that the Application layer depends upon.
Architectural Patterns & Important Details
• Clean Architecture Layers: Explicitly show the flow from Presentation → Application → Domain → Infrastructure.
• Technologies: Include .NET 8, Blazor (both Server and Client/WebAssembly), MediatR, and possibly Mapster for object mapping; denote Entity Framework (or another ORM) for database interactions.