Architecture
The BuildingBlocks library is organized into several key areas:- CQRS: Command and Query interfaces based on MediatR
- Behaviors: Cross-cutting concerns using MediatR pipeline behaviors
- Exceptions: Custom exception types and global exception handler
- Pagination: Standardized pagination request and response types
Key Dependencies
The BuildingBlocks library relies on the following NuGet packages:Project Structure
Usage Across Microservices
Each microservice in the AspNetRun project references the BuildingBlocks library to:- Define Commands and Queries: Using CQRS interfaces to separate read and write operations
- Validate Requests: Automatically validate commands using FluentValidation
- Log Operations: Track request execution time and log warnings for slow operations
- Handle Exceptions: Convert exceptions to standardized HTTP problem details responses
- Paginate Results: Return consistent paginated responses across all APIs
Benefits
- Consistency: All microservices follow the same patterns and conventions
- Reusability: Common code is written once and shared across services
- Maintainability: Changes to cross-cutting concerns are made in one place
- Type Safety: Strong typing for commands, queries, and handlers
- Separation of Concerns: Clean separation between business logic and infrastructure
Next Steps
CQRS Pattern
Learn about the Command and Query interfaces
Pipeline Behaviors
Understand validation and logging behaviors
Exception Handling
Explore custom exceptions and global handler
Pagination
Implement pagination in your queries
