# nomoreft/e-commerce-app architecture

> Architecture diagram of the GitHub repository nomoreft/e-commerce-app, 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/nomoreft/e-commerce-app
- Repository: https://github.com/nomoreft/e-commerce-app

## Overview

##### Main Components

a. Core Services Layer:
- Customer Service
- Product Service
- Order Service
- Payment Service
- Notification Service

b. Infrastructure Services:
- Config Server (Spring Cloud Config)
- Discovery Service (Eureka)
- API Gateway

c. Message Broker:
- Kafka (evident from Kafka configurations in notification and payment services)

d. Databases:
- Individual databases for each service (following microservices pattern)

##### Component Relationships

a. Client Layer:
- External clients connect through the API Gateway
- Gateway handles security (noted by SecurityConfig in gateway service)

b. Service Communication:
- Synchronous communications via REST (evident from *Client.java files)
- Asynchronous communications via Kafka (particularly for notifications)
- Service discovery through Eureka

c. Data Flow Patterns:
- Order → Payment → Notification flow
- Product purchase flow
- Customer information flow

##### Specific Implementation Details

Use these visual elements:

- Blue: Core business services
- Green: Infrastructure services
- Yellow: Message broker
- Gray: Databases
- Purple: External clients/API Gateway

b. Connection Types:

##### Additional Elements

Components:
- Configuration management flow from Config Server
- Service registration/discovery with Eureka
- Kafka topics for order and payment notifications
- Security boundary at Gateway level

##### Specific Notations

Details:
- Service ports and names
- Main API endpoints
- Database types (if specified in configurations)
- Kafka topics: order-confirmation, payment-confirmation

##### Technical Stack Indicators

Technology usage:
- Spring Boot/Cloud
- Kafka
- Eureka
- Spring Cloud Gateway
- Spring Cloud Config

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef client fill:#9370DB,stroke:#333,stroke-width:2px
    classDef gateway fill:#9370DB,stroke:#333,stroke-width:2px
    classDef service fill:#4682B4,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#98FB98,stroke:#333,stroke-width:2px
    classDef messaging fill:#FFD700,stroke:#333,stroke-width:2px
    classDef database fill:#A9A9A9,stroke:#333,stroke-width:2px

    %% Client Layer
    Client["External Clients"]:::client

    %% Gateway Layer
    Gateway["API Gateway"]:::gateway
    click Gateway "https://github.com/nomoreFt/e-commerce-app/tree/master/services/gateway"

    %% Core Services Layer
    CustomerService["Customer Service"]:::service
    click CustomerService "https://github.com/nomoreFt/e-commerce-app/tree/master/services/customer"
    ProductService["Product Service"]:::service
    click ProductService "https://github.com/nomoreFt/e-commerce-app/tree/master/services/product"
    OrderService["Order Service"]:::service
    click OrderService "https://github.com/nomoreFt/e-commerce-app/tree/master/services/order"
    PaymentService["Payment Service"]:::service
    click PaymentService "https://github.com/nomoreFt/e-commerce-app/tree/master/services/payment"
    NotificationService["Notification Service"]:::service
    click NotificationService "https://github.com/nomoreFt/e-commerce-app/tree/master/services/notification"

    %% Infrastructure Services
    ConfigServer["Config Server"]:::infrastructure
    click ConfigServer "https://github.com/nomoreFt/e-commerce-app/tree/master/services/config-server"
    Discovery["Discovery Service<br/>(Eureka)"]:::infrastructure
    click Discovery "https://github.com/nomoreFt/e-commerce-app/tree/master/services/discovery"

    %% Message Broker
    Kafka["Kafka Message Broker"]:::messaging

    %% Databases
    CustomerDB[(Customer DB)]:::database
    ProductDB[(Product DB)]:::database
    OrderDB[(Order DB)]:::database
    PaymentDB[(Payment DB)]:::database
    NotificationDB[(Notification DB)]:::database

    %% Relationships
    Client --> Gateway
    Gateway --> CustomerService
    Gateway --> ProductService
    Gateway --> OrderService
    Gateway --> PaymentService

    CustomerService --> CustomerDB
    ProductService --> ProductDB
    OrderService --> OrderDB
    PaymentService --> PaymentDB
    NotificationService --> NotificationDB

    OrderService -.-> Kafka
    PaymentService -.-> Kafka
    Kafka -.-> NotificationService

    ConfigServer --> CustomerService
    ConfigServer --> ProductService
    ConfigServer --> OrderService
    ConfigServer --> PaymentService
    ConfigServer --> NotificationService
    ConfigServer --> Gateway

    CustomerService --> Discovery
    ProductService --> Discovery
    OrderService --> Discovery
    PaymentService --> Discovery
    NotificationService --> Discovery
    Gateway --> Discovery

    %% Legend
    subgraph Legend
        ClientLegend["Client/Gateway"]:::client
        ServiceLegend["Core Services"]:::service
        InfraLegend["Infrastructure"]:::infrastructure
        MessagingLegend["Message Broker"]:::messaging
        DBLegend[(Database)]:::database
    end

    %% Relationship Types
    style Legend fill:#fff,stroke:#333,stroke-width:2px
    linkStyle 0,1,2,3,4,5,6,7,8,9 stroke:#333,stroke-width:2px
    linkStyle 10,11,12 stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
    linkStyle 13,14,15,16,17,18 stroke:#333,stroke-width:1px,stroke-dasharray: 3 3
    linkStyle 19,20,21,22,23,24 stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
