# zehraseren/multishopproject architecture

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

- Interactive diagram: https://gitdiagram.com/zehraseren/multishopproject
- Repository: https://github.com/zehraseren/multishopproject

## Overview

##### Project type and purpose
- This is a .NET-based, microservices e-commerce platform (“MultiShopProject”) that uses:
- An API Gateway (Ocelot)
- A federated IdentityServer for authentication/authorization
- Multiple bounded-context microservices (Basket, Cargo, Catalog, Comment, Discount, Image, Message, Order, Payment, RabbitMQ messaging API, SignalR real-time API)
- A monolithic Web UI (MS.WebUI) and a DTO layer for client-server models

##### High-level architectural components
a. Client/UI layer
- MS.WebUI: ASP.NET Core MVC Razor front-end
- RapidApi/MS.RapidApiWebUI: sample Razor UI calling public endpoints
b. API Gateway
- MS.OcelotGateway: single entry point, routes incoming requests
c. Identity & Security
- MS.IdentityServer: issues and validates JWT tokens
d. Microservices
- Basket (uses Redis)
- Cargo (SQL via EF Core)
- Catalog (MongoDB)
- Comment (SQL via EF Core)
- Discount (Dapper/SQL)
- Image (CloudStorage: e.g. Google Cloud Storage)
- Message (SQL via EF Core)
- Order (CQRS + Mediator + SQL)
- Payment (placeholder service)
- RabbitMQMessageApi (RabbitMQ producer/consumer)
- SignalRRealTimeApi (SignalR hubs for comments/messages)
e. Data stores & external systems
- Redis for basket caching
- MongoDB for catalog data
- SQL databases for most services
- RabbitMQ message broker
- Cloud storage (GCS) for images

##### Relationships and interactions
- All clients → HTTP(S) → API Gateway → downstream microservices
- MS.WebUI attaches JWT token to outbound requests via DelegatingHandlers
- Gateway forwards to IdentityServer for /connect/token or to services for business APIs
- Microservices validate tokens against IdentityServer’s JWKS endpoint
- Basket service caches state in Redis
- Catalog service uses MongoDB collections
- Order service implements internal CQRS/Mediator, persists in SQL DB
- Discount, Cargo, Comment, Message each own their SQL schema/migration
- RabbitMQMessageApi publishes/subscribes to RabbitMQ for async events
- SignalR hub pushes real-time updates to clients over WebSockets

