# abdallah-mamdouh/modularmonolithstartup architecture

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

- Interactive diagram: https://gitdiagram.com/abdallah-mamdouh/modularmonolithstartup
- Repository: https://github.com/abdallah-mamdouh/modularmonolithstartup

## Overview

This is a .NET modular-monolith backend for catalog, shopping baskets, and order management. The principal workflow reads catalog products into a basket, checks out the basket by atomically storing an outbox event and removing the cart, then consumes that event to create an order with inbox-based deduplication. The graph also preserves the documented HTTP, cache, messaging, and identity capabilities. Some subsystem wiring is represented from README documentation; unsampled implementation details are not asserted.

Main entry points: [`src/Bootstrapper/Host/Program.cs`](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Bootstrapper/Host/Program.cs) (ASP.NET host), [`src/Modules/Basket/Basket.Application/Features/AddItemIntoBasket/AddItemIntoBasketHandler.cs`](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Application/Features/AddItemIntoBasket/AddItemIntoBasketHandler.cs) (Basket use cases), [`src/Modules/Catalog/Catalog.Application/Products/Features/GetProductById/GetProductByIdHandler.cs`](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Catalog/Catalog.Application/Products/Features/GetProductById/GetProductByIdHandler.cs) (Product use cases), [`src/Modules/Ordering/Ordering.Application/Features/CreateOrder/CreateOrderHandler.cs`](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Application/Features/CreateOrder/CreateOrderHandler.cs) (Order use cases)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host and HTTP"]
  node_host["ASP.NET host<br/>[Program.cs]"]
  node_basket_api["Basket endpoints"]
  node_catalog_api["Catalog endpoints"]
  node_ordering_api["Ordering endpoints"]
end

subgraph group_catalog["Catalog"]
  node_catalog_usecases["Product use cases"]
  node_catalog_db[("Catalog store")]
  node_product_model["Product model<br/>[Product.cs]"]
end

subgraph group_basket["Basket"]
  node_basket_usecases["Basket use cases"]
  node_basket_checkout["Checkout handler"]
  node_basket_model["Shopping cart<br/>[ShoppingCart.cs]"]
  node_basket_cache["Cached repository"]
  node_basket_db[("Basket store<br/>[BasketDbContext.cs]")]
  node_outbox["Outbox processor<br/>[OutboxProcessor.cs]"]
end

subgraph group_ordering["Ordering"]
  node_ordering_consumer["Checkout consumer"]
  node_ordering_usecases["Order use cases"]
  node_order_model["Order model<br/>[Order.cs]"]
  node_ordering_db[("Ordering store")]
end

subgraph group_platform["Shared platform"]
  node_cqrs["CQRS contracts<br/>[ICommand.cs]"]
  node_messaging["Integration events"]
  node_idempotency["HTTP idempotency"]
end

node_customer(("API client"))
node_broker["RabbitMQ broker"]
node_identity["Keycloak identity"]

node_customer -->|"sends HTTP"| node_host
node_host -->|"composes module"| node_basket_api
node_host -->|"composes module"| node_catalog_api
node_host -->|"composes module"| node_ordering_api
node_basket_api -->|"dispatches commands"| node_basket_usecases
node_catalog_api -->|"dispatches queries"| node_catalog_usecases
node_ordering_api -->|"dispatches commands"| node_ordering_usecases
node_basket_usecases -->|"queries product"| node_catalog_usecases
node_basket_usecases -->|"uses repository"| node_basket_cache
node_basket_cache -->|"reads and writes"| node_basket_db
node_basket_usecases -->|"updates cart"| node_basket_model
node_basket_checkout -->|"writes checkout"| node_basket_db
node_basket_checkout -->|"creates event"| node_messaging
node_basket_db -->|"stores outbox row"| node_outbox
node_outbox -->|"publishes event"| node_broker
node_broker -->|"delivers event"| node_ordering_consumer
node_ordering_consumer -->|"sends create command"| node_ordering_usecases
node_ordering_consumer -->|"claims inbox message"| node_ordering_db
node_ordering_usecases -->|"persists order"| node_ordering_db
node_ordering_usecases -->|"creates order"| node_order_model
node_catalog_usecases -.->|"queries products"| node_catalog_db
node_catalog_usecases -.->|"returns product data"| node_product_model
node_host -.->|"enables endpoint guard"| node_idempotency
node_host -.->|"authenticates with"| node_identity
node_basket_usecases -->|"uses command contract"| node_cqrs

