# observe-resolve/openaiobservability architecture

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

- Interactive diagram: https://gitdiagram.com/observe-resolve/openaiobservability
- Repository: https://github.com/observe-resolve/openaiobservability

## Overview

##### Main Components
- Application Backend – Represented by the contents in the “src” directory (with app.py and Dockerfile). This is the containerized application.
- Static Content – Located in “src/public” (HTML, CSS, images) which is the frontend although simple in nature.
- Containerization – The Dockerfile in “src” and deployment manifests (in the “k8s” directory) highlight that container images are deployed to a Kubernetes cluster.
- Observability Instrumentation:
- OpenTelemetry – The “opentelemetry” folder holds manifests and configuration (stateful sets, daemon sets, RBAC, etc.) that deploy the OpenTelemetry collector for gathering traces, logs, and metrics.
- Dynatrace Integration – Files in the “dynatrace” directory (dynakube.yaml) and instructions in the README detail how the Dynatrace Operator is used to monitor the Kubernetes environment.
- Infrastructure & Deployment – The “k8s” folder contains YAML files (e.g., deployment and loadtest) that define the Kubernetes deployment details, and “deployment.sh” is used as a script to deploy all components, tying in GKE provisioning and configuration.

##### Relationships & Interactions
- The containerized application (built from the “src” folder) runs inside a GKE cluster.
- Instrumentation via OpenTelemetry is integrated directly with the application containers and transmits telemetry data (traces, metrics, logs) to configured collectors.
- The Dynatrace Operator (defined by manifests in “dynatrace” and “k8s”) processes and forwards observability data from the OpenTelemetry collector (whose deployment is configured in the “opentelemetry” directory) to the Dynatrace tenant.
- External integration exists with the Azure OpenAI service (as shown in the README) where the application or a service acts as a client to the Azure OpenAI endpoint, with tokens used for authentication.
- Deployment orchestration is handled via “deployment.sh”, which automates the configuration of not only the Kubernetes cluster but also the secrets for tokens (Dynatrace API tokens, Azure OpenAI keys), linking everything together.

##### Architectural Patterns and Technologies
- Containerization and Microservices – The usage of Docker and Kubernetes for application deployment.
- Infrastructure-as-Code – Kubernetes manifests and deployment scripts drive reproducible deployments.
- API-Driven External Service Integration – Communication with Azure OpenAI’s services using endpoint and API keys.

##### Final Recommendations
- Within the GKE cluster, separate the application pod(s) from the monitoring pods.
- Logical boundaries between the application’s layers (backend, static frontend assets) and the telemetry/observability layers.
- Component is clearly marked with its corresponding technology (e.g., Docker for containerization, Kubernetes manifests for deployment, OpenTelemetry for telemetry, and Dynatrace for monitoring).
- Use consistent visual notation to improve readability and allow stakeholders to quickly understand how data flows from the application to the external monitoring systems.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Deployment("Infrastructure & Deployment"):::infra
    Containerization("Containerization"):::container
    Azure_OpenAI("Azure OpenAI Service"):::external
    Dynatrace_Tenant("Dynatrace Tenant"):::external
    Dashboard("Dashboard"):::dashboard

    Deployment --> Containerization
    Containerization --> App_Backend
    Containerization --> Static_Content

    subgraph "GKE Cluster"
        subgraph "Application Tier"
            App_Backend("Application Backend"):::app
            Static_Content("Static Content"):::app
        end
        subgraph "Observability Tier"
            OpenTelemetry("OpenTelemetry Collector"):::otel
            Dynatrace_Integration("Dynatrace Operator"):::dynatrace
        end
    end

    App_Backend -->|"telemetry"| OpenTelemetry
    OpenTelemetry -->|"observability"| Dynatrace_Integration
    Dynatrace_Integration -->|"data"| Dynatrace_Tenant
    Dynatrace_Tenant -->|"metrics"| Dashboard
    App_Backend -->|"API_request"| Azure_OpenAI

    click App_Backend "https://github.com/observe-resolve/openaiobservability/blob/main/src/app.py"
    click Static_Content "https://github.com/observe-resolve/openaiobservability/tree/main/src/public"
    click Containerization "https://github.com/observe-resolve/openaiobservability/tree/main/src/Dockerfile"
    click OpenTelemetry "https://github.com/observe-resolve/openaiobservability/tree/main/opentelemetry"
    click Dynatrace_Integration "https://github.com/observe-resolve/openaiobservability/blob/main/dynatrace/dynakube.yaml"
    click Deployment "https://github.com/observe-resolve/openaiobservability/blob/main/deployment.sh"
    click Dashboard "https://github.com/observe-resolve/openaiobservability/tree/main/dashboard"

    classDef infra fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef container fill:#B3E5FC,stroke:#333,stroke-width:2px;
    classDef app fill:#C8E6C9,stroke:#333,stroke-width:2px;
    classDef otel fill:#D1C4E9,stroke:#333,stroke-width:2px;
    classDef dynatrace fill:#FFCDD2,stroke:#333,stroke-width:2px;
    classDef external fill:#FFE0B2,stroke:#333,stroke-width:2px;
    classDef dashboard fill:#B2EBF2,stroke:#333,stroke-width:2px;
```
