- Target Framework: .NET 10.0 Release
- Core Libraries:
Microsoft.EntityFrameworkCore.SqlServer(v10.0.1)Microsoft.AspNetCore.Identity.EntityFrameworkCore(v10.0.1)FluentValidation.DependencyInjectionExtensions(v12.1.1)Swashbuckle.AspNetCore(v10.1.0)Microsoft.AspNetCore.Authentication.JwtBearer(v10.0.1)
- ORM: Entity Framework Core 10.0.1
- API: ASP.NET Core Web API
- Blazor: Blazor WebAssembly (implied by
EShop.BlazorClientfolder)
- Style: Layered Architecture (Hybrid Clean Architecture)
- Domain: Contains Entities and Specifications. No dependencies.
- Application: Contains Interfaces and Validators. Lightweight.
- Infrastructure: Contains Data Access (Repositories) and Business Logic (Services). Implements Application interfaces.
- API: Entry point, Controllers, Middleware, DI configuration.
- Shared: Common DTOs and Result wrappers used by both API and Blazor Client.
- Key Patterns:
- Repository Pattern: Generic Repository (
IGenericRepository<T>) used for data access. - Specification Pattern: Used for encapsulating query logic (e.g.,
ProductsWithCategorySpecification). - Result Pattern: Services return
Result<T>instead of throwing exceptions or returning raw data. - Service-Based Logic: Business logic is encapsulated in Services (e.g.,
ProductService) effectively implementing the "Transaction Script" or "Domain Service" pattern rather than CQRS with MediatR.
- Repository Pattern: Generic Repository (
- Naming Conventions:
- Interfaces: PascalCase with 'I' prefix (e.g.,
IGenericRepository). - Classes/Services: PascalCase (e.g.,
ProductService). - DTOs: PascalCase with 'Dto' suffix (e.g.,
ProductDto). No record types used; standardclasswith{ get; set; }.
- Interfaces: PascalCase with 'I' prefix (e.g.,
- Entities:
- Standard
class(notrecord). - Properties initialized with defaults (e.g.,
= string.Empty;).
- Standard
- Dependency Injection:
- Registered in
Program.csusingbuilder.Services.AddScoped<Interface, Implementation>()orAddScoped<Service>(). - Constructor Injection used in Controllers and Services.
- Registered in
- Error Handling:
- Global Middleware:
ExceptionMiddlewarecatches exceptions and returns standardized JSON responses (Result<string>). - Result Pattern: Services return
Result.Failurefor logical errors (e.g., "Product not found") rather than throwing exceptions.
- Global Middleware:
- Validation:
- FluentValidation: logic decoupled from DTOs/Entities, registered in
Program.cs.
- FluentValidation: logic decoupled from DTOs/Entities, registered in
- Architecture Mandate: FUTURE WORK: All Business Logic (Services) must be implemented in the Application layer. The Infrastructure layer should only contain Data Access (Repositories) and external integrations. Do NOT use MediatR or CQRS unless explicitly requested.
- Return Types: Always return
Result<T>from Services. Do not return raw Entities or DTOs. Handle success/failure states explicitly via the Result object. - Data Access: Use
IGenericRepository<T>for all database operations. Do not useDbContextdirectly in Services or Controllers. Use Specifications for filtering/querying logic. - DTOs & Entities: Use
classfor Entities and DTOs. Initialize string properties tostring.Emptyto avoid null reference warnings. Do not userecordtypes unless explicitly requested. - Validation: Use
FluentValidationfor input validation. Do not use Data Annotations on DTOs.