Skip to content

Latest commit

 

History

History
50 lines (46 loc) · 3.53 KB

File metadata and controls

50 lines (46 loc) · 3.53 KB

Project_DNA.md

Tech Stack & Versions

  • 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.BlazorClient folder)

Architecture Pattern

  • 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.

Coding Standards (Detected)

  • 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; standard class with { get; set; }.
  • Entities:
    • Standard class (not record).
    • Properties initialized with defaults (e.g., = string.Empty;).
  • Dependency Injection:
    • Registered in Program.cs using builder.Services.AddScoped<Interface, Implementation>() or AddScoped<Service>().
    • Constructor Injection used in Controllers and Services.
  • Error Handling:
    • Global Middleware: ExceptionMiddleware catches exceptions and returns standardized JSON responses (Result<string>).
    • Result Pattern: Services return Result.Failure for logical errors (e.g., "Product not found") rather than throwing exceptions.
  • Validation:
    • FluentValidation: logic decoupled from DTOs/Entities, registered in Program.cs.

Critical Instructions

  1. 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.
  2. Return Types: Always return Result<T> from Services. Do not return raw Entities or DTOs. Handle success/failure states explicitly via the Result object.
  3. Data Access: Use IGenericRepository<T> for all database operations. Do not use DbContext directly in Services or Controllers. Use Specifications for filtering/querying logic.
  4. DTOs & Entities: Use class for Entities and DTOs. Initialize string properties to string.Empty to avoid null reference warnings. Do not use record types unless explicitly requested.
  5. Validation: Use FluentValidation for input validation. Do not use Data Annotations on DTOs.