# dotnet-architecture/eshoponazure architecture

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

- Interactive diagram: https://gitdiagram.com/dotnet-architecture/eshoponazure
- Repository: https://github.com/dotnet-architecture/eshoponazure

## Overview

##### Main Components
- Microservice Containers – Represent each autonomous backend service such as Basket.API, Catalog.API, Identity.API, and Ordering.API. Include additional specialized building blocks (e.g., Event Bus, Health Checks, Resilience libraries) from the “src/BuildingBlocks” folder.
- Integration/Event Communication – Emphasize the Integration Events and the Event Bus (e.g., RabbitMQ integration packages and the integration event log from the Catalog and Basket services) which provide asynchronous, cross-service communication.
- Docker/Deployment Components – Include elements for Docker Compose setups (docker-compose.yml and various override files) as well as different CLI tools to build and deploy the containers.

##### Relationships and Data Flows
- Event Bus as a central intermediary connecting microservices that rely on integration events.

##### Architectural Patterns and Design Principles
- Microservice segregation: Each service is designed to be autonomous, owns its own database and data model (evidenced from the separate folders and project files for each API).
- Domain-Driven Design (DDD) and CQRS elements: Some services especially in Ordering show commands, domain events, and repositories, which signifies the use of layering and command/handler patterns.
- Containerization: The deployment is based on Docker containers (with distinct Dockerfiles for Linux and Windows) – mark these boundaries clearly.
- Client-Server separation: Emphasize the clear separation between back-end (microservices) and the variety of client applications.

##### Technologies & Tools
- .NET Core for API services, ASP.NET Core MVC for web apps.
- Angular 2+ for SPA.
- Xamarin for mobile clients.
- Docker and Docker Compose (illustrated by multiple docker-compose files).
- RabbitMQ and Redis as key infrastructure components.
- Visual Studio solutions (such as eShopOnContainers.sln and specific mobile/web solution files) which allow toggling between different client/server projects.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Applications"
        WebMVC["ASP.NET Core MVC (WebMVC)"]
        WebMonolithic["ASP.NET Core MVC (WebMonolithic)"]
        WebSPA["SPA (Angular)"]
        Mobile["Mobile (Xamarin)"]
    end

    subgraph "Microservices"
        BasketAPI["Basket.API"]
        CatalogAPI["Catalog.API"]
        IdentityAPI["Identity.API"]
        OrderingAPI["Ordering.API"]
    end

    subgraph "Building Blocks"
        EventBus["Event Bus & Integration Events"]
        HealthChecks["Health Checks"]
        Resilience["Resilience Libraries"]
    end

    subgraph "Infrastructure Services"
        SQLServer["SQL Server"]
        Redis["Redis Cache"]
        RabbitMQ["RabbitMQ Message Broker"]
    end

    subgraph "Deployment / Configurations"
        InfraDeploy["Infra & Deployment Configs"]
    end

    %% Client Applications to Microservices (HTTP REST Calls)
    WebMVC -->|"HTTPREST"| CatalogAPI
    WebMonolithic -->|"HTTPREST"| BasketAPI
    WebSPA -->|"HTTPREST"| BasketAPI
    Mobile -->|"HTTPREST"| OrderingAPI

    %% Microservices publishing Integration Events to Event Bus
    BasketAPI -->|"IntegrationEvent"| EventBus
    CatalogAPI -->|"IntegrationEvent"| EventBus
    IdentityAPI -->|"IntegrationEvent"| EventBus
    OrderingAPI -->|"IntegrationEvent"| EventBus

    %% Event Bus uses RabbitMQ Message Broker
    EventBus -->|"Uses"| RabbitMQ

    %% Data Persistence connections from Microservices to Infrastructure
    BasketAPI -->|"DataPersistence"| SQLServer
    CatalogAPI -->|"DataPersistence"| SQLServer
    OrderingAPI -->|"DataPersistence"| SQLServer
    BasketAPI -->|"Cache"| Redis

    %% Supporting Building Blocks usage by Microservices
    BasketAPI ---|"HealthChecks"| HealthChecks
    CatalogAPI ---|"HealthChecks"| HealthChecks
    OrderingAPI ---|"Resilience"| Resilience
    IdentityAPI ---|"Resilience"| Resilience

    %% Deployment / Configurations deploying and managing components
    InfraDeploy -->|"Deploys"| BasketAPI
    InfraDeploy -->|"Deploys"| CatalogAPI
    InfraDeploy -->|"Deploys"| IdentityAPI
    InfraDeploy -->|"Deploys"| OrderingAPI
    InfraDeploy -->|"Deploys"| EventBus
    InfraDeploy -->|"Manages"| SQLServer
    InfraDeploy -->|"Manages"| Redis
    InfraDeploy -->|"Manages"| RabbitMQ

    %% Styles: Colors for clarity
    classDef client fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef microservice fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef building fill:#abebc6,stroke:#1e8449,stroke-width:2px;
    classDef infra fill:#f5b7b1,stroke:#943126,stroke-width:2px;
    classDef deploy fill:#d7bde2,stroke:#6c3483,stroke-width:2px;

    class WebMVC,WebMonolithic,WebSPA,Mobile client;
    class BasketAPI,CatalogAPI,IdentityAPI,OrderingAPI microservice;
    class EventBus,HealthChecks,Resilience building;
    class SQLServer,Redis,RabbitMQ infra;
    class InfraDeploy deploy;

    %% Click Events for Components
    click BasketAPI "https://github.com/dotnet-architecture/eshoponazure/blob/master/src/Services/Basket/Basket.API"
    click CatalogAPI "https://github.com/dotnet-architecture/eshoponazure/blob/master/src/Services/Catalog/Catalog.API"
    click IdentityAPI "https://github.com/dotnet-architecture/eshoponazure/blob/master/src/Services/Identity/Identity.API"
    click OrderingAPI "https://github.com/dotnet-architecture/eshoponazure/blob/master/src/Services/Ordering/Ordering.API"
    click EventBus "https://github.com/dotnet-architecture/eshoponazure/tree/master/src/BuildingBlocks/EventBus"
    click HealthChecks "https://github.com/dotnet-architecture/eshoponazure/tree/master/src/BuildingBlocks/HealthChecks"
    click Resilience "https://github.com/dotnet-architecture/eshoponazure/tree/master/src/BuildingBlocks/Resilience"
    click WebMVC "https://github.com/dotnet-architecture/eshoponazure/tree/master/src/Web/WebMVC"
    click WebMonolithic "https://github.com/dotnet-architecture/eshoponazure/tree/master/src/Web/WebMonolithic"
    click WebSPA "https://github.com/dotnet-architecture/eshoponazure/tree/master/src/Web/WebSPA"
    click Mobile "https://github.com/dotnet-architecture/eshoponazure/tree/master/src/Mobile"
    click InfraDeploy "https://github.com/dotnet-architecture/eshoponazure/tree/master/ _docker"
```