click node_host "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Bootstrapper/Host/Program.cs"
click node_basket_api "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Presentation/Features/CheckoutBasket/CheckoutBasketEndpoint.cs"
click node_catalog_api "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Catalog/Catalog.Presentation/Products/Features/GetProductById/GetProductIdEndPoint.cs"
click node_ordering_api "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Presentation/Features/CreateOrder/CreateOrderEndpoint.cs"
click node_catalog_usecases "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Catalog/Catalog.Application/Products/Features/GetProductById/GetProductByIdHandler.cs"
click node_catalog_db "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Catalog/Catalog.Infrastructure/Data/CatalogDbContext.cs"
click node_product_model "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Catalog/Catalog.Domain/Products/Models/Product.cs"
click node_basket_usecases "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Application/Features/AddItemIntoBasket/AddItemIntoBasketHandler.cs"
click node_basket_checkout "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Application/Features/CheckoutBasket/CheckoutBasketHandler.cs"
click node_basket_model "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Domain/Models/ShoppingCart.cs"
click node_basket_cache "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Infrastructure/Data/Repository/CachedBasketRepository.cs"
click node_basket_db "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Infrastructure/Data/BasketDbContext.cs"
click node_outbox "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Infrastructure/Data/Processors/OutboxProcessor.cs"
click node_ordering_consumer "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Application/EventHandlers/BasketCheckoutIntegrationEventHandler.cs"
click node_ordering_usecases "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Application/Features/CreateOrder/CreateOrderHandler.cs"
click node_order_model "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Domain/Models/Order.cs"
click node_ordering_db "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Infrastructure/Data/OrderingDbContext.cs"
click node_cqrs "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Shared/Shared.Contracts/CQRS/ICommand.cs"
click node_messaging "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Shared/Shared.Messaging/Events/BasketCheckoutIntegrationEvent.cs"
click node_idempotency "https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Shared/Shared/Idempotency/IdempotencyMiddleware.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_host,node_basket_api,node_catalog_api,node_ordering_api,node_customer toneBlue
class node_catalog_usecases,node_catalog_db,node_product_model toneAmber
class node_basket_usecases,node_basket_checkout,node_basket_model,node_basket_cache,node_basket_db,node_outbox toneMint
class node_ordering_consumer,node_ordering_usecases,node_order_model,node_ordering_db toneRose
class node_cqrs,node_messaging,node_idempotency,node_broker,node_identity toneIndigo
```

## Components

### Host and HTTP

- [ASP.NET host](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Bootstrapper/Host/Program.cs): `src/Bootstrapper/Host/Program.cs`
- [Basket endpoints](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Presentation/Features/CheckoutBasket/CheckoutBasketEndpoint.cs): `src/Modules/Basket/Basket.Presentation/Features/CheckoutBasket/CheckoutBasketEndpoint.cs`
- [Catalog endpoints](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Catalog/Catalog.Presentation/Products/Features/GetProductById/GetProductIdEndPoint.cs): `src/Modules/Catalog/Catalog.Presentation/Products/Features/GetProductById/GetProductIdEndPoint.cs`
- [Ordering endpoints](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Presentation/Features/CreateOrder/CreateOrderEndpoint.cs): `src/Modules/Ordering/Ordering.Presentation/Features/CreateOrder/CreateOrderEndpoint.cs`

### Catalog

- [Product use cases](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Catalog/Catalog.Application/Products/Features/GetProductById/GetProductByIdHandler.cs): `src/Modules/Catalog/Catalog.Application/Products/Features/GetProductById/GetProductByIdHandler.cs`
- [Catalog store](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Catalog/Catalog.Infrastructure/Data/CatalogDbContext.cs): `src/Modules/Catalog/Catalog.Infrastructure/Data/CatalogDbContext.cs`
- [Product model](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Catalog/Catalog.Domain/Products/Models/Product.cs): `src/Modules/Catalog/Catalog.Domain/Products/Models/Product.cs`

### Basket

- [Basket use cases](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Application/Features/AddItemIntoBasket/AddItemIntoBasketHandler.cs): `src/Modules/Basket/Basket.Application/Features/AddItemIntoBasket/AddItemIntoBasketHandler.cs`
- [Checkout handler](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Application/Features/CheckoutBasket/CheckoutBasketHandler.cs): `src/Modules/Basket/Basket.Application/Features/CheckoutBasket/CheckoutBasketHandler.cs`
- [Shopping cart](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Domain/Models/ShoppingCart.cs): `src/Modules/Basket/Basket.Domain/Models/ShoppingCart.cs`
- [Cached repository](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Infrastructure/Data/Repository/CachedBasketRepository.cs): `src/Modules/Basket/Basket.Infrastructure/Data/Repository/CachedBasketRepository.cs`
- [Basket store](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Infrastructure/Data/BasketDbContext.cs): `src/Modules/Basket/Basket.Infrastructure/Data/BasketDbContext.cs`
- [Outbox processor](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Basket/Basket.Infrastructure/Data/Processors/OutboxProcessor.cs): `src/Modules/Basket/Basket.Infrastructure/Data/Processors/OutboxProcessor.cs`

### Ordering

- [Checkout consumer](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Application/EventHandlers/BasketCheckoutIntegrationEventHandler.cs): `src/Modules/Ordering/Ordering.Application/EventHandlers/BasketCheckoutIntegrationEventHandler.cs`
- [Order use cases](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Application/Features/CreateOrder/CreateOrderHandler.cs): `src/Modules/Ordering/Ordering.Application/Features/CreateOrder/CreateOrderHandler.cs`
- [Order model](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Domain/Models/Order.cs): `src/Modules/Ordering/Ordering.Domain/Models/Order.cs`
- [Ordering store](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Modules/Ordering/Ordering.Infrastructure/Data/OrderingDbContext.cs): `src/Modules/Ordering/Ordering.Infrastructure/Data/OrderingDbContext.cs`

### Shared platform

- [CQRS contracts](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Shared/Shared.Contracts/CQRS/ICommand.cs): `src/Shared/Shared.Contracts/CQRS/ICommand.cs`
- [Integration events](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Shared/Shared.Messaging/Events/BasketCheckoutIntegrationEvent.cs): `src/Shared/Shared.Messaging/Events/BasketCheckoutIntegrationEvent.cs`
- [HTTP idempotency](https://github.com/abdallah-mamdouh/modularmonolithstartup/blob/main/src/Shared/Shared/Idempotency/IdempotencyMiddleware.cs): `src/Shared/Shared/Idempotency/IdempotencyMiddleware.cs`

### Other components

- **API client**
- **RabbitMQ broker**
- **Keycloak identity**

## Connections

- API client → ASP.NET host: sends HTTP (evidence: `README.md`)
- ASP.NET host → Basket endpoints: composes module (evidence: `src/Bootstrapper/Host/Program.cs`)
- ASP.NET host → Catalog endpoints: composes module (evidence: `src/Bootstrapper/Host/Program.cs`)
- ASP.NET host → Ordering endpoints: composes module (evidence: `src/Bootstrapper/Host/Program.cs`)
- Basket endpoints → Basket use cases: dispatches commands (evidence: `README.md`)
- Catalog endpoints → Product use cases: dispatches queries (evidence: `README.md`)
- Ordering endpoints → Order use cases: dispatches commands (evidence: `README.md`)
- Basket use cases → Product use cases: queries product (evidence: `src/Modules/Basket/Basket.Application/Features/AddItemIntoBasket/AddItemIntoBasketHandler.cs`)
- Basket use cases → Cached repository: uses repository (evidence: `src/Modules/Basket/Basket.Application/Features/AddItemIntoBasket/AddItemIntoBasketHandler.cs`)
- Cached repository → Basket store: reads and writes (evidence: `src/Modules/Basket/Basket.Infrastructure/Data/Repository/CachedBasketRepository.cs`)
- Basket use cases → Shopping cart: updates cart (evidence: `src/Modules/Basket/Basket.Application/Features/AddItemIntoBasket/AddItemIntoBasketHandler.cs`)
- Checkout handler → Basket store: writes checkout (evidence: `src/Modules/Basket/Basket.Application/Features/CheckoutBasket/CheckoutBasketHandler.cs`)
- Checkout handler → Integration events: creates event (evidence: `src/Modules/Basket/Basket.Application/Features/CheckoutBasket/CheckoutBasketHandler.cs`)
- Basket store → Outbox processor: stores outbox row (evidence: `README.md`)
- Outbox processor → RabbitMQ broker: publishes event (evidence: `README.md`)
- RabbitMQ broker → Checkout consumer: delivers event (evidence: `README.md`)
- Checkout consumer → Order use cases: sends create command (evidence: `src/Modules/Ordering/Ordering.Application/EventHandlers/BasketCheckoutIntegrationEventHandler.cs`)
- Checkout consumer → Ordering store: claims inbox message (evidence: `src/Modules/Ordering/Ordering.Application/EventHandlers/BasketCheckoutIntegrationEventHandler.cs`)
- Order use cases → Ordering store: persists order (evidence: `src/Modules/Ordering/Ordering.Application/Features/CreateOrder/CreateOrderHandler.cs`)
- Order use cases → Order model: creates order (evidence: `src/Modules/Ordering/Ordering.Application/Features/CreateOrder/CreateOrderHandler.cs`)
- Product use cases → Catalog store: queries products
- Product use cases → Product model: returns product data
- ASP.NET host → HTTP idempotency: enables endpoint guard (evidence: `README.md`)
- ASP.NET host → Keycloak identity: authenticates with (evidence: `README.md`)
- Basket use cases → CQRS contracts: uses command contract (evidence: `src/Modules/Basket/Basket.Application/Features/AddItemIntoBasket/AddItemIntoBasketHandler.cs`)
