# ashish-panicker/gateway-circuit-breaker architecture

> Architecture diagram of the GitHub repository ashish-panicker/gateway-circuit-breaker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ashish-panicker/gateway-circuit-breaker
- Repository: https://github.com/ashish-panicker/gateway-circuit-breaker

## Overview

##### Discovery Service (Eureka Server)
- Acts as the centralized service registry.
- All the other services (gateway, orders, and products) register themselves here for service discovery.

##### Gateway Service (Spring Cloud Gateway)
- Serves as the API gateway, routing incoming client requests to the appropriate microservice.
- It may also incorporate circuit breaker functionality to handle failures gracefully, as indicated in the project title.

##### Order Service
- Manages order-related operations, including creating orders.
- Contains a controller, model classes, and service layer implementations.
- It also includes a REST client (ProductServiceRestClient) to communicate with the product service.

##### Product Service
- Manages product-related operations such as retrieving and handling bulk product requests.
- Consists of controller, model, and service components.

- Discovery Service: Label it clearly as “Eureka Server/Discovery Service” and note that it registers and tracks all available services.
- Gateway Service: Mark it as “API Gateway” and add annotations for its role in routing and as the entry point for client requests.

B. Map the Relationships and Interactions:
- In addition, illustrate communication from the Order Service to the Product Service (via the REST client) to denote that orders depend on product data.

C. Highlight Architectural Patterns and Design Principles:
- Microservices architecture, with each service deployed independently.
- Use of Spring Cloud patterns such as service discovery and API gateway routing.
- Potential circuit breaker patterns if applicable (especially in the Gateway and Order service when calling the Product service).

D. Include Relevant Technologies and Frameworks:
- Mention that each service is built with Spring Boot and managed with Maven (as seen in the file structure with Maven wrappers and pom.xml files).
- Use of Docker for containerization (each service has a Dockerfile and there is a docker-compose.yaml file for orchestration).
- Optionally, include that the services are configured using application.properties or application.yaml files.

- Use another for the API gateway.
- And different categories for backend services (Order and Product services).
- Incoming client requests → Gateway Service.
- Gateway → Order Service and Product Service.
- Order Service (internal REST Client) → Product Service.
- Microservice registration → Discovery Service.

- Clear labels for each service/component with concise descriptions (e.g., “API Gateway: Handles incoming requests and applies circuit breaker logic”).
- Rounded rectangles for microservices.
- Annotations for technologies (Spring Boot, Maven, Docker) where relevant.

## Diagram (Mermaid)

```mermaid
graph TD
    Client["Client"]:::client
    APIGateway["API Gateway: Routes requests\nand applies circuit breaker logic"]:::gateway

    subgraph "Order Service"
        OrderService["Order Service: Manages Orders"]:::service
        OrderController["Order Controller"]:::internal
        ProductServiceRestClient["ProductServiceRestClient"]:::internal
        OrderService -->|"contains"| OrderController
        OrderService -->|"contains"| ProductServiceRestClient
    end

    subgraph "Product Service"
        ProductService["Product Service: Handles Products"]:::service
        ProductController["Product Controller"]:::internal
        ProductService -->|"contains"| ProductController
    end

    DiscoveryService["Eureka Server/Discovery Service"]:::discovery

    Client -->|"requests"| APIGateway
    APIGateway -->|"routes"| OrderService
    APIGateway -->|"routes"| ProductService
    OrderService -->|"calls_via_REST"| ProductService

    APIGateway -->|"registers"| DiscoveryService
    OrderService -->|"registers"| DiscoveryService
    ProductService -->|"registers"| DiscoveryService

    click DiscoveryService "https://github.com/ashish-panicker/gateway-circuit-breaker/blob/main/discovery-service/src/main/java/com/example/discovery_service/DiscoveryServiceApplication.java"
    click APIGateway "https://github.com/ashish-panicker/gateway-circuit-breaker/blob/main/gateway-service/src/main/java/com/example/gateway_service/GatewayServiceApplication.java"
    click OrderService "https://github.com/ashish-panicker/gateway-circuit-breaker/blob/main/order-service/src/main/java/com/example/order_service/OrderServiceApplication.java"
    click OrderController "https://github.com/ashish-panicker/gateway-circuit-breaker/blob/main/order-service/src/main/java/com/example/order_service/controller/OrderController.java"
    click ProductServiceRestClient "https://github.com/ashish-panicker/gateway-circuit-breaker/blob/main/order-service/src/main/java/com/example/order_service/service/ProductServiceRestClient.java"
    click ProductService "https://github.com/ashish-panicker/gateway-circuit-breaker/blob/main/product-service/src/main/java/com/example/product_service/ProductServiceApplication.java"
    click ProductController "https://github.com/ashish-panicker/gateway-circuit-breaker/blob/main/product-service/src/main/java/com/example/product_service/controller/ProductController.java"

    classDef client fill:#85C1E9,stroke:#1B4F72,stroke-width:2px;
    classDef gateway fill:#F7DC6F,stroke:#B7950B,stroke-width:2px;
    classDef service fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef internal fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef discovery fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
