# mathankarthik18/imagent architecture

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

- Interactive diagram: https://gitdiagram.com/mathankarthik18/imagent
- Repository: https://github.com/mathankarthik18/imagent

## Overview

imagent is a self-hosted AI-agent observability product. An application instruments agent runs through the Python SDK, which emits OpenTelemetry spans to the server; the server ingests and stores them, and the UI supports trace exploration, live status, blueprints, and comparisons. Experiments replay recorded runs with model changes and judging. Edges are limited to relationships shown in excerpts, the SOURCE INDEX, or README; some UI-to-server wiring is documented only at the product level.

Main entry points: [`server/imagent_server/main.py`](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/main.py) (HTTP API and ingest), [`ui/src/lib/api.ts`](https://github.com/mathankarthik18/imagent/blob/main/ui/src/lib/api.ts) (API client and state), [`sdk/src/imagent/runtime.py`](https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/runtime.py) (Tracing runtime), [`sdk/src/imagent/integrations`](https://github.com/mathankarthik18/imagent/tree/main/sdk/src/imagent/integrations) (Framework integrations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sdk["Python SDK"]
  node_sdk_runtime["Tracing runtime<br/>[runtime.py]"]
  node_sdk_frameworks["Framework integrations"]
  node_sdk_spans["Span conventions<br/>[_spans.py]"]
  node_sdk_blueprint["Blueprint capture<br/>[blueprint.py]"]
  node_sdk_experiments["Experiment replay<br/>[experiments.py]"]
  node_sdk_replay["Replay engine<br/>[replay.py]"]
end

subgraph group_server["Ingest and services"]
  node_server_api["HTTP API and ingest<br/>[main.py]"]
  node_server_queries["Trace queries<br/>[queries.py]"]
  node_server_live["Live run status<br/>[live.py]"]
  node_server_blueprints["Blueprint service<br/>[blueprints.py]"]
  node_server_experiments["Experiment service<br/>[experiments.py]"]
  node_server_judge["AI judging<br/>[judge.py]"]
  node_server_projects["Projects and keys<br/>[projects.py]"]
  node_server_pricing["Cost pricing<br/>[pricing.py]"]
end

subgraph group_storage["Persistence and pricing"]
  node_db[("ClickHouse<br/>[db.py]")]
  node_price_sync["Price catalog sync<br/>[price_sync.py]"]
end

subgraph group_ui["Web application"]
  node_ui_api["API client and state<br/>[api.ts]"]
  node_ui_traces["Trace exploration<br/>[FlowView.tsx]"]
  node_ui_blueprint["Blueprint canvas<br/>[Blueprint.tsx]"]
  node_ui_experiments["Experiment interface<br/>[NewExperiment.tsx]"]
  node_ui_compare["Run comparison<br/>[CompareView.tsx]"]
  node_ui_projects["Project interface<br/>[Projects.tsx]"]
end

node_app(("Agent application"))
node_otel(("OpenTelemetry backend"))

node_app -->|"initializes tracing"| node_sdk_runtime
node_sdk_runtime -->|"installs integrations"| node_sdk_frameworks
node_sdk_frameworks -->|"creates spans"| node_sdk_spans
node_sdk_frameworks -->|"captures structure"| node_sdk_blueprint
node_sdk_frameworks -->|"supports replay"| node_sdk_experiments
node_sdk_runtime -->|"publishes blueprint"| node_sdk_blueprint
node_sdk_runtime -->|"starts experiments"| node_sdk_experiments
node_sdk_experiments -->|"delegates replay"| node_sdk_replay
node_sdk_runtime -->|"exports spans"| node_otel
node_otel -->|"sends OTLP"| node_server_api
node_server_api -->|"stores spans"| node_db
node_server_api -->|"routes queries"| node_server_queries
node_server_api -->|"reads live status"| node_server_live
node_server_api -->|"routes blueprint calls"| node_server_blueprints
node_server_api -->|"routes experiment calls"| node_server_experiments
node_server_api -->|"routes project calls"| node_server_projects
node_server_experiments -->|"reads and writes"| node_db
node_server_experiments -->|"requests judging"| node_server_judge
node_server_pricing -.->|"uses price data"| node_db
node_price_sync -->|"syncs catalog"| node_server_pricing
node_price_sync -->|"stores prices"| node_db
node_ui_api -.->|"calls endpoints"| node_server_api
node_ui_traces -->|"loads trace data"| node_ui_api
node_ui_blueprint -->|"loads blueprint"| node_ui_api
node_ui_experiments -->|"submits experiments"| node_ui_api
node_ui_compare -->|"loads comparisons"| node_ui_api
node_ui_projects -.->|"manages projects"| node_ui_api

click node_sdk_runtime "https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/runtime.py"
click node_sdk_frameworks "https://github.com/mathankarthik18/imagent/tree/main/sdk/src/imagent/integrations"
click node_sdk_spans "https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/integrations/_spans.py"
click node_sdk_blueprint "https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/blueprint.py"
click node_sdk_experiments "https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/experiments.py"
click node_sdk_replay "https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/replay.py"
click node_server_api "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/main.py"
click node_server_queries "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/queries.py"
click node_server_live "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/live.py"
click node_server_blueprints "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/blueprints.py"
click node_server_experiments "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/experiments.py"
click node_server_judge "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/judge.py"
click node_server_projects "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/projects.py"
click node_server_pricing "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/pricing.py"
click node_db "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/db.py"
click node_price_sync "https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/price_sync.py"
click node_ui_api "https://github.com/mathankarthik18/imagent/blob/main/ui/src/lib/api.ts"
click node_ui_traces "https://github.com/mathankarthik18/imagent/blob/main/ui/src/components/FlowView.tsx"
click node_ui_blueprint "https://github.com/mathankarthik18/imagent/blob/main/ui/src/pages/Blueprint.tsx"
click node_ui_experiments "https://github.com/mathankarthik18/imagent/blob/main/ui/src/components/NewExperiment.tsx"
click node_ui_compare "https://github.com/mathankarthik18/imagent/blob/main/ui/src/components/CompareView.tsx"
click node_ui_projects "https://github.com/mathankarthik18/imagent/blob/main/ui/src/pages/Projects.tsx"

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_sdk_runtime,node_sdk_frameworks,node_sdk_spans,node_sdk_blueprint,node_sdk_experiments,node_sdk_replay toneBlue
class node_server_api,node_server_queries,node_server_live,node_server_blueprints,node_server_experiments,node_server_judge,node_server_projects,node_server_pricing toneAmber
class node_db,node_price_sync toneMint
class node_ui_api,node_ui_traces,node_ui_blueprint,node_ui_experiments,node_ui_compare,node_ui_projects toneRose
class node_app,node_otel toneIndigo
```

## Components

### Python SDK

- [Tracing runtime](https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/runtime.py): `sdk/src/imagent/runtime.py`
- [Framework integrations](https://github.com/mathankarthik18/imagent/tree/main/sdk/src/imagent/integrations): `sdk/src/imagent/integrations`
- [Span conventions](https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/integrations/_spans.py): `sdk/src/imagent/integrations/_spans.py`
- [Blueprint capture](https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/blueprint.py): `sdk/src/imagent/blueprint.py`
- [Experiment replay](https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/experiments.py): `sdk/src/imagent/experiments.py`
- [Replay engine](https://github.com/mathankarthik18/imagent/blob/main/sdk/src/imagent/replay.py): `sdk/src/imagent/replay.py`

### Ingest and services

- [HTTP API and ingest](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/main.py): `server/imagent_server/main.py`
- [Trace queries](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/queries.py): `server/imagent_server/queries.py`
- [Live run status](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/live.py): `server/imagent_server/live.py`
- [Blueprint service](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/blueprints.py): `server/imagent_server/blueprints.py`
- [Experiment service](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/experiments.py): `server/imagent_server/experiments.py`
- [AI judging](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/judge.py): `server/imagent_server/judge.py`
- [Projects and keys](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/projects.py): `server/imagent_server/projects.py`
- [Cost pricing](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/pricing.py): `server/imagent_server/pricing.py`

### Persistence and pricing

- [ClickHouse](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/db.py): `server/imagent_server/db.py`
- [Price catalog sync](https://github.com/mathankarthik18/imagent/blob/main/server/imagent_server/price_sync.py): `server/imagent_server/price_sync.py`

### Web application

- [API client and state](https://github.com/mathankarthik18/imagent/blob/main/ui/src/lib/api.ts): `ui/src/lib/api.ts`
- [Trace exploration](https://github.com/mathankarthik18/imagent/blob/main/ui/src/components/FlowView.tsx): `ui/src/components/FlowView.tsx`
- [Blueprint canvas](https://github.com/mathankarthik18/imagent/blob/main/ui/src/pages/Blueprint.tsx): `ui/src/pages/Blueprint.tsx`
- [Experiment interface](https://github.com/mathankarthik18/imagent/blob/main/ui/src/components/NewExperiment.tsx): `ui/src/components/NewExperiment.tsx`
- [Run comparison](https://github.com/mathankarthik18/imagent/blob/main/ui/src/components/CompareView.tsx): `ui/src/components/CompareView.tsx`
- [Project interface](https://github.com/mathankarthik18/imagent/blob/main/ui/src/pages/Projects.tsx): `ui/src/pages/Projects.tsx`

### Other components

- **Agent application**
- **OpenTelemetry backend**

## Connections

- Agent application → Tracing runtime: initializes tracing
- Tracing runtime → Framework integrations: installs integrations (evidence: `sdk/src/imagent/runtime.py`)
- Framework integrations → Span conventions: creates spans (evidence: `sdk/src/imagent/integrations/_spans.py`)
- Framework integrations → Blueprint capture: captures structure (evidence: `sdk/src/imagent/integrations/crewai.py`)
- Framework integrations → Experiment replay: supports replay (evidence: `sdk/src/imagent/integrations/llamaindex.py`)
- Tracing runtime → Blueprint capture: publishes blueprint (evidence: `sdk/src/imagent/runtime.py`)
- Tracing runtime → Experiment replay: starts experiments (evidence: `sdk/src/imagent/runtime.py`)
- Experiment replay → Replay engine: delegates replay (evidence: `sdk/src/imagent/experiments.py`)
- Tracing runtime → OpenTelemetry backend: exports spans
- OpenTelemetry backend → HTTP API and ingest: sends OTLP
- HTTP API and ingest → ClickHouse: stores spans (evidence: `server/imagent_server/main.py`)
- HTTP API and ingest → Trace queries: routes queries (evidence: `server/imagent_server/main.py`)
- HTTP API and ingest → Live run status: reads live status (evidence: `server/imagent_server/main.py`)
- HTTP API and ingest → Blueprint service: routes blueprint calls (evidence: `server/imagent_server/main.py`)
- HTTP API and ingest → Experiment service: routes experiment calls (evidence: `server/imagent_server/main.py`)
- HTTP API and ingest → Projects and keys: routes project calls (evidence: `server/imagent_server/main.py`)
- Experiment service → ClickHouse: reads and writes (evidence: `server/imagent_server/experiments.py`)
- Experiment service → AI judging: requests judging (evidence: `server/imagent_server/main.py`)
- Cost pricing → ClickHouse: uses price data
- Price catalog sync → Cost pricing: syncs catalog (evidence: `server/imagent_server/price_sync.py`)
- Price catalog sync → ClickHouse: stores prices (evidence: `server/imagent_server/price_sync.py`)
- API client and state → HTTP API and ingest: calls endpoints
- Trace exploration → API client and state: loads trace data (evidence: `ui/src/components/FlowView.tsx`)
- Blueprint canvas → API client and state: loads blueprint (evidence: `ui/src/pages/Blueprint.tsx`)
- Experiment interface → API client and state: submits experiments (evidence: `ui/src/components/NewExperiment.tsx`)
- Run comparison → API client and state: loads comparisons (evidence: `ui/src/components/CompareView.tsx`)
- Project interface → API client and state: manages projects
