# alifakoor/google-microservices-demo architecture

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

- Interactive diagram: https://gitdiagram.com/alifakoor/google-microservices-demo
- Repository: https://github.com/alifakoor/google-microservices-demo

## Overview

- Frontend Component: Representing the web server (written in Go) which serves the UI.
- Microservices: Create nodes for each service – adservice (Java), cartservice (C#), productcatalogservice (Go), currencyservice (Node.js), paymentservice (Node.js), shippingservice (Go), emailservice (Python), checkoutservice (Go), recommendationservice (Python), and loadgenerator (Python/Locust). Also include shoppingassistantservice if shown.
- Supporting Infrastructure: Identify backend data tiers such as Redis (cart storage), AlloyDB, Spanner, and Memorystore as referenced in deployment and Terraform directories.
- gRPC Messaging: Indicate the common communication layer (gRPC and Protocol Buffers) which sits between these services.
- API Gateway/Ingress: Incorporate the frontend’s external access point (with Kubernetes Ingress, Istio gateways, etc.) as shown by the istio-manifests and Kubernetes manifests.
- Deployment & Configuration Layers: Highlight deployment artifacts such as Helm charts, Kustomize overlays, Terraform modules, and Kubernetes YAML manifests that orchestrate the infrastructure.

##### Relationships and Interactions
- Demonstrate how the checkout service coordinates with other microservices (cart, payment, shipping, email).
- Data flow from the frontend → microservices (adservice, recommendationservice, etc.) → external databases (Redis, Spanner, AlloyDB, Memorystore).
- That each microservice has its own containerized deployment (reflected by Dockerfiles and Kubernetes manifests) and is orchestrated as part of a larger Kubernetes cluster.

##### Architectural Patterns and Design Principles
- Microservices Architecture: Clearly show that the system is divided into several small, independent services.
- Polyglot Persistence and Polyglot Programming: Each microservice may be written in a different language and may use different storage backends.
- Containerization and Orchestration: Emphasize that the application is deployed on Kubernetes (with supporting manifests, Helm charts, and Kustomize overlays).
- Service Mesh & Ingress: If using Istio or Cloud Service Mesh, show the logical separation of service communication, traffic management, and security policies.
- CI/CD Pipeline: Optionally illustrate the integration with GitHub Workflows and cloud build files, which help in continuously testing and deploying the application.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    A["Client Browser"]:::client
    B["API Gateway / Ingress"]:::gateway
    C["Frontend (Go)"]:::frontend

    %% Communication Middleware
    D["gRPC & Protobuf"]:::grpc

    %% Microservices Layer
    subgraph "Microservices"
        E["adservice (Java)"]:::microservice
        F["cartservice (C#)"]:::microservice
        G["productcatalogservice (Go)"]:::microservice
        H["currencyservice (Node.js)"]:::microservice
        I["paymentservice (Node.js)"]:::microservice
        J["shippingservice (Go)"]:::microservice
        K["emailservice (Python)"]:::microservice
        L["checkoutservice (Go)"]:::microservice
        M["recommendationservice (Python)"]:::microservice
        N["loadgenerator (Python/Locust)"]:::microservice
        O["shoppingassistantservice"]:::microservice
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        subgraph "Data Stores"
            P1["Redis"]:::infrastructure
            P2["AlloyDB"]:::infrastructure
            P3["Spanner"]:::infrastructure
            P4["Memorystore"]:::infrastructure
        end
        Q["Deployment & Configuration"]:::config
        R["Monitoring & Observability (GCP Ops)"]:::monitor
    end

    %% Relationships
    A -->|"HTTP"| B
    B -->|"HTTP"| C
    N -->|"Traffic"| C
    C -->|"gRPC"| D

    %% gRPC communication from middleware to microservices
    D --> E
    D --> F
    D --> G
    D --> H
    D --> I
    D --> J
    D --> K
    D --> L
    D --> M
    D --> O

    %% Checkout orchestration
    L -->|"orchestrates"| F
    L -->|"orchestrates"| I
    L -->|"orchestrates"| J
    L -->|"orchestrates"| K

    %% Microservices dependency on Data Stores (collectively)
    E ---|"uses"| P1
    F ---|"uses"| P1
    G ---|"uses"| P2
    H ---|"uses"| P3
    I ---|"uses"| P3
    J ---|"uses"| P4
    K ---|"uses"| P4
    L ---|"uses"| P1
    M ---|"uses"| P2
    O ---|"uses"| P1

    %% Deployment & Configuration management
    Q ---|"manages"| B
    Q ---|"manages"| C
    Q ---|"manages"| E
    Q ---|"manages"| F
    Q ---|"manages"| G
    Q ---|"manages"| H
    Q ---|"manages"| I
    Q ---|"manages"| J
    Q ---|"manages"| K
    Q ---|"manages"| L
    Q ---|"manages"| M
    Q ---|"manages"| N
    Q ---|"manages"| O
    Q ---|"integrates with"| R

    %% Styling for dashed management arrows
    linkStyle 18 stroke-dasharray: 5,5,stroke:#555,stroke-width:1px

    %% Click Events
    click C "https://github.com/alifakoor/google-microservices-demo/tree/main/src/frontend"
    click B "https://github.com/alifakoor/google-microservices-demo/blob/main/istio-manifests/frontend.yaml"
    click E "https://github.com/alifakoor/google-microservices-demo/tree/main/src/adservice"
    click F "https://github.com/alifakoor/google-microservices-demo/tree/main/src/cartservice"
    click L "https://github.com/alifakoor/google-microservices-demo/tree/main/src/checkoutservice"
    click H "https://github.com/alifakoor/google-microservices-demo/tree/main/src/currencyservice"
    click I "https://github.com/alifakoor/google-microservices-demo/tree/main/src/paymentservice"
    click G "https://github.com/alifakoor/google-microservices-demo/tree/main/src/productcatalogservice"
    click K "https://github.com/alifakoor/google-microservices-demo/tree/main/src/emailservice"
    click M "https://github.com/alifakoor/google-microservices-demo/tree/main/src/recommendationservice"
    click J "https://github.com/alifakoor/google-microservices-demo/tree/main/src/shippingservice"
    click N "https://github.com/alifakoor/google-microservices-demo/tree/main/src/loadgenerator"
    click O "https://github.com/alifakoor/google-microservices-demo/tree/main/src/shoppingassistantservice"
    click D "https://github.com/alifakoor/google-microservices-demo/tree/main/protos"
    click Q "https://github.com/alifakoor/google-microservices-demo/tree/main/helm-chart"
    click R "https://github.com/alifakoor/google-microservices-demo/tree/main/kustomize/components/google-cloud-operations"
    click P1 "https://github.com/alifakoor/google-microservices-demo/blob/main/terraform/memorystore.tf"

    %% Class Definitions
    classDef client fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef gateway fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef frontend fill:#abebc6,stroke:#1e8449,stroke-width:2px;
    classDef microservice fill:#fcf3cf,stroke:#b7950b,stroke-width:2px;
    classDef grpc fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef infrastructure fill:#f5b7b1,stroke:#a93226,stroke-width:2px;
    classDef config fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
    classDef monitor fill:#f9c4d0,stroke:#c0392b,stroke-width:2px;
```