##### Architectural patterns / principles
- Microservices (bounded contexts)
- API Gateway
- Token-based security (OAuth2/OIDC)
- CQRS + Mediator (Order service)
- Repository/Unit-of-Work via EF Core / Dapper / MongoDB abstractions
- DTO layers in UI to decouple client models
- Pub/Sub messaging (RabbitMQ)
- Real-time push (SignalR)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layer 1: Client/UI Layer
    subgraph "Client/UI Layer"
        direction TB
        WebUI["MS.WebUI"]:::frontend
        DTO["DTO Layer"]:::frontend
        RapidUI["RapidApi WebUI"]:::frontend
    end

    %% Layer 2: API Gateway
    subgraph "API Gateway"
        direction TB
        Gateway["MS.OcelotGateway"]:::gateway
    end

    %% Layer 3: Identity & Auth
    subgraph "Identity & Auth"
        direction TB
        Identity["MS.IdentityServer"]:::auth
    end

    %% Layer 4: Microservices
    subgraph "Microservices"
        direction TB
        Basket["Basket Service"]:::service
        Cargo["Cargo Service"]:::service
        Catalog["Catalog Service"]:::service
        Comment["Comment Service"]:::service
        Discount["Discount Service"]:::service
        ImageSvc["Image Service"]:::service
        ImageUI["Image UI"]:::service
        Message["Message Service"]:::service
        OrderAPI["Order Service API"]:::service
        Payment["Payment Service"]:::service
        RabbitMQApi["RabbitMQMessageApi"]:::broker
        SignalRApi["SignalRRealTimeApi"]:::service
    end

    %% Layer 5: Data Stores & Brokers
    subgraph "Data Stores & Brokers"
        direction TB
        Redis["Redis (Basket)"]:::db
        Mongo["MongoDB"]:::db
        SQL["SQL Databases"]:::db
        GCS["Cloud Storage (GCS)"]:::storage
        RabbitMQ["RabbitMQ Broker"]:::broker
    end

    %% Connections
    WebUI -->|HTTP| Gateway
    DTO -->|HTTP| Gateway
    RapidUI -->|HTTP| Gateway

    Gateway -->|routes| Identity
    Gateway -->|routes| Basket
    Gateway -->|routes| Cargo
    Gateway -->|routes| Catalog
    Gateway -->|routes| Comment
    Gateway -->|routes| Discount
    Gateway -->|routes| ImageSvc
    Gateway -->|routes| ImageUI
    Gateway -->|routes| Message
    Gateway -->|routes| OrderAPI
    Gateway -->|routes| Payment
    Gateway -->|routes| RabbitMQApi
    Gateway -->|routes| SignalRApi

    Basket -->|cache| Redis
    Catalog -->|data| Mongo
    Cargo -->|data| SQL
    Comment -->|data| SQL
    Discount -->|data| SQL
    Message -->|data| SQL
    OrderAPI -->|data| SQL
    Payment -->|data| SQL
    RabbitMQApi -->|AMQP| RabbitMQ
    SignalRApi -->|WebSocket| WebUI
    SignalRApi -->|WebSocket| RapidUI

    Message -->|push| SignalRApi

    ImageSvc -->|store| GCS
    ImageUI -->|store| GCS

    %% Click Events
    click WebUI "https://github.com/zehraseren/multishopproject/blob/master/Frontends/MS.WebUI"
    click DTO "https://github.com/zehraseren/multishopproject/blob/master/Frontends/MS.UI.DtoLayer"
    click RapidUI "https://github.com/zehraseren/multishopproject/blob/master/RapidApi/MS.RapidApiWebUI"
    click Gateway "https://github.com/zehraseren/multishopproject/blob/master/ApiGateway/MS.OcelotGateway"
    click Identity "https://github.com/zehraseren/multishopproject/blob/master/IdentityServer/MS.IdentityServer"
    click Basket "https://github.com/zehraseren/multishopproject/blob/master/Services/Basket/MS.Basket"
    click Cargo "https://github.com/zehraseren/multishopproject/blob/master/Services/Cargo/MS.Cargo.WepApi"
    click Catalog "https://github.com/zehraseren/multishopproject/blob/master/Services/Catalog/MS.Catalog"
    click Comment "https://github.com/zehraseren/multishopproject/blob/master/Services/Comment/MS.Comment"
    click Discount "https://github.com/zehraseren/multishopproject/blob/master/Services/Discount/MS.Discount"
    click ImageSvc "https://github.com/zehraseren/multishopproject/blob/master/Services/MS.Image"
    click ImageUI "https://github.com/zehraseren/multishopproject/blob/master/Service/Image/MS.Image.WebUI"
    click Message "https://github.com/zehraseren/multishopproject/blob/master/Services/Message/MS.Messages"
    click OrderAPI "https://github.com/zehraseren/multishopproject/blob/master/Services/Order/Presentation/MS.Order.WebApi"
    click Payment "https://github.com/zehraseren/multishopproject/blob/master/Services/MS.Payment"
    click RabbitMQApi "https://github.com/zehraseren/multishopproject/blob/master/RabbitMQMessage/MS.RabbitMQMessageApi"
    click SignalRApi "https://github.com/zehraseren/multishopproject/blob/master/Services/SignalRRealTimeApi/MS.SignalRRealTimeApi"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:1px
    classDef gateway fill:#ffa,stroke:#333,stroke-width:1px
    classDef auth fill:#fcc,stroke:#333,stroke-width:1px
    classDef service fill:#bbf,stroke:#333,stroke-width:1px
    classDef db fill:#bfb,stroke:#333,stroke-width:1px
    classDef broker fill:#fcf,stroke:#333,stroke-width:1px
    classDef storage fill:#cff,stroke:#333,stroke-width:1px
```
