# sloweyyy/cloud-native-ecommerce-platform architecture

> Architecture diagram of the GitHub repository sloweyyy/cloud-native-ecommerce-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sloweyyy/cloud-native-ecommerce-platform
- Repository: https://github.com/sloweyyy/cloud-native-ecommerce-platform

## Overview

##### Core Components
- Frontend Client: Represent the Angular-based web client that provides the user interface. Include details like its use of Material UI/Tailwind CSS and its connection to the Identity Server for authentication.
- API Gateway: Clearly show the Ocelot API Gateway, which serves as the single entry point to the microservices. Note that it handles routing, aggregation, and cross-cutting concerns such as JWT authentication and rate limiting.
- API Layer: REST endpoints/controllers.
- Application Layer: Business logic (commands, queries, handlers, and behaviors implementing CQRS).
- Core/Domain Layer: Business rules, entities, domain models.
- Infrastructure Layer: Data persistence, repository implementations, external integrations (e.g., Redis, MongoDB, PostgreSQL, SQL Server).
- Shared Components:
- Event Bus/Message Broker: Illustrate RabbitMQ that facilitates asynchronous, event-driven communication between services.
- Shared Infrastructure: Include common components such as the centralized logging (Serilog/ Common.Logging) and event bus messages located under the Infrastructure folders.
- Databases: Map out the databases linked to each service:
- Catalog – MongoDB
- Basket – Redis
- Discount – PostgreSQL
- Ordering – SQL Server
- Deployment & Orchestration: Include Kubernetes as the orchestration platform, Helm charts for deployment, and Istio as the service mesh for observability and traffic management.
- Monitoring & Logging: Represent the monitoring tools such as Elasticsearch, Kibana, and any health-check mechanisms in place.

##### Relationships and Interactions
- The Client communicates with the system via the API Gateway.
- The API Gateway routes requests to the corresponding microservice.
- Within each microservice, illustrate the separation between the API, Application, Domain, and Infrastructure layers.
- Integration points:
- Database connections per service.
- External calls from the API Gateway to microservices.
- Cross-service communications using the message broker.

##### Architectural Patterns and Principles
- Microservices Architecture: Emphasize the isolation and autonomous deployment of services.
- Clean Architecture: For each microservice, visually separate the core, application, and infrastructure layers so that responsibilities are clear.
- Service Mesh: Note the role of Istio in managing network traffic and observability.
- API Gateway Pattern: Underline the role of Ocelot in centralizing routing and security.

