# msvcbench/mubench architecture

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

- Interactive diagram: https://gitdiagram.com/msvcbench/mubench
- Repository: https://github.com/msvcbench/mubench

## Overview

##### Project Type and Purpose
- µBench is an orchestration‐and‐benchmarking tool for cloud/edge microservice applications. It is not a monolithic app, but a **factory** that programmatically generates, deploys, and monitors dummy microservice workloads on Kubernetes.

##### File‐Structure Analysis
- Top‐level “Deployers”, “ServiceGraphGenerator”, “WorkModelGenerator”, “Benchmarks”, “Autopilots”: these are Python CLI modules that drive the workflow.
- “Configs”: JSON parameter files that configure graph topology, resource settings, traffic patterns, etc.
- “Add-on” and “Monitoring”: optional, complementary scripts and manifests for Horizontal Pod Autoscaler, Istio service mesh, Prometheus/Grafana/Kiali/Jaeger.
- “ServiceCell”: a Dockerized microservice template implementing both REST and gRPC, plus stress‐functions library.
- CI/CD (“.github”), Dockerfile, and Docker-README for containerizing the entire µBench tool.

##### Key README Insights
- Users run scripts inside a Docker container to generate service graphs & work models, then deploy to Kubernetes via the “K8sDeployer”.
- The deployed application consists of an NGINX gateway (“gw-nginx”) fronting N service‐cell pods, wired by the generated service graph.
- A full observability stack (Prometheus, Grafana, Istio, Kiali, Jaeger) can be installed and configured.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Host/Client Side
    subgraph "Host/Client Side"
        direction TB
        User["User"]:::actor
        CLI["Docker CLI Container\n(msvcbench/mubench)"]:::container
        SG["ServiceGraphGenerator"]:::module
        WM["WorkModelGenerator"]:::module
        TG["TrafficGenerator\n(Benchmarks)"]:::module
        LR["LoadRunner\n(Benchmarks)"]:::module
        KD["K8sDeployer"]:::module
        AP["Autopilots"]:::module
        CFG["Configs\n(JSON files)"]:::configs
    end

    %% Kubernetes Control Plane
    subgraph "Kubernetes Control Plane"
        direction TB
        Kubectl["kubectl"]:::tool
        K8sAPI["Kubernetes API Server"]:::cloud
    end

    %% Kubernetes Data Plane
    subgraph "Kubernetes Data Plane"
        direction TB
        NS["Namespace µBench"]:::namespace
        CM["ConfigMaps & Deployments"]:::resources
        SVC_gate["Service: gw-nginx\n(NodePort)"]:::service
        GW["Pod: gw-nginx"]:::pod
        subgraph "Service-Cells"
            direction TB
            SC["Pods s0…sN\n(REST/gRPC + stress)"]:::pod
        end
    end

    %% Monitoring Stack
    subgraph "Monitoring Stack"
        direction TB
        Prom["Prometheus"]:::monitor
        Graf["Grafana"]:::monitor
        Istio["Istio\n(sidecars & resources)"]:::monitor
        Jaeg["Jaeger"]:::monitor
        Kiali["Kiali"]:::monitor
    end

    %% Workflows
    User -->|runs| CLI
    CLI --> SG
    CLI --> WM
    CLI --> TG
    CLI --> LR
    CLI --> KD
    CLI --> AP

    SG -->|"read JSON & gen YAML"| KD
    WM -->|"read JSON & gen YAML"| KD
    KD -->|"kubectl apply"| Kubectl
    Kubectl -->|"sync"| K8sAPI
    K8sAPI -->|"create"| NS
    NS --> CM
    CM --> GW
    CM --> SC
    CM --> SVC_gate

    TG -->|"HTTP traffic"| SVC_gate
    SVC_gate -->|"route to"| GW
    GW -->|"HTTP/gRPC calls"| SC
    SC -->|"HTTP/gRPC calls"| SC

    SC -->|"metrics/traces via sidecar"| Istio
    Istio -->|"scrape/collect"| Prom
    Istio -->|"send traces"| Jaeg
    Prom --> Graf
    Istio --> Kiali

    AP -->|"HPA/autoscale actions"| K8sAPI

    %% Click Events
    click SG "https://github.com/msvcbench/mubench/blob/main/ServiceGraphGenerator/RunServiceGraphGen.py"
    click SG "https://github.com/msvcbench/mubench/blob/main/ServiceGraphGenerator/ServiceGraphGenerator.py"
    click WM "https://github.com/msvcbench/mubench/blob/main/WorkModelGenerator/RunWorkModelGen.py"
    click WM "https://github.com/msvcbench/mubench/blob/main/WorkModelGenerator/WorkModelGenerator.py"
    click TG "https://github.com/msvcbench/mubench/blob/main/Benchmarks/TrafficGenerator/RunTrafficGen.py"
    click TG "https://github.com/msvcbench/mubench/blob/main/Benchmarks/TrafficGenerator/TrafficGenerator.py"
    click LR "https://github.com/msvcbench/mubench/blob/main/Benchmarks/Runner/Runner.py"
    click LR "https://github.com/msvcbench/mubench/blob/main/Benchmarks/Runner/TimingError.py"
    click KD "https://github.com/msvcbench/mubench/blob/main/Deployers/K8sDeployer/RunK8sDeployer.py"
    click KD "https://github.com/msvcbench/mubench/blob/main/Deployers/K8sDeployer/K8sYamlBuilder.py"
    click KD "https://github.com/msvcbench/mubench/blob/main/Deployers/K8sDeployer/K8sYamlDeployer.py"
    click KD "https://github.com/msvcbench/mubench/tree/main/Deployers/K8sDeployer/Templates"
    click AP "https://github.com/msvcbench/mubench/blob/main/Autopilots/K8sAutopilot/K8sAutopilot.py"
    click CFG "https://github.com/msvcbench/mubench/blob/main/Configs/ServiceGraphParameters.json"
    click CFG "https://github.com/msvcbench/mubench/blob/main/Configs/WorkModelParameters.json"
    click CFG "https://github.com/msvcbench/mubench/blob/main/Configs/TrafficParameters.json"
    click CFG "https://github.com/msvcbench/mubench/blob/main/Configs/RunnerParameters.json"
    click CFG "https://github.com/msvcbench/mubench/blob/main/Configs/K8sParameters.json"
    click CFG "https://github.com/msvcbench/mubench/blob/main/Configs/K8sAutopilotConf.json"

    %% Styles
    classDef actor fill:#f9f,stroke:#333,stroke-width:1px
    classDef container fill:#bbf,stroke:#333,stroke-width:1px
    classDef module fill:#bfb,stroke:#333,stroke-width:1px
    classDef configs fill:#ffeb99,stroke:#333,stroke-width:1px
    classDef cloud fill:#eee,stroke:#333,stroke-width:1px
    classDef tool fill:#fdd,stroke:#333,stroke-width:1px
    classDef namespace fill:#ffe4b5,stroke:#333,stroke-width:1px
    classDef resources fill:#f5f5dc,stroke:#333,stroke-width:1px
    classDef service fill:#ffd1a9,stroke:#333,stroke-width:1px
    classDef pod fill:#ffc0cb,stroke:#333,stroke-width:1px
    classDef monitor fill:#8fd3d1,stroke:#333,stroke-width:1px
```
