# renako223678/sneakershop architecture

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

- Interactive diagram: https://gitdiagram.com/renako223678/sneakershop
- Repository: https://github.com/renako223678/sneakershop

## Overview

Sneaker Shop is a .NET microservices e-commerce backend. The main purchase flow is client → gateway → order creation: Ordering requests authoritative variant prices from Catalog, saves a pending order, and publishes an event; Inventory reserves stock and reports the outcome to Ordering. Cancellation and shipping trigger inventory compensation or deduction. The graph also preserves identity, catalog management, inventory queries, and shared contracts. Cross-service event and HTTP links follow the README; several consumer implementations were not sampled, so those links are documented rather than source-verified.

Main entry points: [`src/Services/Catalog/Catalog.Api/Controllers/SneakersController.cs`](https://github.com/renako223678/sneakershop/blob/main/src/Services/Catalog/Catalog.Api/Controllers/SneakersController.cs) (Catalog API), [`src/Services/Ordering/Ordering.Api/Services/OrderService.cs`](https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Services/OrderService.cs) (Order lifecycle), [`src/Gateway/ApiGateway/Program.cs`](https://github.com/renako223678/sneakershop/blob/main/src/Gateway/ApiGateway/Program.cs) (API gateway), [`src/Services/Identity/Identity.Api/Controllers/AuthController.cs`](https://github.com/renako223678/sneakershop/blob/main/src/Services/Identity/Identity.Api/Controllers/AuthController.cs) (Identity API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Public access"]
  node_gateway["API gateway<br/>[Program.cs]"]
end

subgraph group_identity["Identity"]
  node_identity_api["Identity API<br/>[AuthController.cs]"]
  node_identity_db[("Identity database<br/>[AuthDbContext.cs]")]
  node_token["JWT issuance<br/>[TokenService.cs]"]
end

subgraph group_catalog["Product catalog"]
  node_catalog_api["Catalog API"]
  node_brand_admin["Brand management"]
  node_variant_lookup["Internal variant lookup"]
  node_catalog_db[("Catalog database")]
end

subgraph group_commerce["Orders and stock"]
  node_order_api["Order endpoints"]
  node_order_service["Order lifecycle<br/>[OrderService.cs]"]
  node_catalog_client["Catalog HTTP client<br/>[CatalogClient.cs]"]
  node_order_db[("Order database<br/>[OrderDbContext.cs]")]
  node_order_consumer["Stock result handlers"]
  node_inventory_api["Inventory endpoints"]
  node_inventory_consumers["Inventory event handlers"]
  node_inventory_db[("Inventory database")]
end

subgraph group_shared["Shared infrastructure"]
  node_events["Event contracts<br/>[Events.cs]"]
  node_catalog_contract["Catalog lookup contract<br/>[CatalogLookup.cs]"]
  node_shared_security["Shared auth conventions<br/>[Roles.cs]"]
  node_shared_errors["Error handling<br/>[AppException.cs]"]
  node_seed_catalog["Catalog seed data<br/>[SeedCatalog.cs]"]
end

node_customer(("Shop client"))
node_rabbitmq["RabbitMQ"]

node_customer -->|"sends requests"| node_gateway
node_gateway -->|"routes auth"| node_identity_api
node_gateway -->|"routes catalog"| node_catalog_api
node_gateway -->|"routes inventory"| node_inventory_api
node_gateway -->|"routes orders"| node_order_api
node_identity_api -->|"reads and writes"| node_identity_db
node_identity_api -->|"issues tokens"| node_token
node_identity_api -->|"uses roles"| node_shared_security
node_catalog_api -->|"reads and writes"| node_catalog_db
node_brand_admin -->|"reads and writes"| node_catalog_db
node_variant_lookup -->|"reads variants"| node_catalog_db
node_catalog_api -->|"publishes variant event"| node_rabbitmq
node_order_api -->|"delegates requests"| node_order_service
node_order_service -->|"requests prices"| node_catalog_client
node_catalog_client -->|"looks up variants"| node_variant_lookup
node_order_service -->|"reads and writes"| node_order_db
node_order_service -->|"publishes order events"| node_rabbitmq
node_rabbitmq -.->|"delivers order events"| node_inventory_consumers
node_inventory_consumers -->|"reserves or adjusts stock"| node_inventory_db
node_inventory_consumers -.->|"publishes stock result"| node_rabbitmq
node_rabbitmq -.->|"delivers stock result"| node_order_consumer
node_order_consumer -->|"updates order state"| node_order_db
node_inventory_api -->|"reads and writes"| node_inventory_db
node_catalog_api -->|"publishes contract"| node_events
node_order_service -->|"publishes contracts"| node_events
node_catalog_client -->|"uses lookup contract"| node_catalog_contract
node_catalog_api -->|"raises API errors"| node_shared_errors
node_order_service -->|"raises API errors"| node_shared_errors
node_catalog_api -.-> node_seed_catalog

click node_gateway "https://github.com/renako223678/sneakershop/blob/main/src/Gateway/ApiGateway/Program.cs"
click node_identity_api "https://github.com/renako223678/sneakershop/blob/main/src/Services/Identity/Identity.Api/Controllers/AuthController.cs"
click node_identity_db "https://github.com/renako223678/sneakershop/blob/main/src/Services/Identity/Identity.Api/Data/AuthDbContext.cs"
click node_token "https://github.com/renako223678/sneakershop/blob/main/src/Services/Identity/Identity.Api/Services/TokenService.cs"
click node_catalog_api "https://github.com/renako223678/sneakershop/blob/main/src/Services/Catalog/Catalog.Api/Controllers/SneakersController.cs"
click node_brand_admin "https://github.com/renako223678/sneakershop/blob/main/src/Services/Catalog/Catalog.Api/Controllers/BrandsController.cs"
click node_variant_lookup "https://github.com/renako223678/sneakershop/blob/main/src/Services/Catalog/Catalog.Api/Controllers/InternalVariantsController.cs"
click node_catalog_db "https://github.com/renako223678/sneakershop/blob/main/src/Services/Catalog/Catalog.Api/Data/CatalogDbContext.cs"
click node_order_api "https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Controllers/OrdersController.cs"
click node_order_service "https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Services/OrderService.cs"
click node_catalog_client "https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Services/CatalogClient.cs"
click node_order_db "https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Data/OrderDbContext.cs"
click node_order_consumer "https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Consumers/StockReservedConsumer.cs"
click node_inventory_api "https://github.com/renako223678/sneakershop/blob/main/src/Services/Inventory/Inventory.Api/Controllers/InventoryController.cs"
click node_inventory_consumers "https://github.com/renako223678/sneakershop/blob/main/src/Services/Inventory/Inventory.Api/Consumers/OrderCreatedConsumer.cs"
click node_inventory_db "https://github.com/renako223678/sneakershop/blob/main/src/Services/Inventory/Inventory.Api/Data/InventoryDbContext.cs"
click node_events "https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Contracts/Events.cs"
click node_catalog_contract "https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Contracts/CatalogLookup.cs"
click node_shared_security "https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Common/Roles.cs"
click node_shared_errors "https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Common/AppException.cs"
click node_seed_catalog "https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Seed/SeedCatalog.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_gateway,node_customer toneBlue
class node_identity_api,node_identity_db,node_token toneAmber
class node_catalog_api,node_brand_admin,node_variant_lookup,node_catalog_db toneMint
class node_order_api,node_order_service,node_catalog_client,node_order_db,node_order_consumer,node_inventory_api,node_inventory_consumers,node_inventory_db toneRose
class node_events,node_catalog_contract,node_shared_security,node_shared_errors,node_seed_catalog,node_rabbitmq toneIndigo
```

## Components

### Public access

- [API gateway](https://github.com/renako223678/sneakershop/blob/main/src/Gateway/ApiGateway/Program.cs): `src/Gateway/ApiGateway/Program.cs`

### Identity

- [Identity API](https://github.com/renako223678/sneakershop/blob/main/src/Services/Identity/Identity.Api/Controllers/AuthController.cs): `src/Services/Identity/Identity.Api/Controllers/AuthController.cs`
- [Identity database](https://github.com/renako223678/sneakershop/blob/main/src/Services/Identity/Identity.Api/Data/AuthDbContext.cs): `src/Services/Identity/Identity.Api/Data/AuthDbContext.cs`
- [JWT issuance](https://github.com/renako223678/sneakershop/blob/main/src/Services/Identity/Identity.Api/Services/TokenService.cs): `src/Services/Identity/Identity.Api/Services/TokenService.cs`

### Product catalog

- [Catalog API](https://github.com/renako223678/sneakershop/blob/main/src/Services/Catalog/Catalog.Api/Controllers/SneakersController.cs): `src/Services/Catalog/Catalog.Api/Controllers/SneakersController.cs`
- [Brand management](https://github.com/renako223678/sneakershop/blob/main/src/Services/Catalog/Catalog.Api/Controllers/BrandsController.cs): `src/Services/Catalog/Catalog.Api/Controllers/BrandsController.cs`
- [Internal variant lookup](https://github.com/renako223678/sneakershop/blob/main/src/Services/Catalog/Catalog.Api/Controllers/InternalVariantsController.cs): `src/Services/Catalog/Catalog.Api/Controllers/InternalVariantsController.cs`
- [Catalog database](https://github.com/renako223678/sneakershop/blob/main/src/Services/Catalog/Catalog.Api/Data/CatalogDbContext.cs): `src/Services/Catalog/Catalog.Api/Data/CatalogDbContext.cs`

### Orders and stock

- [Order endpoints](https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Controllers/OrdersController.cs): `src/Services/Ordering/Ordering.Api/Controllers/OrdersController.cs`
- [Order lifecycle](https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Services/OrderService.cs): `src/Services/Ordering/Ordering.Api/Services/OrderService.cs`
- [Catalog HTTP client](https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Services/CatalogClient.cs): `src/Services/Ordering/Ordering.Api/Services/CatalogClient.cs`
- [Order database](https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Data/OrderDbContext.cs): `src/Services/Ordering/Ordering.Api/Data/OrderDbContext.cs`
- [Stock result handlers](https://github.com/renako223678/sneakershop/blob/main/src/Services/Ordering/Ordering.Api/Consumers/StockReservedConsumer.cs): `src/Services/Ordering/Ordering.Api/Consumers/StockReservedConsumer.cs`
- [Inventory endpoints](https://github.com/renako223678/sneakershop/blob/main/src/Services/Inventory/Inventory.Api/Controllers/InventoryController.cs): `src/Services/Inventory/Inventory.Api/Controllers/InventoryController.cs`
- [Inventory event handlers](https://github.com/renako223678/sneakershop/blob/main/src/Services/Inventory/Inventory.Api/Consumers/OrderCreatedConsumer.cs): `src/Services/Inventory/Inventory.Api/Consumers/OrderCreatedConsumer.cs`
- [Inventory database](https://github.com/renako223678/sneakershop/blob/main/src/Services/Inventory/Inventory.Api/Data/InventoryDbContext.cs): `src/Services/Inventory/Inventory.Api/Data/InventoryDbContext.cs`

### Shared infrastructure

- [Event contracts](https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Contracts/Events.cs): `src/BuildingBlocks/SneakerShop.BuildingBlocks/Contracts/Events.cs`
- [Catalog lookup contract](https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Contracts/CatalogLookup.cs): `src/BuildingBlocks/SneakerShop.BuildingBlocks/Contracts/CatalogLookup.cs`
- [Shared auth conventions](https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Common/Roles.cs): `src/BuildingBlocks/SneakerShop.BuildingBlocks/Common/Roles.cs`
- [Error handling](https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Common/AppException.cs): `src/BuildingBlocks/SneakerShop.BuildingBlocks/Common/AppException.cs`
- [Catalog seed data](https://github.com/renako223678/sneakershop/blob/main/src/BuildingBlocks/SneakerShop.BuildingBlocks/Seed/SeedCatalog.cs): `src/BuildingBlocks/SneakerShop.BuildingBlocks/Seed/SeedCatalog.cs`

### Other components

- **Shop client**
- **RabbitMQ**

## Connections

- Shop client → API gateway: sends requests
- API gateway → Identity API: routes auth
- API gateway → Catalog API: routes catalog
- API gateway → Inventory endpoints: routes inventory
- API gateway → Order endpoints: routes orders
- Identity API → Identity database: reads and writes (evidence: `src/Services/Identity/Identity.Api/Controllers/AuthController.cs`)
- Identity API → JWT issuance: issues tokens (evidence: `src/Services/Identity/Identity.Api/Controllers/AuthController.cs`)
- Identity API → Shared auth conventions: uses roles (evidence: `src/Services/Identity/Identity.Api/Controllers/AuthController.cs`)
- Catalog API → Catalog database: reads and writes (evidence: `src/Services/Catalog/Catalog.Api/Controllers/SneakersController.cs`)
- Brand management → Catalog database: reads and writes (evidence: `src/Services/Catalog/Catalog.Api/Controllers/BrandsController.cs`)
- Internal variant lookup → Catalog database: reads variants (evidence: `src/Services/Catalog/Catalog.Api/Controllers/InternalVariantsController.cs`)
- Catalog API → RabbitMQ: publishes variant event (evidence: `src/Services/Catalog/Catalog.Api/Controllers/SneakersController.cs`)
- Order endpoints → Order lifecycle: delegates requests (evidence: `src/Services/Ordering/Ordering.Api/Controllers/OrdersController.cs`)
- Order lifecycle → Catalog HTTP client: requests prices (evidence: `src/Services/Ordering/Ordering.Api/Services/OrderService.cs`)
- Catalog HTTP client → Internal variant lookup: looks up variants
- Order lifecycle → Order database: reads and writes (evidence: `src/Services/Ordering/Ordering.Api/Services/OrderService.cs`)
- Order lifecycle → RabbitMQ: publishes order events (evidence: `src/Services/Ordering/Ordering.Api/Services/OrderService.cs`)
- RabbitMQ → Inventory event handlers: delivers order events
- Inventory event handlers → Inventory database: reserves or adjusts stock (evidence: `src/Services/Inventory/Inventory.Api/Consumers/OrderCreatedConsumer.cs`)
- Inventory event handlers → RabbitMQ: publishes stock result
- RabbitMQ → Stock result handlers: delivers stock result
- Stock result handlers → Order database: updates order state (evidence: `src/Services/Ordering/Ordering.Api/Consumers/StockReservedConsumer.cs`)
- Inventory endpoints → Inventory database: reads and writes (evidence: `src/Services/Inventory/Inventory.Api/Controllers/InventoryController.cs`)
- Catalog API → Event contracts: publishes contract (evidence: `src/Services/Catalog/Catalog.Api/Controllers/SneakersController.cs`)
- Order lifecycle → Event contracts: publishes contracts (evidence: `src/Services/Ordering/Ordering.Api/Services/OrderService.cs`)
- Catalog HTTP client → Catalog lookup contract: uses lookup contract
- Catalog API → Error handling: raises API errors (evidence: `src/Services/Catalog/Catalog.Api/Controllers/SneakersController.cs`)
- Order lifecycle → Error handling: raises API errors (evidence: `src/Services/Ordering/Ordering.Api/Services/OrderService.cs`)
- Catalog API → Catalog seed data