##### Mention Relevant Technologies and Frameworks
- Backend: .NET Core 8.0, CQRS with MediatR, Entity Framework Core, and Dapper.
- Frontend: Angular, TypeScript, and Angular Material/Tailwind CSS.
- Databases: MongoDB, Redis, PostgreSQL, SQL Server.
- Messaging: RabbitMQ.
- Deployment Tools: Docker, Docker Compose, Kubernetes, Helm, and Istio.
- Monitoring: Elasticsearch and Kibana.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    FE["Frontend Client (Angular)"]:::frontend
    APIGW["API Gateway (Ocelot)"]:::gateway
    FE -->|"calls"| APIGW

    %% Microservices
    subgraph "Basket Microservice"
        BA_API["Basket API"]:::layer
        BA_App["Basket Application"]:::layer
        BA_Core["Basket Core"]:::layer
        BA_Infra["Basket Infrastructure"]:::layer
        BA_API -->|"calls"| BA_App
        BA_App -->|"calls"| BA_Core
        BA_Core -->|"calls"| BA_Infra
    end
    APIGW -->|"routes"| BA_API

    subgraph "Catalog Microservice"
        CAT_API["Catalog API"]:::layer
        CAT_App["Catalog Application"]:::layer
        CAT_Core["Catalog Core"]:::layer
        CAT_Infra["Catalog Infrastructure"]:::layer
        CAT_API -->|"calls"| CAT_App
        CAT_App -->|"calls"| CAT_Core
        CAT_Core -->|"calls"| CAT_Infra
    end
    APIGW -->|"routes"| CAT_API

    subgraph "Discount Microservice"
        DIS_API["Discount API"]:::layer
        DIS_App["Discount Application"]:::layer
        DIS_Core["Discount Core"]:::layer
        DIS_Infra["Discount Infrastructure"]:::layer
        DIS_API -->|"calls"| DIS_App
        DIS_App -->|"calls"| DIS_Core
        DIS_Core -->|"calls"| DIS_Infra
    end
    APIGW -->|"routes"| DIS_API

    subgraph "Ordering Microservice"
        ORD_API["Ordering API"]:::layer
        ORD_App["Ordering Application"]:::layer
        ORD_Core["Ordering Core"]:::layer
        ORD_Infra["Ordering Infrastructure"]:::layer
        ORD_API -->|"calls"| ORD_App
        ORD_App -->|"calls"| ORD_Core
        ORD_Core -->|"calls"| ORD_Infra
    end
    APIGW -->|"routes"| ORD_API

    %% Databases
    BDB["Basket Database (Redis)"]:::database
    CAT_DB["Catalog Database (MongoDB)"]:::database
    DIS_DB["Discount Database (PostgreSQL)"]:::database
    ORD_DB["Ordering Database (SQL Server)"]:::database

    BA_Infra -->|"writes"| BDB
    CAT_Infra -->|"writes"| CAT_DB
    DIS_Infra -->|"writes"| DIS_DB
    ORD_Infra -->|"writes"| ORD_DB

    %% Shared Components
    subgraph "Shared Components"
        RabbitMQ["RabbitMQ"]:::messaging
        EventBus["EventBus Messages"]:::messaging
        Logging["Shared Logging Infrastructure"]:::logging
        RabbitMQ ---|"messages"| EventBus
    end

    BA_Infra -.->|"publishes"| RabbitMQ
    CAT_Infra -.->|"publishes"| RabbitMQ
    DIS_Infra -.->|"publishes"| RabbitMQ
    ORD_Infra -.->|"publishes"| RabbitMQ

    BA_Infra -.->|"logs"| Logging
    CAT_Infra -.->|"logs"| Logging
    DIS_Infra -.->|"logs"| Logging
    ORD_Infra -.->|"logs"| Logging

    %% Deployment & Orchestration
    subgraph "Deployment & Orchestration"
        Helm["Helm Charts"]:::deployment
        K8s["Kubernetes"]:::deployment
        Istio["Istio Service Mesh"]:::deployment
        APIGWDep["API Gateway Deployment"]:::deployment
        ES["Elasticsearch"]:::monitoring
        Kibana["Kibana"]:::monitoring
        Helm --> K8s
        Helm --> Istio
    end

    %% Click Events
    click FE "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/client/"
    click APIGW "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/ApiGateways/Ocelot.ApiGateway"
    click BA_API "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Basket/Basket.API"
    click BA_App "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Basket/Basket.Application"
    click BA_Core "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Basket/Basket.Core"
    click BA_Infra "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Basket/Basket.Infrastructure"
    click CAT_API "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Catalog/Catalog.API"
    click CAT_App "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Catalog/Catalog.Application"
    click CAT_Core "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Catalog/Catalog.Core"
    click CAT_Infra "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Catalog/Catalog.Infrastructure"
    click DIS_API "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Discount/Discount.API"
    click DIS_App "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Discount/Discount.Application"
    click DIS_Core "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Discount/Discount.Core"
    click DIS_Infra "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Discount/Discount.Infrastructure"
    click ORD_API "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Ordering/Ordering.API"
    click ORD_App "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Ordering/Ordering.Application"
    click ORD_Core "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Ordering/Ordering.Core"
    click ORD_Infra "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Services/Ordering/Ordering.Infrastructure"
    click RabbitMQ "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/helm/rabbitmq"
    click EventBus "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Infrastructure/EventBus.Messages"
    click Logging "https://github.com/sloweyyy/cloud-native-ecommerce-platform/blob/main/Infrastructure/Common.Logging"
    click BDB "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/helm/basketdb"
    click CAT_DB "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/helm/catalogdb"
    click DIS_DB "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/helm/discountdb"
    click ORD_DB "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/helm/orderdb"
    click APIGWDep "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/helm/ocelotapigw"
    click Helm "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/helm/"
    click K8s "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/k8s/"
    click Istio "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/istio"
    click ES "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/helm/elasticsearch"
    click Kibana "https://github.com/sloweyyy/cloud-native-ecommerce-platform/tree/main/Deployments/helm/kibana"

    %% Styles
    classDef frontend fill:#85C1E9,stroke:#2E86C1,stroke-width:2px;
    classDef gateway fill:#F5B041,stroke:#CA6F1E,stroke-width:2px;
    classDef layer fill:#AED6F1,stroke:#5DADE2,stroke-width:2px;
    classDef database fill:#FCF3CF,stroke:#F4D03F,stroke-width:2px;
    classDef deployment fill:#D2B4DE,stroke:#AF7AC5,stroke-width:2px;
    classDef messaging fill:#F9E79F,stroke:#F4D03F,stroke-width:2px;
    classDef logging fill:#D5DBDB,stroke:#AAB7B8,stroke-width:2px;
    classDef monitoring fill:#AED6F1,stroke:#5DADE2,stroke-width:2px;
```
