# kunwardivyrajs/eshop architecture

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

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

## Overview

#### Purpose and entry points
eShop “AdventureWorks” is a .NET 10 reference e-commerce system using service-oriented architecture and .NET Aspire. The primary local entry point is the Aspire AppHost, selected by `aspire.config.json`; it composes the distributed application and its dependencies. Application executables generally bootstrap in each service’s `Program.cs`.
- `src/eShop.AppHost/Program.cs`
- `aspire.config.json`
- `eShop.Web.slnf`

#### Distributed orchestration and shared platform
The AppHost coordinates service startup, service discovery/configuration, containerized dependencies, and deployment modeling. Shared service defaults centralize cross-cutting HTTP, authentication, configuration, and OpenAPI behavior. Local execution requires an OCI runtime; the documented deployment target is Azure Container Apps, with disposable PostgreSQL, Redis, and RabbitMQ containers.
- `src/eShop.AppHost/Extensions.cs`
- `src/eShop.ServiceDefaults/Extensions.cs`
- `src/eShop.ServiceDefaults/AuthenticationExtensions.cs`

#### Customer-facing clients
The main browser client is a Blazor web application for catalog browsing, cart, checkout, login, and order history. It holds browser-side basket state, calls backend services, and consumes order-status events for UI refresh. Two MAUI clients provide native/hybrid alternatives: an MVVM client and a Blazor Hybrid catalog client.
- `src/WebApp/Program.cs`
- `src/WebApp/Services/BasketState.cs`
- `src/ClientApp/MauiProgram.cs`
- `src/HybridApp/MauiProgram.cs`

#### Catalog and basket boundaries
Catalog is an HTTP API with EF Core persistence, migrations, seeded products, images, paging, and integration-event publishing. Basket is a separate gRPC API backed by Redis; clients use its protobuf contract rather than accessing basket storage directly. Catalog’s integration handlers participate in stock and price-change workflows.
- `src/Catalog.API/Program.cs`
- `src/Catalog.API/Infrastructure/CatalogContext.cs`
- `src/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs`
- `src/Basket.API/Grpc/BasketService.cs`
- `src/Basket.API/Repositories/RedisBasketRepository.cs`

#### Ordering workflow and durable domain model
Ordering exposes API endpoints and applies a CQRS/mediator-style application layer: validated commands run through logging and transaction behaviors, mutate Buyer/Order aggregates, and expose query models separately. Ordering persistence is EF Core with repositories and an idempotency request manager. The checkout flow creates/submits an order from basket data, then order status advances through validation, payment, stock confirmation/rejection, shipment, or cancellation.
- `src/Ordering.API/Apis/OrdersApi.cs`
- `src/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs`
- `src/Ordering.API/Application/Behaviors/TransactionBehavior.cs`
- `src/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs`
- `src/Ordering.Infrastructure/OrderingContext.cs`

#### Asynchronous integration pipeline
Services communicate state changes through shared event-bus abstractions with a RabbitMQ implementation. Catalog and Ordering use integration-event services plus EF-backed event logging/outbox infrastructure to couple database updates with eventual publication. Payment and grace-period processors are standalone background executables that consume/publish order events; their results drive Ordering state transitions. WebApp subscribes to status events for customer notifications.
- `src/EventBus/Abstractions/IEventBus.cs`
- `src/EventBusRabbitMQ/RabbitMQEventBus.cs`
- `src/IntegrationEventLogEF/Services/IntegrationEventLogService.cs`
- `src/PaymentProcessor/Program.cs`
- `src/OrderProcessor/Services/GracePeriodManagerService.cs`

#### Identity, webhooks, and optional AI
Identity is a dedicated ASP.NET Core/IdentityServer-style authentication authority with EF-backed users and account/consent flows; clients and services authenticate across this boundary. Webhooks persist subscriptions and relay selected catalog/order events to registered external endpoints; a separate client manages subscriptions and received messages. An optional AppHost-enabled Microsoft Foundry integration supplies chat and embedding connections for the web chatbot, using Foundry deployments when `UseFoundry=true`.
- `src/Identity.API/Program.cs`
- `src/Identity.API/Data/ApplicationDbContext.cs`
- `src/Webhooks.API/Apis/WebHooksApi.cs`
- `src/Webhooks.API/Services/WebhooksSender.cs`
- `src/WebApp/Components/Chatbot/MessageProcessor.cs`

