# rahulsahay19/clean-architecture-dotnet-10 architecture

> Architecture diagram of the GitHub repository rahulsahay19/clean-architecture-dotnet-10, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rahulsahay19/clean-architecture-dotnet-10
- Repository: https://github.com/rahulsahay19/clean-architecture-dotnet-10

## Overview

This repository implements an event-driven e-commerce backend. The main customer journey is browsing catalog products, building a basket, checking out, and having Ordering coordinate payment outcomes; Identity provides authentication. README-described saga and outbox behavior is represented where source excerpts do not expose the full implementation. Dashed edges indicate documented but unsampled or otherwise unverified relationships.

Main entry points: [`ApiGateway/ApiGateway/Program.cs`](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/ApiGateway/ApiGateway/Program.cs) (API Gateway), [`Services/Ordering/Ordering.Application/Orders`](https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Ordering/Ordering.Application/Orders) (Order command and query handlers), [`Services/Basket/Basket.API/Controllers/BasketController.cs`](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Basket/Basket.API/Controllers/BasketController.cs) (Basket API), [`Services/Basket/Basket.Application/Handlers`](https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Basket/Basket.Application/Handlers) (Basket workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_catalog["Product Catalog"]
  node_catalog_api["Catalog API"]
  node_catalog_handlers["Catalog queries and commands<br/>[Handlers]"]
  node_catalog_repo["Catalog repository"]
end

subgraph group_basket["Basket and Discounts"]
  node_basket_api["Basket API"]
  node_basket_handlers["Basket workflows<br/>[Handlers]"]
  node_basket_repo["Basket repository"]
  node_discount_grpc["Discount gRPC client"]
  node_discount_service["Discount gRPC service<br/>[DiscountService.cs]"]
  node_discount_repo["Discount repository"]
end

subgraph group_order["Orders and Payments"]
  node_checkout_event["Checkout event"]
  node_ordering_consumer["Checkout consumer"]
  node_order_api["Order API<br/>[OrderController.cs]"]
  node_order_handlers["Order command and query handlers<br/>[Orders]"]
  node_outbox["Outbox dispatcher"]
  node_payment["Payment consumer"]
  node_payment_events["Payment outcome consumers<br/>[EventBusConsumer]"]
end

subgraph group_platform["Access and Platform"]
  node_gateway["API Gateway<br/>[Program.cs]"]
  node_identity["Identity and JWT<br/>[AuthController.cs]"]
  node_logging["Shared logging<br/>[Logging.cs]"]
  node_service_defaults["Service defaults<br/>[Extensions.cs]"]
end

node_customer(("Customer"))
node_catalog_db[("Catalog MongoDB")]
node_redis[("Redis cache")]
node_discount_db[("Discount database")]
node_rabbitmq["RabbitMQ"]
node_order_db[("Order database")]

node_customer -.->|"requests"| node_gateway
node_gateway -.->|"routes"| node_catalog_api
node_gateway -.->|"routes"| node_basket_api
node_gateway -.->|"routes"| node_order_api
node_customer -.->|"authenticates"| node_identity
node_catalog_api -->|"dispatches"| node_catalog_handlers
node_catalog_handlers -.->|"queries"| node_catalog_repo
node_catalog_repo -->|"reads and writes"| node_catalog_db
node_basket_api -->|"dispatches"| node_basket_handlers
node_basket_handlers -->|"loads and deletes"| node_basket_repo
node_basket_repo -.->|"stores baskets"| node_redis
node_basket_handlers -->|"publishes"| node_checkout_event
node_basket_api -->|"registers client"| node_discount_grpc
node_discount_grpc -.->|"calls gRPC"| node_discount_service
node_discount_service -->|"queries discounts"| node_discount_repo
node_discount_repo -->|"reads and writes"| node_discount_db
node_checkout_event -.->|"transports"| node_rabbitmq
node_rabbitmq -->|"delivers event"| node_ordering_consumer
node_ordering_consumer -.->|"creates order"| node_order_handlers
node_order_api -->|"invokes"| node_order_handlers
node_order_handlers -.->|"persists orders"| node_order_db
node_outbox -.->|"publishes reliably"| node_rabbitmq
node_payment -.->|"consumes events"| node_rabbitmq
node_rabbitmq -.->|"delivers outcomes"| node_payment_events
node_payment_events -.->|"updates order"| node_order_handlers
node_logging -.->|"supports services"| node_service_defaults

click node_gateway "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/ApiGateway/ApiGateway/Program.cs"
click node_identity "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Identity/Identity/Controllers/AuthController.cs"
click node_catalog_api "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Catalog/Catalog.API/Controllers/CatalogController.cs"
click node_catalog_handlers "https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Catalog/Catalog.Application/Handlers"
click node_catalog_repo "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Catalog/Catalog.Infrastructure/Repositories/ProductRepository.cs"
click node_basket_api "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Basket/Basket.API/Controllers/BasketController.cs"
click node_basket_handlers "https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Basket/Basket.Application/Handlers"
click node_basket_repo "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Basket/Basket.Infrastructure/Repositories/BasketRepository.cs"
click node_discount_grpc "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Basket/Basket.Application/GrpcService/DiscountGrpcService.cs"
click node_discount_service "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Discount/Discount.API/Services/DiscountService.cs"
click node_discount_repo "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Discount/Discount.Infrastructure/Repositories/DiscountRepository.cs"
click node_checkout_event "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Infrastructure/EventBus.Messages/Events/BasketCheckoutEvent.cs"
click node_ordering_consumer "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Ordering/Ordering.Application/EventBusConsumer/BasketOrderingConsumer.cs"
click node_order_api "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Ordering/Ordering.API/Controllers/OrderController.cs"
click node_order_handlers "https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Ordering/Ordering.Application/Orders"
click node_outbox "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Ordering/Ordering.Infrastructure/Dispatcher/OutboxMessageDispatcher.cs"
click node_payment "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Payment/Payment/EventBusConsumer/OrderCreatedConsumer.cs"
click node_payment_events "https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Ordering/Ordering.Application/EventBusConsumer"
click node_logging "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Infrastructure/Common.Logging/Logging.cs"
click node_service_defaults "https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Aspire/Ecommerce.ServiceDefaults/Extensions.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_catalog_api,node_catalog_handlers,node_catalog_repo toneBlue
class node_basket_api,node_basket_handlers,node_basket_repo,node_discount_grpc,node_discount_service,node_discount_repo,node_catalog_db,node_redis,node_discount_db,node_order_db toneAmber
class node_checkout_event,node_ordering_consumer,node_order_api,node_order_handlers,node_outbox,node_payment,node_payment_events toneMint
class node_gateway,node_identity,node_logging,node_service_defaults toneRose
class node_customer,node_rabbitmq toneIndigo
```

## Components

### Product Catalog

- [Catalog API](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Catalog/Catalog.API/Controllers/CatalogController.cs): `Services/Catalog/Catalog.API/Controllers/CatalogController.cs`
- [Catalog queries and commands](https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Catalog/Catalog.Application/Handlers): `Services/Catalog/Catalog.Application/Handlers`
- [Catalog repository](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Catalog/Catalog.Infrastructure/Repositories/ProductRepository.cs): `Services/Catalog/Catalog.Infrastructure/Repositories/ProductRepository.cs`

### Basket and Discounts

- [Basket API](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Basket/Basket.API/Controllers/BasketController.cs): `Services/Basket/Basket.API/Controllers/BasketController.cs`
- [Basket workflows](https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Basket/Basket.Application/Handlers): `Services/Basket/Basket.Application/Handlers`
- [Basket repository](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Basket/Basket.Infrastructure/Repositories/BasketRepository.cs): `Services/Basket/Basket.Infrastructure/Repositories/BasketRepository.cs`
- [Discount gRPC client](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Basket/Basket.Application/GrpcService/DiscountGrpcService.cs): `Services/Basket/Basket.Application/GrpcService/DiscountGrpcService.cs`
- [Discount gRPC service](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Discount/Discount.API/Services/DiscountService.cs): `Services/Discount/Discount.API/Services/DiscountService.cs`
- [Discount repository](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Discount/Discount.Infrastructure/Repositories/DiscountRepository.cs): `Services/Discount/Discount.Infrastructure/Repositories/DiscountRepository.cs`

### Orders and Payments

- [Checkout event](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Infrastructure/EventBus.Messages/Events/BasketCheckoutEvent.cs): `Infrastructure/EventBus.Messages/Events/BasketCheckoutEvent.cs`
- [Checkout consumer](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Ordering/Ordering.Application/EventBusConsumer/BasketOrderingConsumer.cs): `Services/Ordering/Ordering.Application/EventBusConsumer/BasketOrderingConsumer.cs`
- [Order API](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Ordering/Ordering.API/Controllers/OrderController.cs): `Services/Ordering/Ordering.API/Controllers/OrderController.cs`
- [Order command and query handlers](https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Ordering/Ordering.Application/Orders): `Services/Ordering/Ordering.Application/Orders`
- [Outbox dispatcher](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Ordering/Ordering.Infrastructure/Dispatcher/OutboxMessageDispatcher.cs): `Services/Ordering/Ordering.Infrastructure/Dispatcher/OutboxMessageDispatcher.cs`
- [Payment consumer](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Payment/Payment/EventBusConsumer/OrderCreatedConsumer.cs): `Services/Payment/Payment/EventBusConsumer/OrderCreatedConsumer.cs`
- [Payment outcome consumers](https://github.com/rahulsahay19/clean-architecture-dotnet-10/tree/12-Aspire/Services/Ordering/Ordering.Application/EventBusConsumer): `Services/Ordering/Ordering.Application/EventBusConsumer`

### Access and Platform

- [API Gateway](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/ApiGateway/ApiGateway/Program.cs): `ApiGateway/ApiGateway/Program.cs`
- [Identity and JWT](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Services/Identity/Identity/Controllers/AuthController.cs): `Services/Identity/Identity/Controllers/AuthController.cs`
- [Shared logging](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Infrastructure/Common.Logging/Logging.cs): `Infrastructure/Common.Logging/Logging.cs`
- [Service defaults](https://github.com/rahulsahay19/clean-architecture-dotnet-10/blob/12-Aspire/Aspire/Ecommerce.ServiceDefaults/Extensions.cs): `Aspire/Ecommerce.ServiceDefaults/Extensions.cs`

### Other components

- **Customer**
- **Catalog MongoDB**
- **Redis cache**
- **Discount database**
- **RabbitMQ**
- **Order database**

## Connections

- Customer → API Gateway: requests
- API Gateway → Catalog API: routes
- API Gateway → Basket API: routes
- API Gateway → Order API: routes
- Customer → Identity and JWT: authenticates
- Catalog API → Catalog queries and commands: dispatches (evidence: `Services/Catalog/Catalog.API/Controllers/CatalogController.cs`)
- Catalog queries and commands → Catalog repository: queries
- Catalog repository → Catalog MongoDB: reads and writes (evidence: `Services/Catalog/Catalog.Infrastructure/Repositories/ProductRepository.cs`)
- Basket API → Basket workflows: dispatches (evidence: `Services/Basket/Basket.API/Controllers/BasketController.cs`)
- Basket workflows → Basket repository: loads and deletes (evidence: `Services/Basket/Basket.Application/Handlers/BasketCheckoutHandler.cs`)
- Basket repository → Redis cache: stores baskets
- Basket workflows → Checkout event: publishes (evidence: `Services/Basket/Basket.Application/Handlers/BasketCheckoutHandler.cs`)
- Basket API → Discount gRPC client: registers client
- Discount gRPC client → Discount gRPC service: calls gRPC
- Discount gRPC service → Discount repository: queries discounts (evidence: `Services/Discount/Discount.API/Services/DiscountService.cs`)
- Discount repository → Discount database: reads and writes (evidence: `Services/Discount/Discount.Infrastructure/Repositories/DiscountRepository.cs`)
- Checkout event → RabbitMQ: transports
- RabbitMQ → Checkout consumer: delivers event
- Checkout consumer → Order command and query handlers: creates order
- Order API → Order command and query handlers: invokes (evidence: `Services/Ordering/Ordering.API/Controllers/OrderController.cs`)
- Order command and query handlers → Order database: persists orders
- Outbox dispatcher → RabbitMQ: publishes reliably
- Payment consumer → RabbitMQ: consumes events
- RabbitMQ → Payment outcome consumers: delivers outcomes
- Payment outcome consumers → Order command and query handlers: updates order
- Shared logging → Service defaults: supports services (evidence: `Infrastructure/Common.Logging/Logging.cs`)
