# pallaveejarad/microservices-backend architecture

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

- Interactive diagram: https://gitdiagram.com/pallaveejarad/microservices-backend
- Repository: https://github.com/pallaveejarad/microservices-backend

## Overview

##### Project Type and Purpose
- This is a backend microservices system built on Spring Boot and Spring Cloud.
- Purpose: Simulate a real-world order processing workflow with service discovery (Eureka), an API Gateway, inter-service communication, resilience patterns, and per-service persistence.

##### File Structure
- Top-level modules:
- api-gateway (Spring Cloud Gateway)
- eureka-server (Service Registry)
- product-service, order-service, payment-service (individual Spring Boot microservices)
- Each module uses Maven, has its own application.yml, src/main/java entrypoint, and test folder.
- Presence of Resilience4j, WebClient calls in service code (per README) and global exception handlers.
- No frontend—pure backend.

##### README for Additional Insights
- Ports and responsibilities of each service.
- Tech stack: Java 21, Spring Boot 3.3, Spring Cloud Gateway, Eureka, Resilience4j, WebClient, Spring Data JPA, MySQL.
- Future plans include distributed tracing, config server, Docker.

##### Essential Architectural Elements
- Circuit-breaker/fallback annotations on inter-service calls.
- Build and deployment hint: Maven wrapper (.mvn), potential Docker in future phases.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["External Client"]:::external

    subgraph "API Layer"
        direction TB
        Gateway["API Gateway\n(port 8080)"]:::gateway
        Registry["Eureka Server\n(port 8761)"]:::registry
    end

    subgraph "Microservices"
        direction TB
        PSvc["Product Service\n(port 8081)"]:::service
        OSvc["Order Service\n(port 8082)"]:::service
        PmntSvc["Payment Service\n(port 8083)"]:::service
    end

    subgraph "Databases"
        direction TB
        PDB[(productdb)]:::db
        ODB[(orderdb)]:::db
        PMDB[(paymentdb)]:::db
    end

    Client -->|HTTP Requests| Gateway
    Gateway -.->|Discover| Registry
    Gateway -->|Route to Product Service| PSvc
    Gateway -->|Route to Order Service| OSvc
    Gateway -->|Route to Payment Service| PmntSvc

    PSvc -.->|Register & Heartbeat| Registry
    OSvc -.->|Register & Heartbeat| Registry
    PmntSvc -.->|Register & Heartbeat| Registry

    OSvc -->|"WebClient + CircuitBreaker\nCheck Stock"| PSvc
    OSvc -->|"WebClient + CircuitBreaker\nProcess Payment"| PmntSvc

    PSvc -->|CRUD| PDB
    OSvc -->|CRUD| ODB
    PmntSvc -->|CRUD| PMDB

    click Gateway "https://github.com/pallaveejarad/microservices-backend/blob/main/api-gateway/src/main/java/com/api/gateway/ApiGatewayApplication.java"
    click Gateway "https://github.com/pallaveejarad/microservices-backend/blob/main/api-gateway/src/main/resources/application.yml"
    click Registry "https://github.com/pallaveejarad/microservices-backend/blob/main/eureka-server/src/main/java/com/eureka/server/EurekaServerApplication.java"
    click Registry "https://github.com/pallaveejarad/microservices-backend/blob/main/eureka-server/src/main/resources/application.yml"
    click PSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/product-service/src/main/java/com/product/ProductServiceApplication.java"
    click PSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/product-service/src/main/java/com/product/controller/ProductController.java"
    click PSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/product-service/src/main/java/com/product/service/ProductService.java"
    click PSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/product-service/src/main/java/com/product/repository/ProductRepository.java"
    click PSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/product-service/src/main/java/com/product/model/Product.java"
    click PSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/product-service/src/main/resources/application.yml"
    click OSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/order-service/src/main/java/com/order/OrderServiceApplication.java"
    click OSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/order-service/src/main/java/com/order/controller/OrderController.java"
    click OSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/order-service/src/main/java/com/order/service/OrderService.java"
    click OSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/order-service/src/main/java/com/order/repository/OrderRepository.java"
    click OSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/order-service/src/main/java/com/order/model/Order.java"
    click OSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/order-service/src/main/java/com/order/model/payment/PaymentDTO.java"
    click OSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/order-service/src/main/resources/application.yaml"
    click PmntSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/payment-service/src/main/java/com/payment/PaymentServiceApplication.java"
    click PmntSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/payment-service/src/main/java/com/payment/controller/PaymentController.java"
    click PmntSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/payment-service/src/main/java/com/payment/service/PaymentService.java"
    click PmntSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/payment-service/src/main/java/com/payment/repository/PaymentRepository.java"
    click PmntSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/payment-service/src/main/java/com/payment/model/Payment.java"
    click PmntSvc "https://github.com/pallaveejarad/microservices-backend/blob/main/payment-service/src/main/resources/application.yml"

    classDef external fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef gateway fill:#87CEEB,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    classDef registry fill:#1E90FF,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2;
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef db fill:#FFE4B5,stroke:#333,stroke-width:1px;
```
