# maheshkumarsingh/eshopmicroservices architecture

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

- Interactive diagram: https://gitdiagram.com/maheshkumarsingh/eshopmicroservices
- Repository: https://github.com/maheshkumarsingh/eshopmicroservices

## Overview

##### Project type and purpose
- This is a microservices-based e-commerce reference implementation (“eShop Microservices”) built on .NET 9 using Domain-Driven Design (DDD), CQRS, and event-driven communication.
- It provides separate bounded contexts for Catalog, Basket, Ordering, and Identity, exposed via an API Gateway and orchestrated with Docker, message broker (RabbitMQ/Kafka), and DevOps pipelines.

##### File structure
- Top-level:
- src/BuildingBlocks – a shared .NET class library containing CQRS interfaces (ICommand, IQuery, handlers), behaviors (validation, logging), and custom exception handling.
- src/Services – each microservice lives in its own directory (e.g., Basket.API, Catalog.API). They follow a pattern: Endpoints, Handlers, Data repositories, Models, Configuration (appsettings.json), Dockerfile.
- docker-compose.* – container orchestration definitions.
- eShop-microservices.sln – Visual Studio solution referencing all projects.
- This shows a classical microservices layout: 1) Shared building blocks, 2) Service boundary per domain, 3) Infrastructure artifacts (Docker, compose).

##### README for additional insights
- It explicitly calls out:
- API Gateway (Ocelot/YARP) as the entry point.
- Four microservices (Catalog, Basket, Ordering, Identity).
- Polyglot persistence (SQL Server/PostgreSQL for Catalog & Ordering, Redis for Basket).
- Asynchronous messaging with RabbitMQ/Kafka.
- gRPC between services for low-latency calls.
- Cross-cutting concerns: Serilog, ELK/Grafana, CI/CD.

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Clients
    subgraph "External Clients"
        direction TB
        WebApp["Web App"]:::external
        MobileApp["Mobile App"]:::external
    end

    WebApp -->|"HTTP/gRPC"| APIGateway
    MobileApp -->|"HTTP/gRPC"| APIGateway

    %% API Gateway
    APIGateway["API Gateway\n(Ocelot/YARP)"]:::gateway

    %% Microservices Layer
    subgraph "Microservices"
        direction TB
        CatalogSvc["Catalog.API\n- Endpoints\n- Handlers\n- Repositories"]:::service
        BasketSvc["Basket.API\n- Endpoints\n- Handlers\n- Repositories"]:::service
        OrderingSvc["Ordering.API\n- Endpoints\n- Handlers\n- Repositories"]:::service
        IdentitySvc["Identity.API\n- Endpoints\n- Handlers\n- Repositories"]:::service
    end

    APIGateway -->|"REST/gRPC"| CatalogSvc
    APIGateway -->|"REST/gRPC"| BasketSvc
    APIGateway -->|"REST/gRPC"| OrderingSvc
    APIGateway -->|"REST/gRPC"| IdentitySvc

    %% Datastores
    CatalogDB["SQL Database\n(Catalog)"]:::database
    OrderingDB["SQL Database\n(Ordering)"]:::database
    IdentityDB["SQL Database\n(Identity)"]:::database
    BasketCache["Redis Cache\n(Basket)"]:::database

    CatalogSvc -->|Reads/Writes| CatalogDB
    OrderingSvc -->|Reads/Writes| OrderingDB
    IdentitySvc -->|Reads/Writes| IdentityDB
    BasketSvc -->|Reads/Writes| BasketCache

    %% Message Broker
    MessageBroker["Message Broker\n(RabbitMQ/Kafka)"]:::broker

    CatalogSvc -->|Publishes/Consumes Events| MessageBroker
    BasketSvc -->|Publishes/Consumes Events| MessageBroker
    OrderingSvc -->|Publishes/Consumes Events| MessageBroker
    IdentitySvc -->|Publishes/Consumes Events| MessageBroker

    %% Shared BuildingBlocks
    BuildingBlocks["Shared BuildingBlocks\n(CQRS, Behaviors,\nExceptions)"]:::shared
    BuildingBlocks --> CatalogSvc
    BuildingBlocks --> BasketSvc
    BuildingBlocks --> OrderingSvc
    BuildingBlocks --> IdentitySvc

    %% Infrastructure Artifacts
    subgraph "Infrastructure"
        direction TB
        DockerCompose["docker-compose.yml"]:::infra
        SolutionFile["eshop-microservices.sln"]:::infra
    end

    DockerCompose --> APIGateway
    DockerCompose --> CatalogSvc
    DockerCompose --> BasketSvc
    DockerCompose --> OrderingSvc
    DockerCompose --> IdentitySvc

    %% Click Events
    click BuildingBlocks "https://github.com/maheshkumarsingh/eshopmicroservices/tree/main/src/BuildingBlocks/BuildingBlocks"
    click CatalogSvc "https://github.com/maheshkumarsingh/eshopmicroservices/blob/main/src/Services/Catalog/Catalog.API"
    click BasketSvc "https://github.com/maheshkumarsingh/eshopmicroservices/blob/main/src/Services/Basket/Basket.API"
    click DockerCompose "https://github.com/maheshkumarsingh/eshopmicroservices/blob/main/src/docker-compose.yml"
    click SolutionFile "https://github.com/maheshkumarsingh/eshopmicroservices/blob/main/src/eshop-microservices.sln"

    %% Styles
    classDef external fill:#D6E9FE,stroke:#4A90E2,color:#000;
    classDef gateway fill:#E2F0CB,stroke:#8DC63F,color:#000;
    classDef service fill:#FFF2CC,stroke:#F8C471,color:#000;
    classDef database fill:#FDEBD0,stroke:#E67E22,color:#000;
    classDef broker fill:#E8DAEF,stroke:#9B59B6,color:#000;
    classDef shared fill:#D5F5E3,stroke:#27AE60,color:#000;
    classDef infra fill:#F4ECF7,stroke:#BB8FCE,color:#000;
```
