# josehelioaraujo/eshop architecture

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

- Interactive diagram: https://gitdiagram.com/josehelioaraujo/eshop
- Repository: https://github.com/josehelioaraujo/eshop

## Overview

#### Purpose and startup
eShop “AdventureWorks” is a .NET 9 reference e-commerce system built as independently runnable services, background processors, and multiple client experiences. The primary local entry point is the .NET Aspire orchestrator at `src/eShop.AppHost/Program.cs`; run it to provision service dependencies and expose the Aspire dashboard. Service executables use their own `Program.cs`, notably `src/Catalog.API/Program.cs`, `src/Ordering.API/Program.cs`, and `src/WebApp/Program.cs`.

#### Client and edge experiences
The main storefront is a Blazor web application with catalog, cart, checkout, account, and order-status UI. It maintains browser/session-facing basket state and calls backend services through its service layer.
- `src/WebApp/Components/Pages/Checkout/Checkout.razor`
- `src/WebApp/Services/BasketService.cs`
- `src/WebApp/Services/OrderingService.cs`

Two MAUI clients are included: a full native/XAML client with MVVM services and a Blazor Hybrid catalog client. They are alternative consumers rather than required server-side components.
- `src/ClientApp/MauiProgram.cs`
- `src/ClientApp/ViewModels/CheckoutViewModel.cs`
- `src/HybridApp/MauiProgram.cs`

#### Identity and service boundaries
`Identity.API` is the authentication/authorization authority; its account, consent, device, and profile surfaces support interactive client sign-in and downstream service identity propagation. Shared service-default extensions centralize cross-cutting service configuration, including authentication and HTTP client behavior.
- `src/Identity.API/Program.cs`
- `src/Identity.API/Configuration/Config.cs`
- `src/eShop.ServiceDefaults/AuthenticationExtensions.cs`

#### Catalog and basket
Catalog owns products, brands, types, inventory-related event handling, sample seeding, and catalog persistence. Its minimal API layer is separated from EF Core context/entity configuration and integration-event publication. Basket owns per-customer basket persistence in Redis and exposes a gRPC contract; clients and ordering consume basket-shaped models rather than its storage implementation.
- `src/Catalog.API/Apis/CatalogApi.cs`
- `src/Catalog.API/Infrastructure/CatalogContext.cs`
- `src/Basket.API/Grpc/BasketService.cs`
- `src/Basket.API/Repositories/RedisBasketRepository.cs`

#### Ordering workflow and persistence
Ordering is the core transactional domain. API commands enter an application layer with validation, logging, transaction, and idempotency behaviors; handlers update `Order` and `Buyer` aggregates through EF Core repositories. Query models are separated from command/domain processing. Order-state transitions emit domain and integration events.
- `src/Ordering.API/Apis/OrdersApi.cs`
- `src/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs`
- `src/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs`
- `src/Ordering.Infrastructure/OrderingContext.cs`

#### Asynchronous fulfillment pipeline
RabbitMQ-backed integration events decouple order, catalog, payment, basket, web UI notifications, and webhooks. Catalog validates/reserves stock in reaction to ordering events; payment and grace-period processors advance or reject the order lifecycle; ordering consumes their outcomes. EF-backed integration-event logs/outbox migrations support reliable publication alongside service database changes.
- `src/EventBusRabbitMQ/RabbitMQEventBus.cs`
- `src/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs`
- `src/PaymentProcessor/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs`
- `src/OrderProcessor/Services/GracePeriodManagerService.cs`
- `src/IntegrationEventLogEF/Services/IntegrationEventLogService.cs`

#### Webhooks, AI, and infrastructure
The webhooks service stores subscriptions and forwards selected catalog/order events to external callback URLs; `WebhookClient` is a separate UI/receiver for registering and viewing them. Catalog optionally uses Azure OpenAI, enabled through the AppHost connection configuration. Local execution requires Docker and Aspire-managed infrastructure; deployment is designed for Azure Developer CLI.
- `src/Webhooks.API/Apis/WebHooksApi.cs`
- `src/Webhooks.API/Services/WebhooksSender.cs`
- `src/WebhookClient/Endpoints/WebhookEndpoints.cs`
- `src/Catalog.API/Services/CatalogAI.cs`

