How alejandrafrancog/products-api works
Products API is a .NET REST service for product CRUD, filtered listing, lookup, and counting. Requests enter through the products endpoints and are dispatched as queries or commands; application handlers use a read-store port for queries and repository/unit-of-work ports for writes. The domain aggregate enforces product invariants, while infrastructure implements persistence with EF Core and PostgreSQL. The excerpts show endpoint dispatch and key persistence behavior; handler-to-port links are supported by the source index, but deeper sender/behavior execution details are not shown.
Main entry points: ProductsEndpoints.cs Product endpoints · Product.cs Product aggregate · IProductRepository.cs Write repository port · DependencyInjection.cs Infrastructure wiring
Components 21
HTTP API
- Product endpoints
src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs - Exception mapping
src/ProductsApi.Api/ExceptionHandling/GlobalExceptionHandler.cs
Application
- Message sender
src/ProductsApi.Application/Messaging/Sender.cs - Logging behavior
src/ProductsApi.Application/Behaviors/LoggingBehavior.cs - Validation behavior
src/ProductsApi.Application/Behaviors/ValidationBehavior.cs - Create product
src/ProductsApi.Application/Products/Commands/CreateProduct/CreateProductCommand.cs - Replace product
src/ProductsApi.Application/Products/Commands/UpdateProduct/UpdateProductCommand.cs - Patch product
src/ProductsApi.Application/Products/Commands/PatchProduct/PatchProductCommand.cs - Delete product
src/ProductsApi.Application/Products/Commands/DeleteProduct/DeleteProductCommand.cs - Product queries
src/ProductsApi.Application/Products/Queries - Read-store port
src/ProductsApi.Application/Abstractions/Data/IProductsReadStore.cs - Not-found error
src/ProductsApi.Application/Common/NotFoundException.cs
Product domain
- Product aggregate
src/ProductsApi.Domain/Products/Product.cs - Domain error
src/ProductsApi.Domain/DomainException.cs - Write repository port
src/ProductsApi.Domain/Products/IProductRepository.cs
Persistence
- Infrastructure wiring
src/ProductsApi.Infrastructure/DependencyInjection.cs - Product repository
src/ProductsApi.Infrastructure/Persistence/ProductRepository.cs - Product read store
src/ProductsApi.Infrastructure/ReadModels/ProductsReadStore.cs - EF unit of work
src/ProductsApi.Infrastructure/Persistence/AppDbContext.cs
Other components
- API client
- PostgreSQL
Connections 29
- API client → Product endpoints: sends requests
src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs - Product endpoints → Message sender: dispatches messages
src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs - Product endpoints → Create product: sends command
src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs - Product endpoints → Replace product: sends command
src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs - Product endpoints → Patch product: sends command
src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs - Product endpoints → Delete product: sends command
src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs - Product endpoints → Product queries: sends queries
src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs - Infrastructure wiring → Logging behavior: registers behavior
- Infrastructure wiring → Validation behavior: registers behavior
- Create product → Write repository port: uses repository
src/ProductsApi.Application/Products/Commands/CreateProduct/CreateProductCommand.cs - Replace product → Write repository port: uses repository
src/ProductsApi.Application/Products/Commands/UpdateProduct/UpdateProductCommand.cs - Patch product → Write repository port: uses repository
src/ProductsApi.Application/Products/Commands/PatchProduct/PatchProductCommand.cs - Delete product → Write repository port: uses repository
src/ProductsApi.Application/Products/Commands/DeleteProduct/DeleteProductCommand.cs - Product queries → Read-store port: reads through
src/ProductsApi.Application/Products/Queries/CountAllProductsQuery.cs - Product repository → EF unit of work: queries and changes
src/ProductsApi.Infrastructure/Persistence/ProductRepository.cs - Product read store → EF unit of work: projects queries
src/ProductsApi.Infrastructure/ReadModels/ProductsReadStore.cs - Infrastructure wiring → Product repository: registers implementation
src/ProductsApi.Infrastructure/DependencyInjection.cs - Infrastructure wiring → Product read store: registers implementation
src/ProductsApi.Infrastructure/DependencyInjection.cs - Write repository port → Product repository: implemented by
src/ProductsApi.Infrastructure/DependencyInjection.cs - Read-store port → Product read store: implemented by
src/ProductsApi.Infrastructure/DependencyInjection.cs - EF unit of work → PostgreSQL: persists products
- Product repository → Product aggregate: loads aggregate
src/ProductsApi.Infrastructure/Persistence/ProductRepository.cs - Create product → Product aggregate: creates aggregate
src/ProductsApi.Application/Products/Commands/CreateProduct/CreateProductCommand.cs - Replace product → Product aggregate: updates aggregate
src/ProductsApi.Application/Products/Commands/UpdateProduct/UpdateProductCommand.cs - Patch product → Product aggregate: updates aggregate
src/ProductsApi.Application/Products/Commands/PatchProduct/PatchProductCommand.cs - Delete product → Not-found error: raises when absent
src/ProductsApi.Application/Products/Commands/DeleteProduct/DeleteProductCommand.cs - Exception mapping → Not-found error: maps to 404
src/ProductsApi.Api/ExceptionHandling/GlobalExceptionHandler.cs - Exception mapping → Domain error: maps to 400
src/ProductsApi.Api/ExceptionHandling/GlobalExceptionHandler.cs - Product aggregate → Domain error: raises on invalid data
src/ProductsApi.Domain/Products/Product.cs