# ziftech/dotnetapm architecture

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

- Interactive diagram: https://gitdiagram.com/ziftech/dotnetapm
- Repository: https://github.com/ziftech/dotnetapm

## Overview

Contoso Shipments is a synthetic .NET APM lab: checkout and worker flows exercise shipment pricing, persistence, tracking requests, and observability instrumentation. The repository also includes a presentation app for explaining the lab. Relationships are limited to sampled calls, SOURCE INDEX references, and README statements; unsampled wiring is omitted.

Main entry points: [`src/Contoso.Shipments.Business/ShipmentService.cs`](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Shipments.Business/ShipmentService.cs) (Shipment Service), [`src/Contoso.Observability/ElasticApmTraceBackend.cs`](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ElasticApmTraceBackend.cs) (Elastic Backend), [`src/ShipmentsWorker/Program.cs`](https://github.com/ziftech/dotnetapm/blob/main/src/ShipmentsWorker/Program.cs) (Timer Worker), [`src/Contoso.Observability/TraceAspect.cs`](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/TraceAspect.cs) (Trace Aspect)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shipments["Shipment Workflows"]
  node_checkout["Checkout Handler"]
  node_worker["Timer Worker<br/>[Program.cs]"]
  node_shipment_service["Shipment Service<br/>[ShipmentService.cs]"]
  node_pricing["Pricing Calculator"]
  node_call_chain["Deep Call Chain<br/>[CallChain.cs]"]
  node_repository["Shipment Repository"]
  node_tracking_client["Tracking Client<br/>[TrackingClient.cs]"]
  node_tracking_api["Tracking API"]
end

subgraph group_observability["APM Instrumentation"]
  node_apm_business["Business Labels<br/>[ApmBusiness.cs]"]
  node_http_module["HTTP Context Module"]
  node_trace_aspect["Trace Aspect<br/>[TraceAspect.cs]"]
  node_trace_scope["Trace Scope<br/>[TraceScope.cs]"]
  node_exception_capture["Exception Capture"]
  node_trace_settings["Trace Settings<br/>[TraceSettings.cs]"]
  node_apm_entry["APM Entry Point<br/>[ApmEntryPoint.cs]"]
  node_elastic_backend["Elastic Backend"]
  node_trace_backend["Trace Backend Contract<br/>[ITraceBackend.cs]"]
end

subgraph group_presentation["Presentation Deck"]
  node_deck_app["Deck Application<br/>[main.ts]"]
  node_deck_scenes["Deck Scenes<br/>[scenes.ts]"]
  node_deck_visuals["Visual Renderer<br/>[visuals.ts]"]
  node_visual_primitives["SVG Primitives<br/>[primitives.ts]"]
  node_deck_types["Deck Types<br/>[types.ts]"]
  node_deck_scenario["Scene Scenario<br/>[scenario.ts]"]
end

node_user(("Checkout User"))
node_database[("Shipments SQL")]
node_elastic_apm[("Elastic APM")]

node_user -->|"submits checkout"| node_checkout
node_checkout -->|"creates quote"| node_shipment_service
node_checkout -->|"requests status"| node_tracking_client
node_shipment_service -->|"calculates price"| node_pricing
node_shipment_service -->|"runs chain"| node_call_chain
node_shipment_service -->|"persists and reads"| node_repository
node_repository -->|"queries and writes"| node_database
node_tracking_client -->|"calls over HTTP"| node_tracking_api
node_tracking_api -->|"looks up status"| node_shipment_service
node_worker -->|"creates quote"| node_shipment_service
node_worker -->|"wraps timer tick"| node_apm_entry
node_worker -->|"selects backend"| node_elastic_backend
node_http_module -->|"sets request labels"| node_apm_business
node_tracking_api -->|"sets tracking labels"| node_apm_business
node_trace_aspect -->|"checks configuration"| node_trace_settings
node_trace_aspect -->|"completes async spans"| node_trace_scope
node_trace_aspect -->|"marks exceptions"| node_exception_capture
node_elastic_backend -->|"implements contract"| node_trace_backend
node_elastic_backend -->|"reads settings"| node_trace_settings
node_elastic_backend -.->|"exports traces"| node_elastic_apm
node_deck_app -->|"loads scenes"| node_deck_scenes
node_deck_app -->|"renders visuals"| node_deck_visuals
node_deck_app -->|"uses scene types"| node_deck_types
node_deck_scenes -->|"uses scenario"| node_deck_scenario
node_deck_visuals -->|"builds with primitives"| node_visual_primitives
node_deck_visuals -->|"uses visual types"| node_deck_types
node_visual_primitives -->|"uses visual options"| node_deck_types

click node_checkout "https://github.com/ziftech/dotnetapm/blob/main/src/ShipmentsWeb/Controllers/CheckoutController.cs"
click node_worker "https://github.com/ziftech/dotnetapm/blob/main/src/ShipmentsWorker/Program.cs"
click node_shipment_service "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Shipments.Business/ShipmentService.cs"
click node_pricing "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Shipments.Business/PricingCalculator.cs"
click node_call_chain "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Shipments.Business/CallChain.cs"
click node_repository "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Shipments.Business/ShipmentRepository.cs"
click node_tracking_client "https://github.com/ziftech/dotnetapm/blob/main/src/ShipmentsWeb/Services/TrackingClient.cs"
click node_tracking_api "https://github.com/ziftech/dotnetapm/blob/main/src/TrackingApi/Controllers/TrackingController.cs"
click node_apm_business "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ApmBusiness.cs"
click node_http_module "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability.Web/ApmContextHttpModule.cs"
click node_trace_aspect "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/TraceAspect.cs"
click node_trace_scope "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/TraceScope.cs"
click node_exception_capture "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ExceptionCapture.cs"
click node_trace_settings "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/TraceSettings.cs"
click node_apm_entry "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ApmEntryPoint.cs"
click node_elastic_backend "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ElasticApmTraceBackend.cs"
click node_trace_backend "https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ITraceBackend.cs"
click node_deck_app "https://github.com/ziftech/dotnetapm/blob/main/preso/src/main.ts"
click node_deck_scenes "https://github.com/ziftech/dotnetapm/blob/main/preso/src/scenes.ts"
click node_deck_visuals "https://github.com/ziftech/dotnetapm/blob/main/preso/src/visuals.ts"
click node_visual_primitives "https://github.com/ziftech/dotnetapm/blob/main/preso/src/visuals/primitives.ts"
click node_deck_types "https://github.com/ziftech/dotnetapm/blob/main/preso/src/types.ts"
click node_deck_scenario "https://github.com/ziftech/dotnetapm/blob/main/preso/src/scenario.ts"

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_checkout,node_worker,node_shipment_service,node_pricing,node_call_chain,node_repository,node_tracking_client,node_tracking_api,node_user toneBlue
class node_apm_business,node_http_module,node_trace_aspect,node_trace_scope,node_exception_capture,node_trace_settings,node_apm_entry,node_elastic_backend,node_trace_backend,node_database,node_elastic_apm toneAmber
class node_deck_app,node_deck_scenes,node_deck_visuals,node_visual_primitives,node_deck_types,node_deck_scenario toneMint
```

## Components

### Shipment Workflows

- [Checkout Handler](https://github.com/ziftech/dotnetapm/blob/main/src/ShipmentsWeb/Controllers/CheckoutController.cs): `src/ShipmentsWeb/Controllers/CheckoutController.cs`
- [Timer Worker](https://github.com/ziftech/dotnetapm/blob/main/src/ShipmentsWorker/Program.cs): `src/ShipmentsWorker/Program.cs`
- [Shipment Service](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Shipments.Business/ShipmentService.cs): `src/Contoso.Shipments.Business/ShipmentService.cs`
- [Pricing Calculator](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Shipments.Business/PricingCalculator.cs): `src/Contoso.Shipments.Business/PricingCalculator.cs`
- [Deep Call Chain](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Shipments.Business/CallChain.cs): `src/Contoso.Shipments.Business/CallChain.cs`
- [Shipment Repository](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Shipments.Business/ShipmentRepository.cs): `src/Contoso.Shipments.Business/ShipmentRepository.cs`
- [Tracking Client](https://github.com/ziftech/dotnetapm/blob/main/src/ShipmentsWeb/Services/TrackingClient.cs): `src/ShipmentsWeb/Services/TrackingClient.cs`
- [Tracking API](https://github.com/ziftech/dotnetapm/blob/main/src/TrackingApi/Controllers/TrackingController.cs): `src/TrackingApi/Controllers/TrackingController.cs`

### APM Instrumentation

- [Business Labels](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ApmBusiness.cs): `src/Contoso.Observability/ApmBusiness.cs`
- [HTTP Context Module](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability.Web/ApmContextHttpModule.cs): `src/Contoso.Observability.Web/ApmContextHttpModule.cs`
- [Trace Aspect](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/TraceAspect.cs): `src/Contoso.Observability/TraceAspect.cs`
- [Trace Scope](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/TraceScope.cs): `src/Contoso.Observability/TraceScope.cs`
- [Exception Capture](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ExceptionCapture.cs): `src/Contoso.Observability/ExceptionCapture.cs`
- [Trace Settings](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/TraceSettings.cs): `src/Contoso.Observability/TraceSettings.cs`
- [APM Entry Point](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ApmEntryPoint.cs): `src/Contoso.Observability/ApmEntryPoint.cs`
- [Elastic Backend](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ElasticApmTraceBackend.cs): `src/Contoso.Observability/ElasticApmTraceBackend.cs`
- [Trace Backend Contract](https://github.com/ziftech/dotnetapm/blob/main/src/Contoso.Observability/ITraceBackend.cs): `src/Contoso.Observability/ITraceBackend.cs`

### Presentation Deck

- [Deck Application](https://github.com/ziftech/dotnetapm/blob/main/preso/src/main.ts): `preso/src/main.ts`
- [Deck Scenes](https://github.com/ziftech/dotnetapm/blob/main/preso/src/scenes.ts): `preso/src/scenes.ts`
- [Visual Renderer](https://github.com/ziftech/dotnetapm/blob/main/preso/src/visuals.ts): `preso/src/visuals.ts`
- [SVG Primitives](https://github.com/ziftech/dotnetapm/blob/main/preso/src/visuals/primitives.ts): `preso/src/visuals/primitives.ts`
- [Deck Types](https://github.com/ziftech/dotnetapm/blob/main/preso/src/types.ts): `preso/src/types.ts`
- [Scene Scenario](https://github.com/ziftech/dotnetapm/blob/main/preso/src/scenario.ts): `preso/src/scenario.ts`

### Other components

- **Checkout User**
- **Shipments SQL**
- **Elastic APM**

## Connections

- Checkout User → Checkout Handler: submits checkout (evidence: `src/ShipmentsWeb/Controllers/CheckoutController.cs`)
- Checkout Handler → Shipment Service: creates quote (evidence: `src/ShipmentsWeb/Controllers/CheckoutController.cs`)
- Checkout Handler → Tracking Client: requests status (evidence: `src/ShipmentsWeb/Controllers/CheckoutController.cs`)
- Shipment Service → Pricing Calculator: calculates price (evidence: `src/Contoso.Shipments.Business/ShipmentService.cs`)
- Shipment Service → Deep Call Chain: runs chain (evidence: `src/Contoso.Shipments.Business/ShipmentService.cs`)
- Shipment Service → Shipment Repository: persists and reads (evidence: `src/Contoso.Shipments.Business/ShipmentService.cs`)
- Shipment Repository → Shipments SQL: queries and writes (evidence: `src/Contoso.Shipments.Business/ShipmentRepository.cs`)
- Tracking Client → Tracking API: calls over HTTP (evidence: `README.md`)
- Tracking API → Shipment Service: looks up status (evidence: `src/TrackingApi/Controllers/TrackingController.cs`)
- Timer Worker → Shipment Service: creates quote (evidence: `src/ShipmentsWorker/Program.cs`)
- Timer Worker → APM Entry Point: wraps timer tick (evidence: `src/ShipmentsWorker/Program.cs`)
- Timer Worker → Elastic Backend: selects backend (evidence: `src/ShipmentsWorker/Program.cs`)
- HTTP Context Module → Business Labels: sets request labels (evidence: `src/Contoso.Observability.Web/ApmContextHttpModule.cs`)
- Tracking API → Business Labels: sets tracking labels (evidence: `src/TrackingApi/Controllers/TrackingController.cs`)
- Trace Aspect → Trace Settings: checks configuration (evidence: `src/Contoso.Observability/TraceAspect.cs`)
- Trace Aspect → Trace Scope: completes async spans (evidence: `src/Contoso.Observability/TraceAspect.cs`)
- Trace Aspect → Exception Capture: marks exceptions (evidence: `src/Contoso.Observability/TraceAspect.cs`)
- Elastic Backend → Trace Backend Contract: implements contract (evidence: `src/Contoso.Observability/ElasticApmTraceBackend.cs`)
- Elastic Backend → Trace Settings: reads settings (evidence: `src/Contoso.Observability/ElasticApmTraceBackend.cs`)
- Elastic Backend → Elastic APM: exports traces
- Deck Application → Deck Scenes: loads scenes (evidence: `preso/src/main.ts`)
- Deck Application → Visual Renderer: renders visuals (evidence: `preso/src/main.ts`)
- Deck Application → Deck Types: uses scene types (evidence: `preso/src/main.ts`)
- Deck Scenes → Scene Scenario: uses scenario (evidence: `preso/src/scenes.ts`)
- Visual Renderer → SVG Primitives: builds with primitives (evidence: `preso/src/visuals.ts`)
- Visual Renderer → Deck Types: uses visual types (evidence: `preso/src/visuals.ts`)
- SVG Primitives → Deck Types: uses visual options (evidence: `preso/src/visuals/primitives.ts`)
