# ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce- architecture

> Architecture diagram of the GitHub repository ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-
- Repository: https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-

## Overview

##### Project Type and Purpose
- This is a full-stack microservices e-commerce platform with:
- Front-end: Angular single-page application (ecom-web-app)
- Identity & Access: Keycloak server for authentication/authorization
- API Gateway: Spring Cloud Gateway for routing and security
- Service Discovery: Eureka Discovery Service
- Microservices (Spring Boot, Maven):
– customer-service (manages customers)
– inventory-service (manages products)
– billign-service (billing, uses OpenFeign to fetch customer & product data)
– analytics-service (streams events, generates reports)
– random-orders (simulates order generation, produces events via Kafka)
- Messaging: Kafka for event streaming between services (random-orders → analytics)
- Orchestration: docker-compose.yml ties Keycloak, Eureka, Gateway, microservices, Kafka, Angular
- Purpose: Demonstrate JEE microservices, security with Keycloak, dynamic routing, OpenFeign, stream processing

##### File Structure Analysis
- Top-level modules correspond to each microservice and the front-end:
analytics-service, billign-service, customer-service, inventory-service, random-orders, gateway-service, eureka-discovery, keycloak, ecom-web-app
- Each microservice follows standard Spring Boot layout:
src/main/java/com/... for code, src/main/resources for properties, Dockerfile for containerization
- Gateway uses application.yml and static/dynamic route config under resources
- Eureka is a standalone Spring Boot app for service registry
- Angular front-end contains src/app modules: auth, services, components for customers, products, orders, charts
- Keycloak directory holds a local Keycloak distribution with standalone server, realms, clients, themes, providers
- docker-compose.yml orchestrates containers

##### README Insights
- Sequential steps illustrating:
1. Customer & Inventory microservices (REST)
2. Gateway static/dynamic routing via Eureka
3. Billing via OpenFeign
4. Angular UI for CRUD and order details
5. Keycloak realm/client/user/role setup and adapter integration in services & front-end
6. Kafka stream integration for analytics

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Users and Front-end
    User["Browser User"]:::frontend
    Angular["Angular SPA"]:::frontend
    User -->|"uses UI"| Angular
    Angular -->|"OIDC login"| Keycloak
    Keycloak -->|"JWT token"| Angular
    Angular -->|"REST API calls (HTTP + JWT)"| Gateway

    %% Identity Provider
    Keycloak["Keycloak Identity Provider"]:::identity

    %% Gateway and Discovery
    subgraph "API & Discovery" 
        Gateway["API Gateway\n(Spring Cloud Gateway)"]:::gateway
        Eureka["Eureka Service Registry"]:::gateway
    end
    Gateway -->|"registers & discovers services"| Eureka

    %% Microservices Layer
    subgraph "Microservices" 
        CustomerService["Customer Service"]:::service
        InventoryService["Inventory Service"]:::service
        BillingService["Billing Service"]:::service
        RandomOrders["Random Orders\n(Event Producer)"]:::service
        AnalyticsService["Analytics Service"]:::service
    end

    Gateway -->|"HTTP REST"| CustomerService
    Gateway -->|"HTTP REST"| InventoryService
    Gateway -->|"HTTP REST"| BillingService
    Gateway -->|"HTTP REST"| AnalyticsService

    BillingService -->|"Feign (via Gateway)"| CustomerService
    BillingService -->|"Feign (via Gateway)"| InventoryService

    %% Messaging
    subgraph "Event Streaming"
        Kafka["Kafka Cluster\n(topic: orders)"]:::messaging
    end
    RandomOrders -->|".. produces events ..\norders topic"| Kafka
    AnalyticsService -->|".. consumes events ..\norders topic"| Kafka

    %% Datastores
    subgraph "Databases"
        CustDB["Customer DB"]:::datastore
        InvDB["Inventory DB"]:::datastore
        BillDB["Billing DB"]:::datastore
        AnalyticsDB["Analytics DB"]:::datastore
    end
    CustomerService -->|Own datastore| CustDB
    InventoryService -->|Own datastore| InvDB
    BillingService -->|Own datastore| BillDB
    AnalyticsService -->|Own datastore| AnalyticsDB

    %% Orchestration
    DockerCompose["docker-compose.yml"]:::gateway
    DockerCompose -.->|orchestrates| Keycloak
    DockerCompose -.->|orchestrates| Eureka
    DockerCompose -.->|orchestrates| Gateway
    DockerCompose -.->|orchestrates| CustomerService
    DockerCompose -.->|orchestrates| InventoryService
    DockerCompose -.->|orchestrates| BillingService
    DockerCompose -.->|orchestrates| RandomOrders
    DockerCompose -.->|orchestrates| AnalyticsService
    DockerCompose -.->|orchestrates| Angular
    DockerCompose -.->|orchestrates| Kafka

    %% Click Events
    click Angular "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/tree/main/ecom-web-app/"
    click Keycloak "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/tree/main/keycloak/"
    click Gateway "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/tree/main/gateway-service/"
    click Eureka "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/tree/main/eureka-discovery/"
    click CustomerService "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/blob/main/customer-service/src/main/java/com/example/customerservice/CustomerServiceApplication.java"
    click InventoryService "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/blob/main/inventory-service/src/main/java/com/example/inventoryservice/InventoryServiceApplication.java"
    click BillingService "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/blob/main/billign-service/src/main/java/com/example/billignservice/BillingServiceApplication.java"
    click AnalyticsService "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/blob/main/analytics-service/src/main/java/com/analytics/AnalyticsServiceApplication.java"
    click RandomOrders "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/blob/main/random-orders/src/main/java/com/randomorders/RandomOrdersApplication.java"
    click DockerCompose "https://github.com/ayyoubtelmoudy/microservice-project-spring-cloud-e-commerce-/blob/main/docker-compose.yml"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef identity fill:#ffcc80,stroke:#333,stroke-width:1px
    classDef gateway fill:#d1c4e9,stroke:#333,stroke-width:1px
    classDef service fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef messaging fill:#fff9c4,stroke:#333,stroke-width:1px
    classDef datastore fill:#eeeeee,stroke:#333,stroke-width:1px
```
