How sagizod/eshoponcontainers works
Purpose and execution
eShopOnContainers is a .NET Core 3.1 reference e-commerce system demonstrating independently deployable, containerized microservices. Local composition starts from src/docker-compose.yml; the solution entry is src/eShopOnContainers-ServicesAndWebApps.sln. Each service is an ASP.NET Core process with its own Docker image and Program.cs/Startup.cs host boundary.
Client and edge layer
Browser clients are server-rendered MVC and an Angular SPA; a status site and webhook demo client are auxiliary entry points.
• MVC storefront: src/Web/WebMVC/Program.cs, src/Web/WebMVC/Controllers/CatalogController.cs
• Angular SPA hosted by ASP.NET Core: src/Web/WebSPA/Client/main.ts, src/Web/WebSPA/Startup.cs
• Separate mobile and web shopping BFFs aggregate downstream basket, catalog, and ordering calls: src/ApiGateways/Web.Bff.Shopping/aggregator/Startup.cs, src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/OrderController.cs
• Envoy gateway configurations define edge routing per client type: src/ApiGateways/Envoy/config/webshopping/envoy.yaml, src/ApiGateways/Envoy/config/mobileshopping/envoy.yaml.
Identity and service communication
Identity.API is the OAuth/OIDC identity boundary used by clients and protected APIs. BFFs and web applications propagate authorization via HTTP delegating handlers; internal service reads also expose gRPC contracts where present.
• Identity host/configuration: src/Services/Identity/Identity.API/Startup.cs, src/Services/Identity/Identity.API/Configuration/Config.cs
• Authorization propagation: src/ApiGateways/Web.Bff.Shopping/aggregator/Infrastructure/HttpClientAuthorizationDelegatingHandler.cs
• gRPC boundaries: src/Services/Basket/Basket.API/Proto/basket.proto, src/Services/Catalog/Catalog.API/Proto/catalog.proto, src/Services/Ordering/Ordering.API/Proto/ordering.proto.
Catalog and basket domains
Catalog owns product, brand/type, stock, and picture data through EF Core; Basket owns per-customer carts in Redis. Basket checkout publishes an integration event rather than synchronously creating an order.
• Catalog HTTP/gRPC API and persistence: src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs, src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs
• Basket API and Redis repository: src/Services/Basket/Basket.API/Controllers/BasketController.cs, src/Services/Basket/Basket.API/Infrastructure/Repositories/RedisBasketRepository.cs
• Checkout event contract: src/Services/Basket/Basket.API/IntegrationEvents/Events/UserCheckoutAcceptedIntegrationEvent.cs.
Ordering workflow and payment saga
Ordering is the primary DDD/CQRS subsystem: commands enter its API, MediatR-style behaviors enforce validation, transactionality, and idempotency, and aggregates persist orders/buyers. It consumes checkout, payment, and stock events, emits order-status events, and drives a distributed workflow. Payment reacts after stock confirmation; a background worker manages the grace period; SignalR broadcasts lifecycle updates.
• API commands/workflow: src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs, src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs
• Domain and persistence: src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs, src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs
• Payment, background, and notifications: src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs, src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs, src/Services/Ordering/Ordering.SignalrHub/NotificationHub.cs.
Eventing and external notifications
The shared EventBus abstracts RabbitMQ or Azure Service Bus. EF-backed integration-event logs support reliable publication alongside service database transactions. Catalog price/stock changes and ordering statuses fan out asynchronously to basket, payment, catalog, SignalR, and webhook subscribers. Webhooks stores subscriptions and delivers outbound HTTP callbacks.
• Bus abstractions/transports: src/BuildingBlocks/EventBus/EventBus/Abstractions/IEventBus.cs, src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs, src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs
• Transactional event log: src/BuildingBlocks/EventBus/IntegrationEventLogEF/Services/IntegrationEventLogService.cs
• Webhook boundary: src/Services/Webhooks/Webhooks.API/Controllers/WebhooksController.cs, src/Services/Webhooks/Webhooks.API/Services/WebhooksSender.cs.
Infrastructure and deployment
The normal runtime is Docker Compose; Kubernetes Helm charts deploy the same service topology, including Envoy gateways, ingress, SQL, Redis, RabbitMQ, and shared secrets. Azure templates provision SQL, Redis, Service Bus, Cosmos DB, and catalog storage. ELK Compose assets provide centralized logging.
• Composition/deployment: src/docker-compose.yml, deploy/k8s/helm/app.yaml, deploy/k8s/helm/deploy-all.sh
• Cloud resources: deploy/azure/az/sql/sqldeploy.json, deploy/azure/az/redis/redisdeploy.json, deploy/azure/az/servicebus/sbusdeploy.json
• Observability stack: src/docker-compose.elk.yml, deploy/elk/logstash/pipeline/logstash.conf.
Main entry points: CreateOrderCommandHandler.cs Ordering API · Startup.cs Shopping BFFs · envoy.yaml Envoy Gateways · docker-compose.yml Docker Compose
Components 20
Clients & Edge
- MVC Storefront
src/Web/WebMVC/Program.cs - Angular SPA
src/Web/WebSPA/Client/main.ts - Envoy Gateways · Routes web and mobile client traffic to BFFs.
src/ApiGateways/Envoy/config/webshopping/envoy.yaml - Shopping BFFs · Separate web and mobile downstream aggregators.
src/ApiGateways/Web.Bff.Shopping/aggregator/Startup.cs
Business Services
- Identity API · Authenticates clients and protected API calls.
src/Services/Identity/Identity.API/Startup.cs - Catalog API · Owns products, stock, brands, types, and pictures.
src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs - Catalog database
src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs - Basket API · Checkout initiates the asynchronous ordering flow.
src/Services/Basket/Basket.API/Controllers/BasketController.cs - Redis baskets
src/Services/Basket/Basket.API/Infrastructure/Repositories/RedisBasketRepository.cs - Ordering API · Handles checkout and order commands through validation, transactions, and idempotency.
src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs - Order domain & store · Persists orders and buyers.
src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs - Payment API · Acts after stock confirmation.
src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs - Grace-period worker · Manages order payment grace periods.
src/Services/Ordering/Ordering.BackgroundTasks/Tasks/GracePeriodManagerTask.cs - Order notifications · Broadcasts order lifecycle updates.
src/Services/Ordering/Ordering.SignalrHub/NotificationHub.cs - Webhooks API · Stores subscriptions and delivers HTTP callbacks.
src/Services/Webhooks/Webhooks.API/Controllers/WebhooksController.cs
Async Platform
- Integration Event Bus · Publishes and consumes cross-service integration events.
- Transactional event log · Reliably publishes events with service database transactions.
src/BuildingBlocks/EventBus/IntegrationEventLogEF/Services/IntegrationEventLogService.cs
Deployment & Observability
- Docker Compose · Starts the containerized service topology.
src/docker-compose.yml - Kubernetes Helm · Deploys the same topology to Kubernetes.
deploy/k8s/helm/app.yaml - ELK logging · Centralizes container logs through Logstash.
src/docker-compose.elk.yml
Connections 24
- Docker Compose → MVC Storefront: runs
- Docker Compose → Integration Event Bus: runs
- Kubernetes Helm → Envoy Gateways: deploys
- MVC Storefront → Identity API: OAuth/OIDC
- Angular SPA → Identity API: OAuth/OIDC
- MVC Storefront → Envoy Gateways: API requests
- Angular SPA → Envoy Gateways: API requests
- Envoy Gateways → Shopping BFFs: routes by client
- Shopping BFFs → Catalog API: aggregates reads · Uses HTTP and gRPC service contracts.
- Shopping BFFs → Basket API: aggregates carts
- Shopping BFFs → Ordering API: aggregates orders
- Catalog API → Catalog database: persists
- Basket API → Redis baskets: stores carts
- Basket API → Transactional event log: records checkout event
- Transactional event log → Integration Event Bus: publishes reliably
- Integration Event Bus → Ordering API: checkout and status events
- Ordering API → Order domain & store: persists aggregates
- Ordering API → Transactional event log: records order events
- Integration Event Bus → Catalog API: stock and price events
- Integration Event Bus → Payment API: stock-confirmed event
- Integration Event Bus → Order notifications: order status events
- Integration Event Bus → Webhooks API: order and catalog events
- Grace-period worker → Ordering API: updates expired orders
- Docker Compose → ELK logging: starts logging stack