# shaikrasheed99/kotlin-ecommerce-microservices architecture

> Architecture diagram of the GitHub repository shaikrasheed99/kotlin-ecommerce-microservices, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shaikrasheed99/kotlin-ecommerce-microservices
- Repository: https://github.com/shaikrasheed99/kotlin-ecommerce-microservices

## Overview

##### Main Components

a. Client-Facing Layer:
- API Gateway (Spring Cloud Gateway)
- Service Discovery (Spring Cloud Netflix)

b. Core Microservices:
- Order Service
- Inventory Service
- Notification Service

c. Data Layer:
- Individual databases for each service
- Kafka message broker
- Outbox and Inbox tables

d. Infrastructure Components:
- Kubernetes cluster components
- Network policies
- Persistent volumes

##### Connection Types

- Service discovery registrations (curved lines)

##### Special Patterns to Highlight

Create dedicated sections or callouts for:
- Transactional Outbox Pattern implementation
- Event Inbox Pattern flow
- Circuit Breaker pattern
- Distributed Scheduler Locking with ShedLock

##### Additional Elements

Include:
- Security scanning components
- Kubernetes orchestration boundary
- Configuration management (ConfigMaps and Secrets)

##### Technical Details

For each service, show:
- Technology stack (Kotlin, Spring Boot)
- Database type
- Exposed ports
- Resource requirements

- Nested containers (for Kubernetes components)
- Layered arrangements
- Export to high-resolution formats

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        Client1[Client Applications]
    end

    subgraph Gateway["Gateway Layer"]
        APIG[API Gateway]:::gateway
        SD[Service Discovery]:::discovery
    end

    subgraph Services["Service Layer"]
        OS[Order Service]:::service
        IS[Inventory Service]:::service
        NS[Notification Service]:::service
    end

    subgraph MessageBroker["Message Broker Layer"]
        KF[Kafka]:::messagebroker
        ZK[Zookeeper]:::messagebroker
    end

    subgraph DataLayer["Data Layer"]
        direction TB
        subgraph Outbox["Outbox/Inbox Pattern"]
            OB[Order Outbox]:::data
            IB1[Inventory Inbox]:::data
            IB2[Notification Inbox]:::data
        end
        
        subgraph Databases["Service Databases"]
            direction TB
            ODB[(Order DB)]:::database
            IDB[(Inventory DB)]:::database
            NDB[(Notification DB)]:::database
        end
    end

    subgraph Infrastructure["Infrastructure Layer"]
        direction TB
        NP[Network Policies]:::infra
        PV[Persistent Volumes]:::infra
        KC[Kubernetes Configs]:::infra
        SC[Secrets]:::infra
    end

    %% Connections
    Client1 --> APIG
    APIG <--> SD
    APIG --> OS
    APIG --> IS
    APIG --> NS

    OS --> OB
    OB --> KF
    KF --> IB1
    KF --> IB2

    OS --> ODB
    IS --> IDB
    NS --> NDB

    OS <-.-> SD
    IS <-.-> SD
    NS <-.-> SD

    KF --- ZK

    %% Infrastructure Connections
    ODB -.-> PV
    IDB -.-> PV
    NDB -.-> PV
    
    OS -.-> NP
    IS -.-> NP
    NS -.-> NP

    OS -.-> KC
    IS -.-> KC
    NS -.-> KC

    OS -.-> SC
    IS -.-> SC
    NS -.-> SC

    %% Styling
    classDef gateway fill:#f9a,stroke:#333
    classDef discovery fill:#adf,stroke:#333
    classDef service fill:#9cf,stroke:#333
    classDef messagebroker fill:#c9f,stroke:#333
    classDef database fill:#9f9,stroke:#333
    classDef data fill:#ff9,stroke:#333
    classDef infra fill:#ddd,stroke:#333

    %% Click Events
    click APIG "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/api-gateway/src/main/kotlin/com/ecommerce/apigateway/ApiGatewayApplication.kt"
    click SD "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/discovery-server/src/main/kotlin/com/ecommerce/discoveryserver/DiscoveryServerApplication.kt"
    click OS "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/order-service/src/main/kotlin/com/ecommerce/orderservice/OrderServiceApplication.kt"
    click IS "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/inventory-service/src/main/kotlin/com/ecommerce/inventoryservice/InventoryServiceApplication.kt"
    click NS "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/notification-service/src/main/kotlin/com/ecommerce/notificationservice/NotificationServiceApplication.kt"
    click KF "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/k8s/deployments/tools/kafka-deploy.yaml"
    click ZK "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/k8s/deployments/tools/zookeeper-deploy.yaml"
    click ODB "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/k8s/deployments/databases/order-service-db-deploy.yaml"
    click IDB "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/k8s/deployments/databases/inventory-service-db-deploy.yaml"
    click NDB "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/k8s/deployments/databases/notification-service-db-deploy.yaml"
    click OB "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/order-service/src/main/kotlin/com/ecommerce/orderservice/models/Outbox.kt"
    click IB1 "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/inventory-service/src/main/kotlin/com/ecommerce/inventoryservice/models/inbox/Inbox.kt"
    click IB2 "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/notification-service/src/main/kotlin/com/ecommerce/notificationservice/models/inbox/Inbox.kt"
    click NP "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/tree/main/k8s/network-policies"
    click PV "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/tree/main/k8s/persistent-volumes"
    click KC "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/k8s/config-maps/configs.yaml"
    click SC "https://github.com/shaikrasheed99/kotlin-ecommerce-microservices/blob/main/k8s/secrets/db-secrets.yaml"
```
