How fadarve1/prueba-tecnica works
Purpose and Entry Points
OrderFlow is a small order-management system: a .NET 8 REST API backed by PostgreSQL and an Angular 22 standalone client for listing, filtering, creating, editing, and deleting orders. Backend startup is backend/src/OrderManagement.Api/Program.cs; frontend bootstrap is frontend/src/main.ts. Database schema initialization is supplied by 001_init.sql and started through docker-compose.yml.
Backend Layering and Dependency Boundary
The backend follows Clean Architecture. The Domain layer owns order entities and status semantics without infrastructure dependencies: backend/src/OrderManagement.Domain/Entities/Order.cs, backend/src/OrderManagement.Domain/Entities/OrderItem.cs, and backend/src/OrderManagement.Domain/Enums/OrderStatus.cs. The Application layer defines use-case contracts, DTO boundaries, and domain-facing exceptions, insulating service logic from EF Core/PostgreSQL.
API Transport Layer
MVC routes are concentrated in backend/src/OrderManagement.Api/Controllers/OrdersController.cs, exposing CRUD and filtered search under /api/orders. Requests map into application DTOs such as backend/src/OrderManagement.Application/DTOs/SaveOrderRequest.cs; responses use order DTOs. backend/src/OrderManagement.Api/Infrastructure/GlobalExceptionHandler.cs is the HTTP error boundary, translating application failures such as missing or duplicate orders into consistent API responses.
Order Use-Case Flow
backend/src/OrderManagement.Application/Services/OrderService.cs is the central orchestration stage for listing, reading, saving/updating, and deleting orders. It enforces application behavior and converts between domain entities and DTOs. It depends only on the persistence abstraction at backend/src/OrderManagement.Application/Abstractions/IOrderRepository.cs, not the concrete database implementation. Application-specific failure paths are represented by backend/src/OrderManagement.Application/Exceptions/OrderNotFoundException.cs and backend/src/OrderManagement.Application/Exceptions/DuplicateOrderNumberException.cs.
Persistence and Database
Infrastructure implements the Application repository contract in backend/src/OrderManagement.Infrastructure/Repositories/OrderRepository.cs. EF Core mapping and aggregate persistence are defined by backend/src/OrderManagement.Infrastructure/Persistence/OrderDbContext.cs, with entity configuration in backend/src/OrderManagement.Infrastructure/Persistence/Configurations/OrderConfiguration.cs and backend/src/OrderManagement.Infrastructure/Persistence/Configurations/OrderItemConfiguration.cs. Dependency registrations cross the composition boundary through backend/src/OrderManagement.Infrastructure/DependencyInjection.cs, invoked by API startup.
PostgreSQL 18 is the external state service. docker-compose.yml provisions it; 001_init.sql establishes its schema and database-side constraints/indexes/logic. The default connection can be overridden with ConnectionStrings__DefaultConnection.
Frontend Application Flow
The Angular client is a standalone SPA configured from frontend/src/app/app.config.ts and navigated through frontend/src/app/app.routes.ts. frontend/src/app/core/services/order.service.ts is the frontend/API boundary, using shared order models from frontend/src/app/core/models/order.model.ts to call the REST endpoints. UI feature components separate read and mutation workflows: frontend/src/app/features/orders/order-list.component.ts handles list/filter/delete behavior, while frontend/src/app/features/orders/order-form.component.ts handles create and edit submission.
Runtime Topology
The browser serves the Angular app on port 4200 and issues HTTP requests to the .NET API on port 5080. The API composes controllers, application services, and EF Core infrastructure, then connects to PostgreSQL on port 5432. Key deployment/runtime configuration is in backend/src/OrderManagement.Api/appsettings.json and docker-compose.yml.
Main entry points: OrdersController.cs Orders controller · app.config.ts App config & routes · OrderService.cs Order service · OrderRepository.cs Order repository
Components 18
Angular SPA
- Browser · Serves the SPA on port 4200.
- Angular bootstrap
frontend/src/main.ts - App config & routes
frontend/src/app/app.config.ts - Order list · Lists, filters, and deletes orders.
frontend/src/app/features/orders/order-list.component.ts - Order form · Creates and edits orders.
frontend/src/app/features/orders/order-form.component.ts - Order API service · Uses shared order models for REST calls.
frontend/src/app/core/services/order.service.ts
.NET API
- API startup · Runs the .NET API on port 5080.
backend/src/OrderManagement.Api/Program.cs - Orders controller · Exposes CRUD and filtered search at /api/orders.
backend/src/OrderManagement.Api/Controllers/OrdersController.cs - Global exception handler
backend/src/OrderManagement.Api/Infrastructure/GlobalExceptionHandler.cs
Clean Architecture
- Order service · Orchestrates list, read, save/update, and delete operations.
backend/src/OrderManagement.Application/Services/OrderService.cs - Order repository contract
backend/src/OrderManagement.Application/Abstractions/IOrderRepository.cs - Order aggregate · Order, items, and status semantics remain infrastructure-free.
backend/src/OrderManagement.Domain/Entities/Order.cs - Infrastructure registration
backend/src/OrderManagement.Infrastructure/DependencyInjection.cs - Order repository
backend/src/OrderManagement.Infrastructure/Repositories/OrderRepository.cs - Order DbContext · Persists the aggregate using entity configurations.
backend/src/OrderManagement.Infrastructure/Persistence/OrderDbContext.cs
Database Runtime
- PostgreSQL 18 · Database runtime on port 5432.
- Schema initialization · Establishes schema, constraints, indexes, and database logic.
001_init.sql - Docker Compose · Provisions PostgreSQL.
docker-compose.yml
Connections 19
- Browser → Angular bootstrap: loads
- Angular bootstrap → App config & routes: initializes
- App config & routes → Order list: routes to
- App config & routes → Order form: routes to
- Order list → Order API service: list/filter/delete
- Order form → Order API service: create/edit
- Order API service → Orders controller: HTTP /api/orders
- API startup → Orders controller: hosts
- API startup → Infrastructure registration: invokes
- Orders controller → Order service: application DTOs
- Global exception handler → Orders controller: translates failures
- Order service → Order repository contract: depends on
- Order service → Order aggregate: maps and applies semantics
- Infrastructure registration → Order repository: registers implementation
- Order repository → Order repository contract: implements
- Order repository → Order DbContext: uses
- Order DbContext → PostgreSQL 18: EF Core connection
- Docker Compose → PostgreSQL 18: provisions
- Schema initialization → PostgreSQL 18: initializes