# albertopasqualetto/onlineboutique-cloud-assignment architecture

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

- Interactive diagram: https://gitdiagram.com/albertopasqualetto/onlineboutique-cloud-assignment
- Repository: https://github.com/albertopasqualetto/onlineboutique-cloud-assignment

## Overview

##### Main Components
- Infrastructure Provisioning – Represented by files such as deployment.tf, variables.tf, terraform.tfvars.example, and directories like auto-deploy-loadgenerator and performance-evaluation with their Terraform definitions.
- Service Mesh & Traffic Management – The “istio” directory contains several YAML files (frontend-destinationrule.yaml, frontend-virtualservice.yaml, etc.) that configure Istio’s traffic management capabilities (such as canary routing and gateway configuration).
- Canary Deployment – The “canary-version” directory shows multiple Dockerfiles, canary YAML (flagger-canary.yaml), and load testing scripts (locustfile.py), indicating the use of canary or staged deployments (including static splits).
- Microservices Application – Although the “microservices-demo” folder does not expose details in this tree, it represents the core application, consisting of multiple services (for example, the checkoutservice and productcatalogservice within the “monitoring” folder are patched and containerized).
- Monitoring – The “monitoring” directory houses configurations for Prometheus, Grafana dashboards, and metric exporters. This aligns with capturing performance and operational metrics, critical in a microservices setup.
- Performance Evaluation & Load Generation – With directories like performance-evaluation (which includes analysis.py, various results CSV files, and load generator configurations) and auto-deploy-loadgenerator, the project emphasizes automated performance testing and result aggregation.

##### Relationships and Interactions
- The Terraform scripts provision the necessary cloud infrastructure and may be responsible for deploying load generators and setting up Kubernetes clusters.
- Once the cluster is running, Istio is installed to manage service-to-service traffic, where its configuration files dictate routing, load balancing, and canary deployment rules.
- The microservices (the core boutique application) are deployed on Kubernetes and are enhanced with Istio sidecar injection. They interact with each other (for instance, the checkoutservice and productcatalogservice) and expose endpoints that are monitored.
- The canary deployment components (frontend-v2, frontend-v3, and flagger configurations) illustrate how traffic is split and new versions are rolled out with controlled exposure.
- Monitoring components capture metrics (via Prometheus and Grafana) which then support performance evaluation. This evaluation is automated through load generation tools like Locust (as seen in locustfile.py) and subsequent analysis scripts that aggregate result CSVs.

##### Architectural Patterns
- Microservices Architecture – Several independently deployable components communicate over the service mesh.
- Infrastructure as Code – Terraform scripts are used for automated provisioning.
- Service Mesh – Istio-based traffic management, including gateways, virtual services, and destination rules.
- Canary Releases – Gradual release and A/B versioning is highlighted by canary configuration files.
- Monitoring & Observability – A strong emphasis on collecting, visualizing, and evaluating performance metrics.

##### Detailed Elements
- Cloud Provider and Kubernetes Cluster:
- Service Account & Credentials (as per README instructions)
- Terraform configuration triggering cluster creation and infrastructure setup.
- Istio Service Mesh:
- Istio Components (Gateway, Virtual Services, Destination Rules)
- Connections to microservices.
- Microservices:
- Core services (checkoutservice, productcatalogservice, etc.) within the microservices-demo.
- Deployment strategies (standard vs. canary) with separate versions for the frontend.
- Canary Deployment:
- Canary-version folder components including Dockerfiles for frontend v2 and v3, canary YAML for flagger.
- Link with load generation (via Locust) to simulate traffic during deployment changes.
- Monitoring & Performance Evaluation:
- Monitoring stack (Prometheus, Grafana configurations, dashboards).
- Performance evaluation scripts analyzing load test results and generating CSV reports.
- Auto-load generation tools orchestrated via Terraform and deployment pipelines.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure Provisioning
    subgraph "Infrastructure Provisioning"
        TR["Terraform Root Config"]:::infra
    end

    %% Deployment & Orchestration
    subgraph "Deployment & Orchestration"
        K8s["Kubernetes Cluster"]:::k8s
        MD["Boutique Microservices Deployment"]:::deploy
    end

    %% Service Mesh & Traffic Management
    subgraph "Service Mesh"
        Istio["Istio Service Mesh"]:::mesh
    end

    %% Canary Deployment
    subgraph "Canary Deployment"
        Canary["Canary Deployment Controller"]:::canary
    end

    %% Microservices Application
    subgraph "Microservices Application"
        Core["Core Microservices"]:::app
        Checkout["Checkout Service"]:::app
        Product["Product Catalog Service"]:::app
    end

    %% Monitoring & Alerting
    subgraph "Monitoring & Alerting"
        Mon["Monitoring & Alerting"]:::monitor
    end

    %% Performance Evaluation & Load Generation
    subgraph "Performance Evaluation & Load Generation"
        Perf["Performance Evaluation Scripts"]:::perf
        AutoLoad["Auto-deploy Load Generator Config"]:::perf
    end

    %% Connections
    TR -->|"provisions"| K8s
    K8s -->|"deploys"| MD
    K8s -->|"installs"| Istio
    MD -->|"hosts"| Core
    Istio -->|"routes traffic to"| Core
    Canary -->|"controls release for"| Core
    AutoLoad -->|"simulates load on"| Core
    Perf -->|"evaluates performance of"| Core
    Core -->|"comprises"| Checkout
    Core -->|"comprises"| Product
    Core -->|"emits metrics to"| Mon
    TR -->|"sets up"| Perf
    TR -->|"deploys"| AutoLoad

    %% Click Events
    click TR "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/blob/main/deployment.tf"
    click MD "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/tree/main/microservices-demo"
    click Istio "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/tree/main/istio"
    click Canary "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/tree/main/canary-version"
    click Core "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/tree/main/microservices-demo"
    click Checkout "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/tree/main/monitoring/checkoutservice"
    click Product "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/tree/main/monitoring/productcatalogservice"
    click Mon "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/tree/main/monitoring"
    click Perf "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/tree/main/performance-evaluation"
    click AutoLoad "https://github.com/albertopasqualetto/onlineboutique-cloud-assignment/tree/main/auto-deploy-loadgenerator"

    %% Styles
    classDef infra fill:#ccf,stroke:#333,stroke-width:2px;
    classDef k8s fill:#9f6,stroke:#333,stroke-width:2px;
    classDef deploy fill:#6cf,stroke:#333,stroke-width:2px;
    classDef mesh fill:#fc9,stroke:#333,stroke-width:2px;
    classDef canary fill:#f90,stroke:#333,stroke-width:2px;
    classDef app fill:#cff,stroke:#333,stroke-width:2px;
    classDef monitor fill:#f66,stroke:#333,stroke-width:2px;
    classDef perf fill:#ff9,stroke:#333,stroke-width:2px;
```