Main entry points: [`src/EventBusRabbitMQ/RabbitMQEventBus.cs`](https://github.com/kunwardivyrajs/eshop/blob/main/src/EventBusRabbitMQ/RabbitMQEventBus.cs) (RabbitMQ Event Bus), [`src/Catalog.API/Program.cs`](https://github.com/kunwardivyrajs/eshop/blob/main/src/Catalog.API/Program.cs) (Catalog API), [`src/eShop.AppHost/Program.cs`](https://github.com/kunwardivyrajs/eshop/blob/main/src/eShop.AppHost/Program.cs) (Aspire AppHost), [`src/WebApp/Program.cs`](https://github.com/kunwardivyrajs/eshop/blob/main/src/WebApp/Program.cs) (Blazor WebApp)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Orchestration"]
  node_apphost{{"Aspire AppHost<br/>orchestrator<br/>[Program.cs]"}}
  node_service_defaults["Service Defaults<br/>shared platform<br/>[Extensions.cs]"]
end

subgraph group_clients["Clients"]
  node_webapp["Blazor WebApp<br/>browser client<br/>[Program.cs]"]
  node_maui_client["MAUI Client<br/>native client<br/>[MauiProgram.cs]"]
  node_hybrid_client["Blazor Hybrid<br/>hybrid client<br/>[MauiProgram.cs]"]
end

subgraph group_commerce["Commerce services"]
  node_catalog["Catalog API<br/>HTTP API<br/>[Program.cs]"]
  node_catalog_db[("Catalog database<br/>EF Core store<br/>[CatalogContext.cs]")]
  node_basket["Basket API<br/>gRPC API<br/>[BasketService.cs]"]
  node_redis[("Redis<br/>basket store")]
  node_ordering_api["Ordering API<br/>HTTP API<br/>[OrdersApi.cs]"]
  node_ordering_app["Order command layer<br/>CQRS application"]
  node_order_domain["Order aggregates<br/>domain model<br/>[Order.cs]"]
  node_ordering_db[("Ordering database<br/>EF Core store<br/>[OrderingContext.cs]")]
end

subgraph group_events["Event pipeline"]
  node_eventbus["RabbitMQ Event Bus<br/>message broker"]
  node_outbox[("Integration event log<br/>outbox")]
  node_payment["Payment Processor<br/>background worker<br/>[Program.cs]"]
  node_grace_processor["Grace-period Processor<br/>background worker"]
end

subgraph group_platform["Platform services"]
  node_identity["Identity API<br/>authentication authority<br/>[Program.cs]"]
  node_webhooks["Webhooks API<br/>webhook service<br/>[WebHooksApi.cs]"]
  node_external_endpoints(("Registered endpoints<br/>external consumers"))
  node_foundry_chat["Foundry Chat<br/>optional AI integration"]
end

node_apphost -->|"applies defaults"| node_service_defaults
node_apphost -->|"starts"| node_catalog
node_apphost -->|"starts"| node_basket
node_apphost -->|"starts"| node_ordering_api
node_apphost -->|"provisions"| node_eventbus
node_apphost -->|"provisions"| node_redis
node_webapp -->|"browses catalog"| node_catalog
node_webapp -->|"basket gRPC"| node_basket
node_webapp -->|"checkout and orders"| node_ordering_api
node_maui_client -->|"catalog access"| node_catalog
node_hybrid_client -->|"catalog access"| node_catalog
node_webapp -->|"sign-in"| node_identity
node_webapp -.->|"chat requests"| node_foundry_chat
node_catalog -->|"persists"| node_catalog_db
node_basket -->|"reads and writes"| node_redis
node_ordering_api -->|"dispatches commands"| node_ordering_app
node_ordering_app -->|"mutates"| node_order_domain
node_ordering_app -->|"transactional persistence"| node_ordering_db
node_catalog -->|"records events"| node_outbox
node_ordering_app -->|"records events"| node_outbox
node_outbox -->|"eventual publish"| node_eventbus
node_eventbus -->|"order events"| node_payment
node_payment -->|"payment result"| node_eventbus
node_eventbus -->|"order events"| node_grace_processor
node_grace_processor -->|"status result"| node_eventbus
node_eventbus -->|"status transitions"| node_ordering_api
node_eventbus -->|"order status"| node_webapp
node_eventbus -->|"selected events"| node_webhooks
node_webhooks -->|"delivers webhooks"| node_external_endpoints
node_identity -.->|"service/client auth"| node_catalog
node_identity -.->|"service/client auth"| node_ordering_api

click node_apphost "https://github.com/kunwardivyrajs/eshop/blob/main/src/eShop.AppHost/Program.cs"
click node_service_defaults "https://github.com/kunwardivyrajs/eshop/blob/main/src/eShop.ServiceDefaults/Extensions.cs"
click node_webapp "https://github.com/kunwardivyrajs/eshop/blob/main/src/WebApp/Program.cs"
click node_maui_client "https://github.com/kunwardivyrajs/eshop/blob/main/src/ClientApp/MauiProgram.cs"
click node_hybrid_client "https://github.com/kunwardivyrajs/eshop/blob/main/src/HybridApp/MauiProgram.cs"
click node_catalog "https://github.com/kunwardivyrajs/eshop/blob/main/src/Catalog.API/Program.cs"
click node_catalog_db "https://github.com/kunwardivyrajs/eshop/blob/main/src/Catalog.API/Infrastructure/CatalogContext.cs"
click node_basket "https://github.com/kunwardivyrajs/eshop/blob/main/src/Basket.API/Grpc/BasketService.cs"
click node_redis "https://github.com/kunwardivyrajs/eshop/blob/main/src/Basket.API/Repositories/RedisBasketRepository.cs"
click node_ordering_api "https://github.com/kunwardivyrajs/eshop/blob/main/src/Ordering.API/Apis/OrdersApi.cs"
click node_ordering_app "https://github.com/kunwardivyrajs/eshop/blob/main/src/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs"
click node_order_domain "https://github.com/kunwardivyrajs/eshop/blob/main/src/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs"
click node_ordering_db "https://github.com/kunwardivyrajs/eshop/blob/main/src/Ordering.Infrastructure/OrderingContext.cs"
click node_eventbus "https://github.com/kunwardivyrajs/eshop/blob/main/src/EventBusRabbitMQ/RabbitMQEventBus.cs"
click node_outbox "https://github.com/kunwardivyrajs/eshop/blob/main/src/IntegrationEventLogEF/Services/IntegrationEventLogService.cs"
click node_payment "https://github.com/kunwardivyrajs/eshop/blob/main/src/PaymentProcessor/Program.cs"
click node_grace_processor "https://github.com/kunwardivyrajs/eshop/blob/main/src/OrderProcessor/Services/GracePeriodManagerService.cs"
click node_identity "https://github.com/kunwardivyrajs/eshop/blob/main/src/Identity.API/Program.cs"
click node_webhooks "https://github.com/kunwardivyrajs/eshop/blob/main/src/Webhooks.API/Apis/WebHooksApi.cs"
click node_foundry_chat "https://github.com/kunwardivyrajs/eshop/blob/main/src/WebApp/Components/Chatbot/MessageProcessor.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_service_defaults toneBlue
class node_webapp,node_maui_client,node_hybrid_client toneAmber
class node_catalog,node_catalog_db,node_basket,node_redis,node_ordering_api,node_ordering_app,node_order_domain,node_ordering_db toneMint
class node_eventbus,node_outbox,node_payment,node_grace_processor toneRose
class node_identity,node_webhooks,node_external_endpoints,node_foundry_chat toneIndigo
```

## Components

### Orchestration

- [Aspire AppHost](https://github.com/kunwardivyrajs/eshop/blob/main/src/eShop.AppHost/Program.cs): orchestrator · Composes local services, containers, discovery, and deployment resources. · `src/eShop.AppHost/Program.cs`
- [Service Defaults](https://github.com/kunwardivyrajs/eshop/blob/main/src/eShop.ServiceDefaults/Extensions.cs): shared platform · Standardizes HTTP, auth, configuration, and OpenAPI. · `src/eShop.ServiceDefaults/Extensions.cs`

### Clients

- [Blazor WebApp](https://github.com/kunwardivyrajs/eshop/blob/main/src/WebApp/Program.cs): browser client · Customer storefront with basket state and order-status refresh. · `src/WebApp/Program.cs`
- [MAUI Client](https://github.com/kunwardivyrajs/eshop/blob/main/src/ClientApp/MauiProgram.cs): native client · `src/ClientApp/MauiProgram.cs`
- [Blazor Hybrid](https://github.com/kunwardivyrajs/eshop/blob/main/src/HybridApp/MauiProgram.cs): hybrid client · `src/HybridApp/MauiProgram.cs`

### Commerce services

- [Catalog API](https://github.com/kunwardivyrajs/eshop/blob/main/src/Catalog.API/Program.cs): HTTP API · Serves products and publishes catalog changes. · `src/Catalog.API/Program.cs`
- [Catalog database](https://github.com/kunwardivyrajs/eshop/blob/main/src/Catalog.API/Infrastructure/CatalogContext.cs): EF Core store · Products, images, migrations, and seed data. · `src/Catalog.API/Infrastructure/CatalogContext.cs`
- [Basket API](https://github.com/kunwardivyrajs/eshop/blob/main/src/Basket.API/Grpc/BasketService.cs): gRPC API · Owns customer basket access through its protobuf contract. · `src/Basket.API/Grpc/BasketService.cs`
- [Redis](https://github.com/kunwardivyrajs/eshop/blob/main/src/Basket.API/Repositories/RedisBasketRepository.cs): basket store · `src/Basket.API/Repositories/RedisBasketRepository.cs`
- [Ordering API](https://github.com/kunwardivyrajs/eshop/blob/main/src/Ordering.API/Apis/OrdersApi.cs): HTTP API · Receives checkout and order-query requests. · `src/Ordering.API/Apis/OrdersApi.cs`
- [Order command layer](https://github.com/kunwardivyrajs/eshop/blob/main/src/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs): CQRS application · Validates and transacts create-order commands. · `src/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs`
- [Order aggregates](https://github.com/kunwardivyrajs/eshop/blob/main/src/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs): domain model · Buyer and Order lifecycle state. · `src/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs`
- [Ordering database](https://github.com/kunwardivyrajs/eshop/blob/main/src/Ordering.Infrastructure/OrderingContext.cs): EF Core store · Persists orders, repositories, and idempotency data. · `src/Ordering.Infrastructure/OrderingContext.cs`

### Event pipeline

- [RabbitMQ Event Bus](https://github.com/kunwardivyrajs/eshop/blob/main/src/EventBusRabbitMQ/RabbitMQEventBus.cs): message broker · Shared asynchronous integration transport. · `src/EventBusRabbitMQ/RabbitMQEventBus.cs`
- [Integration event log](https://github.com/kunwardivyrajs/eshop/blob/main/src/IntegrationEventLogEF/Services/IntegrationEventLogService.cs): outbox · EF-backed durable publication record for service changes. · `src/IntegrationEventLogEF/Services/IntegrationEventLogService.cs`
- [Payment Processor](https://github.com/kunwardivyrajs/eshop/blob/main/src/PaymentProcessor/Program.cs): background worker · Consumes order events and publishes payment outcomes. · `src/PaymentProcessor/Program.cs`
- [Grace-period Processor](https://github.com/kunwardivyrajs/eshop/blob/main/src/OrderProcessor/Services/GracePeriodManagerService.cs): background worker · Advances delayed order processing and cancellation paths. · `src/OrderProcessor/Services/GracePeriodManagerService.cs`

### Platform services

- [Identity API](https://github.com/kunwardivyrajs/eshop/blob/main/src/Identity.API/Program.cs): authentication authority · IdentityServer-style users, login, consent, and tokens. · `src/Identity.API/Program.cs`
- [Webhooks API](https://github.com/kunwardivyrajs/eshop/blob/main/src/Webhooks.API/Apis/WebHooksApi.cs): webhook service · Stores subscriptions and relays selected commerce events. · `src/Webhooks.API/Apis/WebHooksApi.cs`
- **Registered endpoints**: external consumers
- [Foundry Chat](https://github.com/kunwardivyrajs/eshop/blob/main/src/WebApp/Components/Chatbot/MessageProcessor.cs): optional AI integration · Provides chat and embedding connections when enabled. · `src/WebApp/Components/Chatbot/MessageProcessor.cs`

## Connections

- Aspire AppHost → Service Defaults: applies defaults
- Aspire AppHost → Catalog API: starts
- Aspire AppHost → Basket API: starts
- Aspire AppHost → Ordering API: starts
- Aspire AppHost → RabbitMQ Event Bus: provisions
- Aspire AppHost → Redis: provisions
- Blazor WebApp → Catalog API: browses catalog
- Blazor WebApp → Basket API: basket gRPC
- Blazor WebApp → Ordering API: checkout and orders
- MAUI Client → Catalog API: catalog access
- Blazor Hybrid → Catalog API: catalog access
- Blazor WebApp → Identity API: sign-in
- Blazor WebApp → Foundry Chat: chat requests
- Catalog API → Catalog database: persists
- Basket API → Redis: reads and writes
- Ordering API → Order command layer: dispatches commands
- Order command layer → Order aggregates: mutates
- Order command layer → Ordering database: transactional persistence
- Catalog API → Integration event log: records events
- Order command layer → Integration event log: records events
- Integration event log → RabbitMQ Event Bus: eventual publish
- RabbitMQ Event Bus → Payment Processor: order events
- Payment Processor → RabbitMQ Event Bus: payment result
- RabbitMQ Event Bus → Grace-period Processor: order events
- Grace-period Processor → RabbitMQ Event Bus: status result
- RabbitMQ Event Bus → Ordering API: status transitions
- RabbitMQ Event Bus → Blazor WebApp: order status
- RabbitMQ Event Bus → Webhooks API: selected events
- Webhooks API → Registered endpoints: delivers webhooks
- Identity API → Catalog API: service/client auth
- Identity API → Ordering API: service/client auth
