# mayank-yadav26/springboot-microservices architecture

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

- Interactive diagram: https://gitdiagram.com/mayank-yadav26/springboot-microservices
- Repository: https://github.com/mayank-yadav26/springboot-microservices

## Overview

##### Main Components
- API Gateway: Acts as the single entry point routing incoming requests to the proper backend services. Emphasize its integration with Spring Cloud Gateway and potential use of Spring Security for authentication and Resilience4j for circuit breaking.
- Discovery Server (Eureka): Central registry for all microservices enabling dynamic service discovery. Illustrate Eureka’s role in eliminating hardcoded URLs and enabling dynamic scaling.
- Microservices:
– Product Service (with MongoDB): Emphasize its flexible schema design, storing products with fields such as id, name, description, and price.
– Inventory Service (with MySQL): Highlight the relational database ensuring transactional integrity and stock consistency.
– Order Service (with MySQL): Include its responsibilities regarding processing orders, maintaining transactional integrity, and using Kafka for event-driven communication (sending order placed events).
– Notification Service: Show that it processes events (for example, order events) and likely triggers notifications.
- External Systems & Infrastructure:
– Kafka Messaging Queue: Indicate its role in the order service for event communication.
– Monitoring Tools: Include Prometheus (and associated Actuator endpoints) for health and metrics monitoring.
- Kubernetes (k8s) Deployment: Represent the deployment manifests, Kind cluster, and your k8s configurations that are used for container orchestration and scaling.

##### Relationships and Interactions
- Monitoring/metrics flow from each service to Prometheus.

##### Architectural Patterns and Design Principles
- Microservices pattern by individually isolating each service.
- Mention the use of API Gateway for abstraction, load balancing, and security.
- Service discovery (Eureka) which abstracts inter-service communication.
- Use of event-driven patterns with Kafka in the Order Service.
- Underline the separation of concerns by assigning different databases for structured (MySQL) vs. unstructured (MongoDB) data.

##### Technologies and Frameworks
- Spring Boot (core framework for microservices)
- Spring Cloud Gateway (API routing, security, and resiliency)
- Eureka (service registry/discovery)
- Resilience4j (circuit breaker, retry mechanisms)
- Kafka (messaging/event streaming)
- MongoDB (NoSQL database for Product Service)
- MySQL (relational database for Inventory & Order Services)
- Kubernetes (for container orchestration and deployment)
- Prometheus (monitoring and health check endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Client["Client Request"]:::frontend

    %% Kubernetes Configuration Node (Deployment Configurations)
    KC["Kubernetes Configurations"]:::infra

    %% Databases and Monitoring (External Infrastructure)
    MDB["MongoDB"]:::db
    MYDB["MySQL"]:::db
    PROM["Prometheus"]:::infra

    %% Kubernetes Deployment Subgraph
    subgraph "Kubernetes Deployment"
        AG["API Gateway"]:::api
        DS["Discovery Server (Eureka)"]:::service
        PS["Product Service (MongoDB)"]:::service
        IS["Inventory Service (MySQL)"]:::service
        OS["Order Service (MySQL & Kafka)"]:::service
        NS["Notification Service"]:::service
        KAFKA["Kafka Messaging Queue"]:::infra
    end

    %% Client Interaction
    Client -->|"routes"| AG

    %% Kubernetes Deployment Trigger
    KC -->|"deploys"| AG

    %% API Gateway interactions
    AG -->|"discovers"| DS
    AG -->|"routes"| PS
    AG -->|"routes"| IS
    AG -->|"routes"| OS

    %% Service Registration with Discovery Server
    PS -->|"registers"| DS
    IS -->|"registers"| DS
    OS -->|"registers"| DS
    NS -->|"registers"| DS

    %% Database Connections
    PS -->|"uses"| MDB
    IS -->|"uses"| MYDB
    OS -->|"uses"| MYDB

    %% Kafka Event-Driven Communication
    OS -->|"sends_event"| KAFKA
    KAFKA -->|"delivers_event"| NS

    %% Monitoring (Metrics Collection)
    AG -->|"metrics"| PROM
    DS -->|"metrics"| PROM
    PS -->|"metrics"| PROM
    IS -->|"metrics"| PROM
    OS -->|"metrics"| PROM
    NS -->|"metrics"| PROM

    %% Styles
    classDef api fill:#f9d5e5,stroke:#d56c91,stroke-width:2px;
    classDef service fill:#d5e5f9,stroke:#6c91d5,stroke-width:2px;
    classDef db fill:#f9f9d5,stroke:#d5d56c,stroke-width:2px;
    classDef infra fill:#d5f9e5,stroke:#6cd591,stroke-width:2px;
    classDef frontend fill:#ffe0b2,stroke:#fb8c00,stroke-width:2px;

    %% Click Events
    click AG "https://github.com/mayank-yadav26/springboot-microservices/blob/main/api-gateway/src/main/java/com/mayanktech/apigateway/ApiGateWayApplication.java"
    click DS "https://github.com/mayank-yadav26/springboot-microservices/blob/main/discovery-server/src/main/java/com/mayanktech/discoveryserver/DiscoveryServerApplication.java"
    click PS "https://github.com/mayank-yadav26/springboot-microservices/blob/main/product-service/src/main/java/com/mayanktech/productservice/ProductServiceApplication.java"
    click IS "https://github.com/mayank-yadav26/springboot-microservices/blob/main/inventory-service/src/main/java/com/mayanktech/inventoryservice/InventoryServiceApplication.java"
    click OS "https://github.com/mayank-yadav26/springboot-microservices/blob/main/order-service/src/main/java/com/mayanktech/orderservice/OrderServiceApplication.java"
    click NS "https://github.com/mayank-yadav26/springboot-microservices/blob/main/notification-service/src/main/java/com/mayanktech/notificationservice/NotificationServiceApplication.java"
    click KC "https://github.com/mayank-yadav26/springboot-microservices/tree/main/k8s/"
    click PROM "https://github.com/mayank-yadav26/springboot-microservices/blob/main/prometheus/prometheus.yml"
```
