# kashifjaved1/ecommercestoremicroservices architecture

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

- Interactive diagram: https://gitdiagram.com/kashifjaved1/ecommercestoremicroservices
- Repository: https://github.com/kashifjaved1/ecommercestoremicroservices

## Overview

##### Project type and purpose
- This is a full-stack microservices e-commerce application.
- Purpose: provide shopping-cart, catalog, discount, and ordering functionality behind an API gateway, plus a Razor Pages web UI.

##### File structure
- Top-level modules under src:
- ApiGateways
– OcelotApiGateway: single entrypoint for all clients
– Shopping.Aggregator: composite façade that calls downstream services and exposes a unified shopping API
- BuildingBlocks/EventBus.Messages: shared contracts for integration events
- Services: each folder implements a microservice
– Basket.API (handles cart operations, publishes BasketCheckoutEvent)
– Catalog.API (CRUD on product catalog)
– Discount.API + Discount.Grpc (REST + gRPC endpoints for coupon service)
– Ordering.API + Application + Domain + Infrastructure (order management, consumes BasketCheckoutEvent)
- WebApps/eCommerceUI: ASP.NET Razor Pages UI that calls the gateway
- Docker-related: Dockerfiles in each service, docker-compose.yml for local orchestration
- Solution and launchSettings coordinate local development

##### README
- Minimal content; relies on code structure for architectural insight.

- Containers and their boundaries.
- Technology stack on each.
- Inter-service events and external dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "Client Tier"
        UI["Web UI (Razor Pages)"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        Gateway["Ocelot API Gateway"]:::frontend
        Aggregator["Shopping Aggregator"]:::frontend
    end

    %% Microservices
    subgraph "Microservices"
        subgraph "Basket Service"
            BasketAPI["Basket.API"]:::service
            BasketDB["Basket DB"]:::db
        end
        subgraph "Catalog Service"
            CatalogAPI["Catalog.API"]:::service
            CatalogDB["Catalog DB"]:::db
        end
        subgraph "Discount Service"
            DiscountAPI["Discount.API"]:::service
            DiscountGRPC["Discount.Grpc"]:::service
            DiscountDB["Discount DB"]:::db
        end
        subgraph "Ordering Service"
            OrderingAPI["Ordering.API"]:::service
            subgraph "Ordering Application"
                OrderApp["Ordering.Application"]:::service
            end
            subgraph "Ordering Domain"
                OrderDomain["Ordering.Domain"]:::service
            end
            subgraph "Ordering Infrastructure"
                OrderInfra["Ordering.Infrastructure"]:::service
            end
            OrderDB["Ordering DB"]:::db
        end
    end

    %% Event Bus and External
    EventBus["Event Bus"]:::bus
    EventBusContracts["EventBus.Messages"]:::bus
    SMTP["SMTP Service"]:::external

    %% Flows
    UI -->|HTTP| Gateway
    Gateway -->|Routes| Aggregator
    Aggregator -->|HTTP: Basket| BasketAPI
    Aggregator -->|HTTP: Catalog| CatalogAPI
    Aggregator -->|HTTP: Order| OrderingAPI
    BasketAPI -->|gRPC| DiscountGRPC
    BasketAPI -->|Publishes BasketCheckoutEvent| EventBus
    EventBusContracts --> EventBus
    EventBus -->|Subscribes BasketCheckoutEvent| OrderingAPI
    OrderingAPI -->|Persists| OrderDB
    OrderingAPI -->|Invokes IEmailService| SMTP

    BasketAPI -->|Reads/Writes| BasketDB
    CatalogAPI -->|Reads/Writes| CatalogDB
    DiscountAPI -->|Reads/Writes| DiscountDB
    DiscountGRPC -->|Reads/Writes| DiscountDB

    %% Click Events
    click UI "https://github.com/kashifjaved1/ecommercestoremicroservices/tree/main/src/WebApps/eCommerceUI"
    click Gateway "https://github.com/kashifjaved1/ecommercestoremicroservices/tree/main/src/ApiGateways/OcelotApiGateway"
    click Aggregator "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/ApiGateways/Shopping.Aggregator"
    click EventBusContracts "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/BuildingBlocks/EventBus.Messages"
    click BasketAPI "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/Services/Basket/Basket.API"
    click CatalogAPI "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/Services/Catalog/Catalog.API"
    click DiscountAPI "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/Services/Discount/Discount.API"
    click DiscountGRPC "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/Services/Discount/Discount.Grpc"
    click OrderingAPI "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/Services/Ordering/Ordering.API"
    click OrderApp "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/Services/Ordering/Ordering.Application"
    click OrderDomain "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/Services/Ordering/Ordering.Domain"
    click OrderInfra "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/Services/Ordering/Ordering.Infrastructure"
    click dockerCompose "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/docker-compose.yml"
    click solution "https://github.com/kashifjaved1/ecommercestoremicroservices/blob/main/src/eCommerceStoreMicroservices.sln"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef service fill:#DFF2BF,stroke:#4F8A10,color:#4F8A10;
    classDef db fill:#E0E0E0,stroke:#888888,color:#333333;
    classDef bus fill:#FFE0B2,stroke:#E65100,color:#E65100;
    classDef external fill:#F0F0F0,stroke:#666666,color:#666666;
```
