How zodiaco1999/dotnetcleanarchitecture works
Project type and purpose
• This is a .NET 8.0 backend API project using the Clean Architecture pattern.
• Its domain is vehicle rentals (“Alquileres”), vehicle searching, user management, and reviews.
• It’s structured into four main assemblies:
• Api (presentation)
• Application (use-case/business logic)
• Domain (core entities, value objects, domain events)
• Infrastructure (EF Core DbContext, repositories, migrations, email/clock services)
File structure
• Top-level solution: CleanArchitecture.sln
• CleanArquitecture.Api
• Controllers → HTTP endpoints
• Middleware, Extensions, Program.cs, appsettings.json
• CleanArchitecture.Application
• Abstractions (ICommand/IQuery, behaviors, clock, email, data)
• Use-cases under Alquileres and Vehiculos (commands, queries, handlers, validators, domain event handlers)
• DependencyInjection.cs for registering MediatR pipelines, validators, etc.
• CleanArchitecture.Domain
• Entities, value objects, errors, domain events, repository interfaces, IUnitOfWork
• CleanArchitecture.Infraestructure
• ApplicationDbContext (EF Core) + Migrations
• Repository implementations for Domain interfaces
• SqlConnectionFactory, DateTimeProvider, EmailService
• EntityTypeConfigurations
README
• Confirms use of “Clean Architecture” in C#/.NET 8.0.
• No further architecture details but it sets the expectation of strict layer separation.
• Presentation/API layer (CleanArquitecture.Api)
• Application layer (CleanArchitecture.Application)
• Domain layer (CleanArchitecture.Domain)
• Infrastructure layer (CleanArchitecture.Infraestructure)
• External resources: SQL Database, SMTP/Email provider, System Clock
1. Client → HTTP Controllers (Api)
2. Controllers → Mediator (ICommand/IQuery) in Application
– Show ValidationBehavior, LoggingBehavior in the pipeline
3. CommandHandler/QueryHandler in Application → Domain Entities & Domain Services
4. Handlers invoke repository interfaces (IAlquilerRepository, IUserRepository, IVehiculoRepository)
5. Repository implementations in Infrastructure → EF Core DbContext → SQL Database
6. Domain events (e.g., AlquilerReservadoDomainEvent) published → handled by Application’s DomainEventHandlers (e.g., to send emails)
7. Infrastructure EmailService and DateTimeProvider are injected into Application via abstractions
c. Architectural patterns/design principles:
• Layered (Onion/Clean) architecture – dependencies only point inward
• CQRS with MediatR-like mediator for commands/queries
• Repository + Unit of Work abstractions in Domain, implemented in Infrastructure
• Domain events for decoupled side effects (email notifications, etc.)
• Behavior pipeline for cross-cutting concerns (validation, logging)
d. Key technologies/frameworks:
• .NET 8.0, C#
• ASP.NET Core Web API
• MediatR or custom mediator abstractions
• Entity Framework Core (DbContext, Migrations)
• FluentValidation (command validators)
• Dependency Injection (built into ASP.NET Core)