How franciscowatson/sistema-de-ordenes-de-inversion works
Project Overview
• This is a REST API that manages investment orders using a Clean Architecture approach and the CQRS pattern.
• It is built with .NET 8 and leverages Entity Framework Core for data persistence, MediatR for command/query handling, FluentValidation for inputs, JWT for authentication, and AutoMapper for data mapping.
Main Layers/Components
a. SOI.API (Presentation Layer)
– Contains controllers (e.g., AuthenticationController, OrdenController) and entry point (Program.cs).
– Exposes REST endpoints and handles incoming HTTP requests.
b. SOI.Application (Application Layer)
– Houses the core application logic using Commands, Queries, Handlers (MediatR), DTOs, and Validators.
– This layer implements CQRS, handling separate operations for state changes (commands) and data retrieval (queries).
c. SOI.Domain (Domain Layer)
– Contains the domain entities (Cuenta, Orden, Activo, etc.) and domain services (e.g., IOrdenDomainService, authentication services).
– Represents the core business model, logic, and interfaces that define the domain rules.
d. SOI.Infrastructure (Infrastructure Layer)
– Provides implementations for data persistence with Entity Framework Core (SoiDbContext, Configurations, Migrations).
– Contains repository implementations and authentication service details (JWT token generation, etc.).
Relationships and Interactions
• The API layer receives HTTP requests and routes them to Controllers which call MediatR.
• MediatR interacts with the Application layer by triggering specific Commands/Queries.
• Handlers in the Application layer execute business logic, possibly invoking domain services from the Domain layer.
• For database operations, the Application layer calls interfaces (e.g., IOrdenRepository) that are implemented in the Infrastructure layer.
• The Infrastructure layer manages persistence, migrations, and configuration using Entity Framework Core.
• Additionally, JWT-based authentication involves both the Domain (interfaces for JWT generation) and Infrastructure for concrete implementations.
Architectural Patterns and Design Principles
• Clean Architecture: Separation into Presentation (API), Application (CQRS logic), Domain (business rules and entities), and Infrastructure (data access and external integration).
• CQRS Pattern with MediatR: Distinct Commands and Queries with corresponding Handlers.
• Dependency Injection and Inversion of Control: Interfaces in Domain/Application are wired up with implementations in Infrastructure.
• Separation of Concerns: Each project has a clear responsibility, helping maintain scalability and testability.
Technologies & Frameworks Highlighted
• .NET 8 and ASP.NET Core: For web API development.
• Entity Framework Core: For interacting with SQL Server.
• Docker: For containerizing the service.
• MediatR: For orchestrating the command/query flows.
• FluentValidation: To validate incoming data.
• AutoMapper: For data transfer object (DTO) mapping.
• JWT: For implementing secure authentication.
Final Inclusions
• You include:
• Inside each, include key submodules (Controllers, Commands/Queries, Handlers, Entities, Repositories, etc.).
• A segment showing “Database” as a separate component interacting with the Infrastructure layer (SoiDbContext and Migrations).