How jesusferru/morenos-seguros-project works
Main Components
• Core (Domain Layer):
– Contains fundamental domain objects such as BaseEntity, IAggregateRoot, domain entities (like User), ValueObjects (UserRole), and any domain constants.
– Represents business rules, domain logic, and modeling techniques (e.g., SmartEnum for UserRole).
• Infrastructure (Data & Persistence Layer):
– Hosts the AppDbContext, repositories (EfRepository based on Ardalis.Specification), data configurations (e.g., UserConfiguration), migrations management, and service registration (InfrastructureServiceExtensions).
– Handles data mapping, configuration, and communication with the actual database.
• API/Web/Endpoints Layer:
– The MorenoSeguros.Api project provides API endpoints (e.g., Login endpoints, User endpoints) which expose the functionality of the backend.
– Includes middleware (e.g., HandleException), page views (Razor pages like Error, Index, Privacy), static assets (in wwwroot with CSS, JS, and libraries).
• Migration Module:
– The Migration project, which contains API DB initialization and migration commands. This module ensures that database schema changes are tracked and applied.
• Frontend (Client Side):
– Although details are sparse here, include it as a separate client component that might interact with backend APIs.
Out the Relationships and Interactions
• How the Web/API layer communicates with the Core via Use Cases and how controllers (or endpoints) call services defined in the Core.
• Dependency inversion where the Core (domain) is independent, while the Infrastructure layer provides implementations (like repositories) that the Core uses.
• How the Infrastructure layer connects with the database (via AppDbContext using EF Core) and how migrations are used to update schema.
• For the frontend, indicate that it interacts with the backend API through HTTP calls (exposing endpoints like Login and Users operations).
Architectural Patterns and Design Principles
• Clean Architecture / Onion Architecture:
– Layers (Core, Use Cases, Infrastructure, and API/Web) should be depicted concentrically with clear boundaries.
• Domain-Driven Design (DDD) patterns:
– Note the use of IAggregateRoot to mark aggregate boundaries, domain entities in the Core, and Value Objects.
• Repository Pattern:
– Show the generic repository (EfRepository<T>) for data access.
• Separation of Concerns and Dependency Inversion:
– Ensure that core business logic does not depend on external frameworks (e.g., EF Core details are isolated in the Infrastructure).
• “Core” block: List BaseEntity, Entities (User), Domain Interfaces, ValueObjects.
• “Infrastructure” block: Include AppDbContext, Repository (EfRepository), Service Registration, Migrations.
• “API/Web Endpoints” block: Represent endpoints for Login, Users, middleware, and static assets.
• “Frontend” (if necessary): Mark the client code interacting with the API.
• Data flow from the API to the Core (via service methods and use cases).
• Dependency from Infrastructure to Core (for domain models).
• Communication from the API layer to the database via the Infrastructure.
• The migration process updating the database.
• Annotations that mention key tools and libraries:
• EF Core (for AppDbContext and migrations).
• Ardalis.Specification-based repository.
• .NET (C# Razor pages) are used in the API layer.
• Dependency Injection (as seen with service extensions).