# alejandrafrancog/products-api architecture

> Architecture diagram of the GitHub repository alejandrafrancog/products-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alejandrafrancog/products-api
- Repository: https://github.com/alejandrafrancog/products-api

## Overview

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: [`src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs`](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs) (Product endpoints), [`src/ProductsApi.Domain/Products/Product.cs`](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Domain/Products/Product.cs) (Product aggregate), [`src/ProductsApi.Domain/Products/IProductRepository.cs`](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Domain/Products/IProductRepository.cs) (Write repository port), [`src/ProductsApi.Infrastructure/DependencyInjection.cs`](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Infrastructure/DependencyInjection.cs) (Infrastructure wiring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_endpoints["Product endpoints"]
  node_errors["Exception mapping"]
end

subgraph group_application["Application"]
  node_sender["Message sender<br/>[Sender.cs]"]
  node_logging["Logging behavior<br/>[LoggingBehavior.cs]"]
  node_validation["Validation behavior"]
  node_create["Create product"]
  node_update["Replace product"]
  node_patch["Patch product"]
  node_delete["Delete product"]
  node_queries["Product queries<br/>[Queries]"]
  node_readport["Read-store port"]
  node_notfound["Not-found error"]
end

subgraph group_domain["Product domain"]
  node_product["Product aggregate<br/>[Product.cs]"]
  node_domainerror["Domain error<br/>[DomainException.cs]"]
  node_repositoryport["Write repository port"]
end

subgraph group_persistence["Persistence"]
  node_registration["Infrastructure wiring"]
  node_repo["Product repository"]
  node_readstore["Product read store"]
  node_context["EF unit of work<br/>[AppDbContext.cs]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_endpoints
node_endpoints -->|"dispatches messages"| node_sender
node_endpoints -->|"sends command"| node_create
node_endpoints -->|"sends command"| node_update
node_endpoints -->|"sends command"| node_patch
node_endpoints -->|"sends command"| node_delete
node_endpoints -->|"sends queries"| node_queries
node_registration -->|"registers behavior"| node_logging
node_registration -->|"registers behavior"| node_validation
node_create -->|"uses repository"| node_repositoryport
node_update -->|"uses repository"| node_repositoryport
node_patch -->|"uses repository"| node_repositoryport
node_delete -->|"uses repository"| node_repositoryport
node_queries -->|"reads through"| node_readport
node_repo -->|"queries and changes"| node_context
node_readstore -->|"projects queries"| node_context
node_registration -->|"registers implementation"| node_repo
node_registration -->|"registers implementation"| node_readstore
node_repositoryport -->|"implemented by"| node_repo
node_readport -->|"implemented by"| node_readstore
node_context -.->|"persists products"| node_postgres
node_repo -->|"loads aggregate"| node_product
node_create -->|"creates aggregate"| node_product
node_update -->|"updates aggregate"| node_product
node_patch -->|"updates aggregate"| node_product
node_delete -->|"raises when absent"| node_notfound
node_errors -->|"maps to 404"| node_notfound
node_errors -->|"maps to 400"| node_domainerror
node_product -->|"raises on invalid data"| node_domainerror

click node_endpoints "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs"
click node_errors "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Api/ExceptionHandling/GlobalExceptionHandler.cs"
click node_sender "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Messaging/Sender.cs"
click node_logging "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Behaviors/LoggingBehavior.cs"
click node_validation "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Behaviors/ValidationBehavior.cs"
click node_create "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Products/Commands/CreateProduct/CreateProductCommand.cs"
click node_update "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Products/Commands/UpdateProduct/UpdateProductCommand.cs"
click node_patch "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Products/Commands/PatchProduct/PatchProductCommand.cs"
click node_delete "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Products/Commands/DeleteProduct/DeleteProductCommand.cs"
click node_queries "https://github.com/alejandrafrancog/products-api/tree/main/src/ProductsApi.Application/Products/Queries"
click node_readport "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Abstractions/Data/IProductsReadStore.cs"
click node_notfound "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Common/NotFoundException.cs"
click node_product "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Domain/Products/Product.cs"
click node_domainerror "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Domain/DomainException.cs"
click node_repositoryport "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Domain/Products/IProductRepository.cs"
click node_registration "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Infrastructure/DependencyInjection.cs"
click node_repo "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Infrastructure/Persistence/ProductRepository.cs"
click node_readstore "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Infrastructure/ReadModels/ProductsReadStore.cs"
click node_context "https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Infrastructure/Persistence/AppDbContext.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_endpoints,node_errors,node_client toneBlue
class node_sender,node_logging,node_validation,node_create,node_update,node_patch,node_delete,node_queries,node_readport,node_notfound,node_postgres toneAmber
class node_product,node_domainerror,node_repositoryport toneMint
class node_registration,node_repo,node_readstore,node_context toneRose
```

## Components

### HTTP API

- [Product endpoints](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs): `src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs`
- [Exception mapping](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Api/ExceptionHandling/GlobalExceptionHandler.cs): `src/ProductsApi.Api/ExceptionHandling/GlobalExceptionHandler.cs`

### Application

- [Message sender](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Messaging/Sender.cs): `src/ProductsApi.Application/Messaging/Sender.cs`
- [Logging behavior](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Behaviors/LoggingBehavior.cs): `src/ProductsApi.Application/Behaviors/LoggingBehavior.cs`
- [Validation behavior](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Behaviors/ValidationBehavior.cs): `src/ProductsApi.Application/Behaviors/ValidationBehavior.cs`
- [Create product](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Products/Commands/CreateProduct/CreateProductCommand.cs): `src/ProductsApi.Application/Products/Commands/CreateProduct/CreateProductCommand.cs`
- [Replace product](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Products/Commands/UpdateProduct/UpdateProductCommand.cs): `src/ProductsApi.Application/Products/Commands/UpdateProduct/UpdateProductCommand.cs`
- [Patch product](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Products/Commands/PatchProduct/PatchProductCommand.cs): `src/ProductsApi.Application/Products/Commands/PatchProduct/PatchProductCommand.cs`
- [Delete product](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Products/Commands/DeleteProduct/DeleteProductCommand.cs): `src/ProductsApi.Application/Products/Commands/DeleteProduct/DeleteProductCommand.cs`
- [Product queries](https://github.com/alejandrafrancog/products-api/tree/main/src/ProductsApi.Application/Products/Queries): `src/ProductsApi.Application/Products/Queries`
- [Read-store port](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Abstractions/Data/IProductsReadStore.cs): `src/ProductsApi.Application/Abstractions/Data/IProductsReadStore.cs`
- [Not-found error](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Application/Common/NotFoundException.cs): `src/ProductsApi.Application/Common/NotFoundException.cs`

### Product domain

- [Product aggregate](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Domain/Products/Product.cs): `src/ProductsApi.Domain/Products/Product.cs`
- [Domain error](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Domain/DomainException.cs): `src/ProductsApi.Domain/DomainException.cs`
- [Write repository port](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Domain/Products/IProductRepository.cs): `src/ProductsApi.Domain/Products/IProductRepository.cs`

### Persistence

- [Infrastructure wiring](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Infrastructure/DependencyInjection.cs): `src/ProductsApi.Infrastructure/DependencyInjection.cs`
- [Product repository](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Infrastructure/Persistence/ProductRepository.cs): `src/ProductsApi.Infrastructure/Persistence/ProductRepository.cs`
- [Product read store](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Infrastructure/ReadModels/ProductsReadStore.cs): `src/ProductsApi.Infrastructure/ReadModels/ProductsReadStore.cs`
- [EF unit of work](https://github.com/alejandrafrancog/products-api/blob/main/src/ProductsApi.Infrastructure/Persistence/AppDbContext.cs): `src/ProductsApi.Infrastructure/Persistence/AppDbContext.cs`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → Product endpoints: sends requests (evidence: `src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs`)
- Product endpoints → Message sender: dispatches messages (evidence: `src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs`)
- Product endpoints → Create product: sends command (evidence: `src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs`)
- Product endpoints → Replace product: sends command (evidence: `src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs`)
- Product endpoints → Patch product: sends command (evidence: `src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs`)
- Product endpoints → Delete product: sends command (evidence: `src/ProductsApi.Api/Endpoints/ProductsEndpoints.cs`)
- Product endpoints → Product queries: sends queries (evidence: `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 (evidence: `src/ProductsApi.Application/Products/Commands/CreateProduct/CreateProductCommand.cs`)
- Replace product → Write repository port: uses repository (evidence: `src/ProductsApi.Application/Products/Commands/UpdateProduct/UpdateProductCommand.cs`)
- Patch product → Write repository port: uses repository (evidence: `src/ProductsApi.Application/Products/Commands/PatchProduct/PatchProductCommand.cs`)
- Delete product → Write repository port: uses repository (evidence: `src/ProductsApi.Application/Products/Commands/DeleteProduct/DeleteProductCommand.cs`)
- Product queries → Read-store port: reads through (evidence: `src/ProductsApi.Application/Products/Queries/CountAllProductsQuery.cs`)
- Product repository → EF unit of work: queries and changes (evidence: `src/ProductsApi.Infrastructure/Persistence/ProductRepository.cs`)
- Product read store → EF unit of work: projects queries (evidence: `src/ProductsApi.Infrastructure/ReadModels/ProductsReadStore.cs`)
- Infrastructure wiring → Product repository: registers implementation (evidence: `src/ProductsApi.Infrastructure/DependencyInjection.cs`)
- Infrastructure wiring → Product read store: registers implementation (evidence: `src/ProductsApi.Infrastructure/DependencyInjection.cs`)
- Write repository port → Product repository: implemented by (evidence: `src/ProductsApi.Infrastructure/DependencyInjection.cs`)
- Read-store port → Product read store: implemented by (evidence: `src/ProductsApi.Infrastructure/DependencyInjection.cs`)
- EF unit of work → PostgreSQL: persists products
- Product repository → Product aggregate: loads aggregate (evidence: `src/ProductsApi.Infrastructure/Persistence/ProductRepository.cs`)
- Create product → Product aggregate: creates aggregate (evidence: `src/ProductsApi.Application/Products/Commands/CreateProduct/CreateProductCommand.cs`)
- Replace product → Product aggregate: updates aggregate (evidence: `src/ProductsApi.Application/Products/Commands/UpdateProduct/UpdateProductCommand.cs`)
- Patch product → Product aggregate: updates aggregate (evidence: `src/ProductsApi.Application/Products/Commands/PatchProduct/PatchProductCommand.cs`)
- Delete product → Not-found error: raises when absent (evidence: `src/ProductsApi.Application/Products/Commands/DeleteProduct/DeleteProductCommand.cs`)
- Exception mapping → Not-found error: maps to 404 (evidence: `src/ProductsApi.Api/ExceptionHandling/GlobalExceptionHandler.cs`)
- Exception mapping → Domain error: maps to 400 (evidence: `src/ProductsApi.Api/ExceptionHandling/GlobalExceptionHandler.cs`)
- Product aggregate → Domain error: raises on invalid data (evidence: `src/ProductsApi.Domain/Products/Product.cs`)
