graph TB
    subgraph External["EXTERNAL (Untrusted)"]
        Client["Client / Data Scientist"]
    end

    subgraph DistBoundary["LLAMA STACK DISTRIBUTION (Component Boundary)"]
        direction TB
        LLSServer["Llama Stack Distribution Server<br/>ClusterIP 8321/TCP HTTP<br/>Auth: None (delegated to ingress)<br/>Managed by: Llama Stack Operator"]

        subgraph Provider["llama-stack-provider-ragas<br/>Image: rhoai/odh-trustyai-ragas-lls-provider-dsp-rhel9<br/>Python 3.12 / UBI9"]
            InlineEval["Inline Evaluator<br/>In-process LLM + Embeddings<br/>max_workers=1"]
            RemoteEval["Remote Evaluator<br/>KFP pipeline submission<br/>Async job tracking"]
        end

        LLSServer -->|in-process<br/>delegation| InlineEval
        LLSServer -->|in-process<br/>delegation| RemoteEval
    end

    subgraph KFPZone["KUBEFLOW PIPELINES ZONE"]
        direction TB
        KFPAPI["Kubeflow Pipelines API<br/>443/TCP HTTPS<br/>TLS 1.2+<br/>Bearer Token"]
        KFPPod["KFP Pipeline Pod<br/>retrieve_data + run_ragas<br/>Image: ragas-provider"]
        KFPAPI -->|creates| KFPPod
    end

    subgraph ExternalServices["EXTERNAL SERVICES"]
        direction TB
        S3["S3-compatible Storage<br/>443/TCP HTTPS<br/>TLS 1.2+<br/>AWS IAM credentials"]
        vLLM["Ollama / vLLM<br/>8443/TCP or 11434/TCP<br/>HTTP/HTTPS configurable<br/>Bearer Token (optional)"]
        K8sAPI["Kubernetes API Server<br/>443/TCP HTTPS<br/>TLS 1.2+<br/>ServiceAccount token"]
    end

    subgraph Secrets["SECRETS (User-Provisioned, No Auto-Rotation)"]
        direction LR
        KFPToken["kubeflow-pipelines-token<br/>⚠️ OpenShift user token<br/>(limited TTL)"]
        AWSCreds["aws-credentials<br/>AccessKeyId / SecretAccessKey"]
        ModelSecret["llama-stack-inference-model-secret<br/>Model name, vLLM URL, API token"]
    end

    %% External to Distribution
    Client -->|"HTTP/8321<br/>No encryption<br/>Auth: None"| LLSServer

    %% Remote evaluator egress
    RemoteEval -->|"HTTPS/443<br/>TLS 1.2+<br/>Bearer Token"| KFPAPI
    RemoteEval -->|"HTTPS/443<br/>TLS 1.2+<br/>AWS IAM"| S3

    %% KFP Pod connections
    KFPPod -->|"HTTP/8321<br/>No auth"| LLSServer
    KFPPod -->|"HTTPS/443<br/>TLS 1.2+<br/>AWS IAM"| S3

    %% Inference backend
    LLSServer -->|"HTTP(S)/8443 or 11434<br/>Configurable TLS<br/>⚠️ VLLM_TLS_VERIFY flag"| vLLM

    %% Kubernetes API
    RemoteEval -->|"HTTPS/443<br/>TLS 1.2+<br/>SA token / kubeconfig"| K8sAPI

    %% Secret usage (dotted)
    KFPToken -.->|used by| RemoteEval
    AWSCreds -.->|used by| RemoteEval
    AWSCreds -.->|mounted in| KFPPod
    ModelSecret -.->|used by| LLSServer

    %% Styling
    classDef external fill:#f9f9f9,stroke:#999,stroke-width:2px
    classDef distribution fill:#dbeafe,stroke:#3b82f6,stroke-width:2px
    classDef provider fill:#4a90e2,stroke:#333,stroke-width:2px,color:#fff
    classDef kfp fill:#ffe6cc,stroke:#d79b00,stroke-width:2px
    classDef externalservice fill:#fff2cc,stroke:#d6b656,stroke-width:2px
    classDef secret fill:#fde8e8,stroke:#e53e3e,stroke-width:1px,stroke-dasharray: 5 5

    class Client external
    class LLSServer distribution
    class InlineEval,RemoteEval provider
    class KFPAPI,KFPPod kfp
    class S3,vLLM,K8sAPI externalservice
    class KFPToken,AWSCreds,ModelSecret secret
