# elastic/opentelemetry-demo architecture

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

- Interactive diagram: https://gitdiagram.com/elastic/opentelemetry-demo
- Repository: https://github.com/elastic/opentelemetry-demo

## Overview

This repository is an OpenTelemetry-instrumented online-store demo, adapted to demonstrate Elastic Observability. A shopper browses products and ads, manages a cart, and places an order; checkout coordinates cart, payment, shipping, and order confirmation, with optional Kafka post-processing. Other services provide currency conversion and recommendations, while feature flags can influence service behavior. The README describes EDOT and upstream Collector modes forwarding telemetry to Elastic. Some frontend and service wiring is documented by the product structure rather than sampled source, so uncertain links are omitted.

Main entry points: [`src/frontend/pages/api`](https://github.com/elastic/opentelemetry-demo/tree/main/src/frontend/pages/api) (Store APIs), [`src/checkout/main.go`](https://github.com/elastic/opentelemetry-demo/blob/main/src/checkout/main.go) (Checkout), [`src/cart/src/Program.cs`](https://github.com/elastic/opentelemetry-demo/blob/main/src/cart/src/Program.cs) (Cart Service), [`src/product-catalog/main.go`](https://github.com/elastic/opentelemetry-demo/blob/main/src/product-catalog/main.go) (Product Catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_web["Web Store<br/>[index.tsx]"]
  node_frontend_api["Store APIs"]
end

subgraph group_commerce["Commerce Services"]
  node_catalog["Product Catalog<br/>[main.go]"]
  node_catalog_db[("Catalog Database")]
  node_ads["Ad Service<br/>[AdService.java]"]
  node_cart["Cart Service<br/>[Program.cs]"]
  node_cart_store[("Cart Store<br/>[ValkeyCartStore.cs]")]
  node_currency["Currency Service<br/>[server.cpp]"]
  node_recommendations["Recommendations"]
end

subgraph group_operations["Order Operations"]
  node_checkout["Checkout<br/>[main.go]"]
  node_payment["Payment Service<br/>[index.js]"]
  node_shipping["Shipping Service<br/>[main.rs]"]
  node_quote["Quote Service<br/>[routes.php]"]
  node_email["Email Service<br/>[email_server.rb]"]
  node_kafka["Order Kafka<br/>[producer.go]"]
  node_accounting["Accounting Consumer<br/>[Program.cs]"]
  node_fraud["Fraud Detection<br/>[main.kt]"]
end

subgraph group_observability["Observability"]
  node_flag_ui["Feature Flag UI"]
  node_flag_storage[("Flag Storage<br/>[storage.ex]")]
  node_collector["OTel Collector"]
  node_elastic["Elastic Observability"]
end

node_shopper(("Shopper"))

node_shopper -->|"browses"| node_web
node_web -->|"requests"| node_frontend_api
node_frontend_api -->|"queries"| node_catalog
node_frontend_api -->|"requests ads"| node_ads
node_frontend_api -->|"manages cart"| node_cart
node_frontend_api -->|"converts prices"| node_currency
node_frontend_api -->|"requests suggestions"| node_recommendations
node_frontend_api -->|"places order"| node_checkout
node_catalog -->|"queries"| node_catalog_db
node_cart -->|"reads and writes"| node_cart_store
node_checkout -->|"gets and empties cart"| node_cart
node_checkout -->|"charges payment"| node_payment
node_checkout -->|"ships order"| node_shipping
node_checkout -->|"sends confirmation"| node_email
node_checkout -->|"publishes order"| node_kafka
node_kafka -.->|"delivers orders"| node_accounting
node_kafka -.->|"delivers orders"| node_fraud
node_shipping -.->|"requests quote"| node_quote
node_flag_ui -->|"reads and writes"| node_flag_storage
node_catalog -.->|"exports telemetry"| node_collector
node_cart -.->|"exports telemetry"| node_collector
node_checkout -.->|"exports telemetry"| node_collector
node_collector -->|"forwards telemetry"| node_elastic

click node_web "https://github.com/elastic/opentelemetry-demo/blob/main/src/frontend/pages/index.tsx"
click node_frontend_api "https://github.com/elastic/opentelemetry-demo/tree/main/src/frontend/pages/api"
click node_catalog "https://github.com/elastic/opentelemetry-demo/blob/main/src/product-catalog/main.go"
click node_ads "https://github.com/elastic/opentelemetry-demo/blob/main/src/ad/src/main/java/oteldemo/AdService.java"
click node_cart "https://github.com/elastic/opentelemetry-demo/blob/main/src/cart/src/Program.cs"
click node_cart_store "https://github.com/elastic/opentelemetry-demo/blob/main/src/cart/src/cartstore/ValkeyCartStore.cs"
click node_currency "https://github.com/elastic/opentelemetry-demo/blob/main/src/currency/src/server.cpp"
click node_recommendations "https://github.com/elastic/opentelemetry-demo/blob/main/src/recommendation/recommendation_server.py"
click node_checkout "https://github.com/elastic/opentelemetry-demo/blob/main/src/checkout/main.go"
click node_payment "https://github.com/elastic/opentelemetry-demo/blob/main/src/payment/index.js"
click node_shipping "https://github.com/elastic/opentelemetry-demo/blob/main/src/shipping/src/main.rs"
click node_quote "https://github.com/elastic/opentelemetry-demo/blob/main/src/quote/app/routes.php"
click node_email "https://github.com/elastic/opentelemetry-demo/blob/main/src/email/email_server.rb"
click node_kafka "https://github.com/elastic/opentelemetry-demo/blob/main/src/checkout/kafka/producer.go"
click node_accounting "https://github.com/elastic/opentelemetry-demo/blob/main/src/accounting/Program.cs"
click node_fraud "https://github.com/elastic/opentelemetry-demo/blob/main/src/fraud-detection/src/main/kotlin/frauddetection/main.kt"
click node_flag_ui "https://github.com/elastic/opentelemetry-demo/blob/main/src/flagd-ui/lib/flagd_ui_web/controllers/feature_controller.ex"
click node_flag_storage "https://github.com/elastic/opentelemetry-demo/blob/main/src/flagd-ui/lib/flagd_ui/storage.ex"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_frontend_api toneBlue
class node_catalog,node_catalog_db,node_ads,node_cart,node_cart_store,node_currency,node_recommendations toneAmber
class node_checkout,node_payment,node_shipping,node_quote,node_email,node_kafka,node_accounting,node_fraud toneMint
class node_flag_ui,node_flag_storage,node_collector,node_elastic toneRose
class node_shopper toneIndigo
```

## Components

### Storefront

- [Web Store](https://github.com/elastic/opentelemetry-demo/blob/main/src/frontend/pages/index.tsx): `src/frontend/pages/index.tsx`
- [Store APIs](https://github.com/elastic/opentelemetry-demo/tree/main/src/frontend/pages/api): `src/frontend/pages/api`

### Commerce Services

- [Product Catalog](https://github.com/elastic/opentelemetry-demo/blob/main/src/product-catalog/main.go): `src/product-catalog/main.go`
- **Catalog Database**
- [Ad Service](https://github.com/elastic/opentelemetry-demo/blob/main/src/ad/src/main/java/oteldemo/AdService.java): `src/ad/src/main/java/oteldemo/AdService.java`
- [Cart Service](https://github.com/elastic/opentelemetry-demo/blob/main/src/cart/src/Program.cs): `src/cart/src/Program.cs`
- [Cart Store](https://github.com/elastic/opentelemetry-demo/blob/main/src/cart/src/cartstore/ValkeyCartStore.cs): `src/cart/src/cartstore/ValkeyCartStore.cs`
- [Currency Service](https://github.com/elastic/opentelemetry-demo/blob/main/src/currency/src/server.cpp): `src/currency/src/server.cpp`
- [Recommendations](https://github.com/elastic/opentelemetry-demo/blob/main/src/recommendation/recommendation_server.py): `src/recommendation/recommendation_server.py`

### Order Operations

- [Checkout](https://github.com/elastic/opentelemetry-demo/blob/main/src/checkout/main.go): `src/checkout/main.go`
- [Payment Service](https://github.com/elastic/opentelemetry-demo/blob/main/src/payment/index.js): `src/payment/index.js`
- [Shipping Service](https://github.com/elastic/opentelemetry-demo/blob/main/src/shipping/src/main.rs): `src/shipping/src/main.rs`
- [Quote Service](https://github.com/elastic/opentelemetry-demo/blob/main/src/quote/app/routes.php): `src/quote/app/routes.php`
- [Email Service](https://github.com/elastic/opentelemetry-demo/blob/main/src/email/email_server.rb): `src/email/email_server.rb`
- [Order Kafka](https://github.com/elastic/opentelemetry-demo/blob/main/src/checkout/kafka/producer.go): `src/checkout/kafka/producer.go`
- [Accounting Consumer](https://github.com/elastic/opentelemetry-demo/blob/main/src/accounting/Program.cs): `src/accounting/Program.cs`
- [Fraud Detection](https://github.com/elastic/opentelemetry-demo/blob/main/src/fraud-detection/src/main/kotlin/frauddetection/main.kt): `src/fraud-detection/src/main/kotlin/frauddetection/main.kt`

### Observability

- [Feature Flag UI](https://github.com/elastic/opentelemetry-demo/blob/main/src/flagd-ui/lib/flagd_ui_web/controllers/feature_controller.ex): `src/flagd-ui/lib/flagd_ui_web/controllers/feature_controller.ex`
- [Flag Storage](https://github.com/elastic/opentelemetry-demo/blob/main/src/flagd-ui/lib/flagd_ui/storage.ex): `src/flagd-ui/lib/flagd_ui/storage.ex`
- **OTel Collector**
- **Elastic Observability**

### Other components

- **Shopper**

## Connections

- Shopper → Web Store: browses
- Web Store → Store APIs: requests
- Store APIs → Product Catalog: queries
- Store APIs → Ad Service: requests ads
- Store APIs → Cart Service: manages cart
- Store APIs → Currency Service: converts prices
- Store APIs → Recommendations: requests suggestions
- Store APIs → Checkout: places order
- Product Catalog → Catalog Database: queries
- Cart Service → Cart Store: reads and writes
- Checkout → Cart Service: gets and empties cart
- Checkout → Payment Service: charges payment
- Checkout → Shipping Service: ships order
- Checkout → Email Service: sends confirmation
- Checkout → Order Kafka: publishes order
- Order Kafka → Accounting Consumer: delivers orders
- Order Kafka → Fraud Detection: delivers orders
- Shipping Service → Quote Service: requests quote
- Feature Flag UI → Flag Storage: reads and writes
- Product Catalog → OTel Collector: exports telemetry
- Cart Service → OTel Collector: exports telemetry
- Checkout → OTel Collector: exports telemetry
- OTel Collector → Elastic Observability: forwards telemetry