Main entry points: [`src/EventBusRabbitMQ/RabbitMQEventBus.cs`](https://github.com/josehelioaraujo/eshop/blob/main/src/EventBusRabbitMQ/RabbitMQEventBus.cs) (RabbitMQ event bus), [`src/Catalog.API/Apis/CatalogApi.cs`](https://github.com/josehelioaraujo/eshop/blob/main/src/Catalog.API/Apis/CatalogApi.cs) (Catalog API), [`src/Ordering.API/Apis/OrdersApi.cs`](https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.API/Apis/OrdersApi.cs) (Orders API), [`src/eShop.AppHost/Program.cs`](https://github.com/josehelioaraujo/eshop/blob/main/src/eShop.AppHost/Program.cs) (Aspire AppHost)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hosting["Hosting"]
  node_apphost{{"Aspire AppHost<br/>orchestrator<br/>[Program.cs]"}}
  node_defaults["Service defaults<br/>cross-cutting extensions"]
end

subgraph group_clients["Client experiences"]
  node_webapp["Blazor storefront<br/>web client<br/>[Checkout.razor]"]
  node_webapp_basket["Basket service layer<br/>client service<br/>[BasketService.cs]"]
  node_webapp_ordering["Ordering service layer<br/>client service<br/>[OrderingService.cs]"]
  node_maui["MAUI client<br/>native client<br/>[MauiProgram.cs]"]
  node_hybrid["Blazor Hybrid client<br/>[MauiProgram.cs]"]
end

subgraph group_services["Core services"]
  node_identity["Identity API<br/>auth service<br/>[Program.cs]"]
  node_catalog_api["Catalog API<br/>catalog service<br/>[CatalogApi.cs]"]
  node_catalog_db[("Catalog context<br/>EF Core persistence<br/>[CatalogContext.cs]")]
  node_catalog_ai["Catalog AI<br/>AI service<br/>[CatalogAI.cs]"]
  node_basket["Basket API<br/>gRPC service<br/>[BasketService.cs]"]
  node_redis_basket[("Redis basket store<br/>Redis repository")]
end

subgraph group_ordering["Ordering workflow"]
  node_ordering_api["Orders API<br/>ordering service<br/>[OrdersApi.cs]"]
  node_create_order["Create order handler<br/>application command handler"]
  node_order_domain["Order aggregate<br/>domain aggregate<br/>[Order.cs]"]
  node_ordering_db[("Ordering context<br/>EF Core persistence<br/>[OrderingContext.cs]")]
end

subgraph group_async["Async processors"]
  node_event_bus["RabbitMQ event bus<br/>integration event bus"]
  node_ordering_events["Ordering event service<br/>outbox publisher"]
  node_payment["Payment processor<br/>background processor"]
  node_grace_period["Grace period processor<br/>background processor"]
  node_event_log[("Integration event log<br/>EF outbox log")]
end

subgraph group_integration["Integration delivery"]
  node_webhooks["Webhooks API<br/>webhook service<br/>[WebHooksApi.cs]"]
  node_webhook_sender["Webhook sender<br/>callback delivery<br/>[WebhooksSender.cs]"]
  node_webhook_client["Webhook client<br/>webhook UI/receiver"]
end

node_apphost -->|"runs"| node_identity
node_apphost -->|"runs"| node_catalog_api
node_apphost -->|"runs"| node_ordering_api
node_apphost -->|"provisions"| node_event_bus
node_defaults -.->|"auth configuration"| node_identity
node_webapp -->|"uses"| node_webapp_basket
node_webapp -->|"uses"| node_webapp_ordering
node_webapp -->|"signs in"| node_identity
node_webapp_basket -->|"gRPC"| node_basket
node_webapp_ordering -->|"order requests"| node_ordering_api
node_maui -->|"authenticates"| node_identity
node_maui -->|"orders"| node_ordering_api
node_hybrid -->|"catalog requests"| node_catalog_api
node_catalog_api -->|"persists catalog"| node_catalog_db
node_catalog_api -.->|"optional AI"| node_catalog_ai
node_basket -->|"persists baskets"| node_redis_basket
node_ordering_api -->|"dispatches command"| node_create_order
node_create_order -->|"updates"| node_order_domain
node_order_domain -->|"persisted by"| node_ordering_db
node_create_order -->|"emits events"| node_ordering_events
node_ordering_events -->|"records publication"| node_event_log
node_ordering_events -->|"publishes"| node_event_bus
node_event_bus -->|"stock events"| node_catalog_api
node_event_bus -->|"stock confirmed"| node_payment
node_event_bus -->|"order events"| node_grace_period
node_payment -->|"payment outcome"| node_event_bus
node_grace_period -->|"lifecycle outcome"| node_event_bus
node_event_bus -->|"consumes outcomes"| node_ordering_api
node_webhook_client -->|"manages subscriptions"| node_webhooks
node_event_bus -->|"selected events"| node_webhooks
node_webhooks -->|"delivers callbacks"| node_webhook_sender

click node_apphost "https://github.com/josehelioaraujo/eshop/blob/main/src/eShop.AppHost/Program.cs"
click node_defaults "https://github.com/josehelioaraujo/eshop/blob/main/src/eShop.ServiceDefaults/AuthenticationExtensions.cs"
click node_webapp "https://github.com/josehelioaraujo/eshop/blob/main/src/WebApp/Components/Pages/Checkout/Checkout.razor"
click node_webapp_basket "https://github.com/josehelioaraujo/eshop/blob/main/src/WebApp/Services/BasketService.cs"
click node_webapp_ordering "https://github.com/josehelioaraujo/eshop/blob/main/src/WebApp/Services/OrderingService.cs"
click node_maui "https://github.com/josehelioaraujo/eshop/blob/main/src/ClientApp/MauiProgram.cs"
click node_hybrid "https://github.com/josehelioaraujo/eshop/blob/main/src/HybridApp/MauiProgram.cs"
click node_identity "https://github.com/josehelioaraujo/eshop/blob/main/src/Identity.API/Program.cs"
click node_catalog_api "https://github.com/josehelioaraujo/eshop/blob/main/src/Catalog.API/Apis/CatalogApi.cs"
click node_catalog_db "https://github.com/josehelioaraujo/eshop/blob/main/src/Catalog.API/Infrastructure/CatalogContext.cs"
click node_catalog_ai "https://github.com/josehelioaraujo/eshop/blob/main/src/Catalog.API/Services/CatalogAI.cs"
click node_basket "https://github.com/josehelioaraujo/eshop/blob/main/src/Basket.API/Grpc/BasketService.cs"
click node_redis_basket "https://github.com/josehelioaraujo/eshop/blob/main/src/Basket.API/Repositories/RedisBasketRepository.cs"
click node_ordering_api "https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.API/Apis/OrdersApi.cs"
click node_create_order "https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs"
click node_order_domain "https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs"
click node_ordering_db "https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.Infrastructure/OrderingContext.cs"
click node_event_bus "https://github.com/josehelioaraujo/eshop/blob/main/src/EventBusRabbitMQ/RabbitMQEventBus.cs"
click node_ordering_events "https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs"
click node_payment "https://github.com/josehelioaraujo/eshop/blob/main/src/PaymentProcessor/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs"
click node_grace_period "https://github.com/josehelioaraujo/eshop/blob/main/src/OrderProcessor/Services/GracePeriodManagerService.cs"
click node_event_log "https://github.com/josehelioaraujo/eshop/blob/main/src/IntegrationEventLogEF/Services/IntegrationEventLogService.cs"
click node_webhooks "https://github.com/josehelioaraujo/eshop/blob/main/src/Webhooks.API/Apis/WebHooksApi.cs"
click node_webhook_sender "https://github.com/josehelioaraujo/eshop/blob/main/src/Webhooks.API/Services/WebhooksSender.cs"
click node_webhook_client "https://github.com/josehelioaraujo/eshop/blob/main/src/WebhookClient/Endpoints/WebhookEndpoints.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_apphost,node_defaults toneBlue
class node_webapp,node_webapp_basket,node_webapp_ordering,node_maui,node_hybrid toneAmber
class node_identity,node_catalog_api,node_catalog_db,node_catalog_ai,node_basket,node_redis_basket toneMint
class node_ordering_api,node_create_order,node_order_domain,node_ordering_db toneRose
class node_event_bus,node_ordering_events,node_payment,node_grace_period,node_event_log toneIndigo
class node_webhooks,node_webhook_sender,node_webhook_client toneTeal
```

## Components

### Hosting

- [Aspire AppHost](https://github.com/josehelioaraujo/eshop/blob/main/src/eShop.AppHost/Program.cs): orchestrator · Provisions local dependencies and service topology. · `src/eShop.AppHost/Program.cs`
- [Service defaults](https://github.com/josehelioaraujo/eshop/blob/main/src/eShop.ServiceDefaults/AuthenticationExtensions.cs): cross-cutting extensions · Centralizes service authentication and HTTP behavior. · `src/eShop.ServiceDefaults/AuthenticationExtensions.cs`

### Client experiences

- [Blazor storefront](https://github.com/josehelioaraujo/eshop/blob/main/src/WebApp/Components/Pages/Checkout/Checkout.razor): web client · Storefront for catalog, cart, checkout, accounts, and order status. · `src/WebApp/Components/Pages/Checkout/Checkout.razor`
- [Basket service layer](https://github.com/josehelioaraujo/eshop/blob/main/src/WebApp/Services/BasketService.cs): client service · `src/WebApp/Services/BasketService.cs`
- [Ordering service layer](https://github.com/josehelioaraujo/eshop/blob/main/src/WebApp/Services/OrderingService.cs): client service · `src/WebApp/Services/OrderingService.cs`
- [MAUI client](https://github.com/josehelioaraujo/eshop/blob/main/src/ClientApp/MauiProgram.cs): native client · Alternative native/XAML consumer. · `src/ClientApp/MauiProgram.cs`
- [Blazor Hybrid client](https://github.com/josehelioaraujo/eshop/blob/main/src/HybridApp/MauiProgram.cs): hybrid client · Alternative catalog consumer. · `src/HybridApp/MauiProgram.cs`

### Core services

- [Identity API](https://github.com/josehelioaraujo/eshop/blob/main/src/Identity.API/Program.cs): auth service · Interactive sign-in and downstream identity authority. · `src/Identity.API/Program.cs`
- [Catalog API](https://github.com/josehelioaraujo/eshop/blob/main/src/Catalog.API/Apis/CatalogApi.cs): catalog service · Owns product catalog and inventory event handling. · `src/Catalog.API/Apis/CatalogApi.cs`
- [Catalog context](https://github.com/josehelioaraujo/eshop/blob/main/src/Catalog.API/Infrastructure/CatalogContext.cs): EF Core persistence · `src/Catalog.API/Infrastructure/CatalogContext.cs`
- [Catalog AI](https://github.com/josehelioaraujo/eshop/blob/main/src/Catalog.API/Services/CatalogAI.cs): AI service · Optional Azure OpenAI-backed catalog capability. · `src/Catalog.API/Services/CatalogAI.cs`
- [Basket API](https://github.com/josehelioaraujo/eshop/blob/main/src/Basket.API/Grpc/BasketService.cs): gRPC service · Exposes per-customer basket contracts. · `src/Basket.API/Grpc/BasketService.cs`
- [Redis basket store](https://github.com/josehelioaraujo/eshop/blob/main/src/Basket.API/Repositories/RedisBasketRepository.cs): Redis repository · `src/Basket.API/Repositories/RedisBasketRepository.cs`

### Ordering workflow

- [Orders API](https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.API/Apis/OrdersApi.cs): ordering service · Accepts order commands and serves order operations. · `src/Ordering.API/Apis/OrdersApi.cs`
- [Create order handler](https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs): application command handler · Runs transactional, validated, idempotent order creation. · `src/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs`
- [Order aggregate](https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs): domain aggregate · Encapsulates order lifecycle transitions. · `src/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs`
- [Ordering context](https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.Infrastructure/OrderingContext.cs): EF Core persistence · Stores ordering aggregates and query data. · `src/Ordering.Infrastructure/OrderingContext.cs`

### Async processors

- [RabbitMQ event bus](https://github.com/josehelioaraujo/eshop/blob/main/src/EventBusRabbitMQ/RabbitMQEventBus.cs): integration event bus · Decouples services through integration events. · `src/EventBusRabbitMQ/RabbitMQEventBus.cs`
- [Ordering event service](https://github.com/josehelioaraujo/eshop/blob/main/src/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs): outbox publisher · Publishes ordering integration events reliably. · `src/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs`
- [Payment processor](https://github.com/josehelioaraujo/eshop/blob/main/src/PaymentProcessor/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs): background processor · Advances or rejects orders after stock confirmation. · `src/PaymentProcessor/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs`
- [Grace period processor](https://github.com/josehelioaraujo/eshop/blob/main/src/OrderProcessor/Services/GracePeriodManagerService.cs): background processor · Manages timed order lifecycle transitions. · `src/OrderProcessor/Services/GracePeriodManagerService.cs`
- [Integration event log](https://github.com/josehelioaraujo/eshop/blob/main/src/IntegrationEventLogEF/Services/IntegrationEventLogService.cs): EF outbox log · Persists publish state alongside database changes. · `src/IntegrationEventLogEF/Services/IntegrationEventLogService.cs`

### Integration delivery

- [Webhooks API](https://github.com/josehelioaraujo/eshop/blob/main/src/Webhooks.API/Apis/WebHooksApi.cs): webhook service · Stores subscriptions and selects events for delivery. · `src/Webhooks.API/Apis/WebHooksApi.cs`
- [Webhook sender](https://github.com/josehelioaraujo/eshop/blob/main/src/Webhooks.API/Services/WebhooksSender.cs): callback delivery · Forwards selected events to external URLs. · `src/Webhooks.API/Services/WebhooksSender.cs`
- [Webhook client](https://github.com/josehelioaraujo/eshop/blob/main/src/WebhookClient/Endpoints/WebhookEndpoints.cs): webhook UI/receiver · Registers and views webhook subscriptions. · `src/WebhookClient/Endpoints/WebhookEndpoints.cs`

## Connections

- Aspire AppHost → Identity API: runs
- Aspire AppHost → Catalog API: runs
- Aspire AppHost → Orders API: runs
- Aspire AppHost → RabbitMQ event bus: provisions
- Service defaults → Identity API: auth configuration
- Blazor storefront → Basket service layer: uses
- Blazor storefront → Ordering service layer: uses
- Blazor storefront → Identity API: signs in
- Basket service layer → Basket API: gRPC
- Ordering service layer → Orders API: order requests
- MAUI client → Identity API: authenticates
- MAUI client → Orders API: orders
- Blazor Hybrid client → Catalog API: catalog requests
- Catalog API → Catalog context: persists catalog
- Catalog API → Catalog AI: optional AI
- Basket API → Redis basket store: persists baskets
- Orders API → Create order handler: dispatches command
- Create order handler → Order aggregate: updates
- Order aggregate → Ordering context: persisted by
- Create order handler → Ordering event service: emits events
- Ordering event service → Integration event log: records publication
- Ordering event service → RabbitMQ event bus: publishes
- RabbitMQ event bus → Catalog API: stock events
- RabbitMQ event bus → Payment processor: stock confirmed
- RabbitMQ event bus → Grace period processor: order events
- Payment processor → RabbitMQ event bus: payment outcome
- Grace period processor → RabbitMQ event bus: lifecycle outcome
- RabbitMQ event bus → Orders API: consumes outcomes
- Webhook client → Webhooks API: manages subscriptions
- RabbitMQ event bus → Webhooks API: selected events
- Webhooks API → Webhook sender: delivers callbacks
