# jaswanthyamana/agent-hub architecture

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

- Interactive diagram: https://gitdiagram.com/jaswanthyamana/agent-hub
- Repository: https://github.com/jaswanthyamana/agent-hub

## Overview

Agent Hub captures agent execution traces, analyzes their reliability and security, and presents the results in a React observability workspace. The main flow is agent or SDK/OTLP spans through normalization and persistence, then trace analysis, evaluation, graphing, and replay; red-team campaigns exercise agents and compare attacked runs with baselines. The README also describes live trace streaming and Pass@k benchmarking. Evidence is strongest for ingestion, red-team orchestration, replay, persistence, and app routing; several API and UI interactions are represented at subsystem level because their implementation excerpts were not provided.

Main entry points: [`backend/core/models.py`](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/core/models.py) (Trace models), [`backend/redteam/engine.py`](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/redteam/engine.py) (Red-team campaigns), [`backend/main.py`](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/main.py) (FastAPI routes), [`backend/api/ingest.py`](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/api/ingest.py) (Span ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and runtime"]
  node_agent["Instrumented agents"]
  node_sdk["Tracing SDK<br/>[sdk.py]"]
  node_integrations["Agent adapters"]
  node_ingest["Span ingestion<br/>[ingest.py]"]
  node_normalizer["Span normalizer<br/>[normalizer.py]"]
  node_models["Trace models<br/>[models.py]"]
end

subgraph group_analysis["Trace analysis"]
  node_anomaly["Anomaly detection<br/>[detector.py]"]
  node_metrics["Reliability metrics<br/>[metrics.py]"]
  node_judge["Judge evaluation<br/>[judge.py]"]
  node_llmjudge["LLM judge<br/>[llm_judge.py]"]
  node_graph["Execution DAG<br/>[builder.py]"]
  node_replay["Replay and diff<br/>[engine.py]"]
end

subgraph group_security["Adversarial testing"]
  node_redteam["Red-team campaigns<br/>[engine.py]"]
  node_attacks["Attack catalogue<br/>[catalogue.py]"]
end

subgraph group_platform["API and persistence"]
  node_domains["Domain policies<br/>[definitions.py]"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_repository["Trace repository<br/>[pg_repository.py]"]
  node_database[("PostgreSQL store<br/>[pg_database.py]")]
end

subgraph group_workspace["Observability UI"]
  node_frontend["React workspace<br/>[App.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_views["Observability views"]
  node_ui_graph["Trace visualizations<br/>[ExecutionGraph.jsx]"]
  node_analytics["Analytics view<br/>[Analytics.jsx]"]
  node_redteam_ui["Red-team view<br/>[RedTeam.jsx]"]
  node_replay_ui["Replay view<br/>[Replay.jsx]"]
end

node_external(("OTLP agents"))

node_external -->|"sends OTLP"| node_ingest
node_sdk -->|"posts spans"| node_ingest
node_integrations -->|"instruments"| node_sdk
node_ingest -->|"normalizes"| node_normalizer
node_ingest -->|"saves spans"| node_repository
node_normalizer -->|"creates spans"| node_models
node_agent -.->|"emits traces"| node_models
node_api -->|"registers route"| node_ingest
node_api -->|"initializes storage"| node_repository
node_repository -->|"uses pool"| node_database
node_redteam -->|"runs baseline"| node_agent
node_redteam -->|"computes scores"| node_metrics
node_redteam -->|"checks attacks"| node_anomaly
node_redteam -->|"selects payload"| node_attacks
node_redteam -.->|"persists results"| node_repository
node_api -->|"registers route"| node_redteam
node_api -->|"loads policies"| node_domains
node_anomaly -->|"analyzes traces"| node_models
node_metrics -->|"scores traces"| node_models
node_llmjudge -->|"assesses traces"| node_models
node_llmjudge -.->|"uses fallback"| node_judge
node_graph -->|"builds DAG"| node_models
node_replay -->|"captures frames"| node_models
node_repository -->|"loads traces"| node_models
node_frontend -->|"routes to"| node_views
node_frontend -.->|"checks health"| node_api_client
node_analytics -->|"requests analytics"| node_api_client
node_api_client -.->|"calls REST"| node_api
node_ui_graph -.->|"visualizes DAG"| node_graph
node_redteam_ui -.->|"submits campaigns"| node_api_client
node_replay_ui -.->|"requests replay"| node_api_client

click node_agent "https://github.com/jaswanthyamana/agent-hub/tree/main/backend/agents"
click node_sdk "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/sdk.py"
click node_integrations "https://github.com/jaswanthyamana/agent-hub/tree/main/backend/integrations"
click node_ingest "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/api/ingest.py"
click node_normalizer "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/ingestion/normalizer.py"
click node_models "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/core/models.py"
click node_anomaly "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/anomaly/detector.py"
click node_metrics "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/evaluation/metrics.py"
click node_judge "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/evaluation/judge.py"
click node_llmjudge "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/evaluation/llm_judge.py"
click node_graph "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/graph/builder.py"
click node_replay "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/replay/engine.py"
click node_domains "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/domains/definitions.py"
click node_redteam "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/redteam/engine.py"
click node_attacks "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/redteam/catalogue.py"
click node_api "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/main.py"
click node_repository "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/storage/pg_repository.py"
click node_database "https://github.com/jaswanthyamana/agent-hub/blob/main/backend/storage/pg_database.py"
click node_frontend "https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/App.jsx"
click node_api_client "https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/services/api.js"
click node_views "https://github.com/jaswanthyamana/agent-hub/tree/main/frontend-react/src/views"
click node_ui_graph "https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/components/graph/ExecutionGraph.jsx"
click node_analytics "https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/views/Analytics.jsx"
click node_redteam_ui "https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/views/RedTeam.jsx"
click node_replay_ui "https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/views/Replay.jsx"

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_agent,node_sdk,node_integrations,node_ingest,node_normalizer,node_models toneBlue
class node_anomaly,node_metrics,node_judge,node_llmjudge,node_graph,node_replay toneAmber
class node_redteam,node_attacks toneMint
class node_domains,node_api,node_repository,node_database toneRose
class node_frontend,node_api_client,node_views,node_ui_graph,node_analytics,node_redteam_ui,node_replay_ui,node_external toneIndigo
```

## Components

### Capture and runtime

- [Instrumented agents](https://github.com/jaswanthyamana/agent-hub/tree/main/backend/agents): `backend/agents`
- [Tracing SDK](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/sdk.py): `backend/sdk.py`
- [Agent adapters](https://github.com/jaswanthyamana/agent-hub/tree/main/backend/integrations): `backend/integrations`
- [Span ingestion](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/api/ingest.py): `backend/api/ingest.py`
- [Span normalizer](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/ingestion/normalizer.py): `backend/ingestion/normalizer.py`
- [Trace models](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/core/models.py): `backend/core/models.py`

### Trace analysis

- [Anomaly detection](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/anomaly/detector.py): `backend/anomaly/detector.py`
- [Reliability metrics](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/evaluation/metrics.py): `backend/evaluation/metrics.py`
- [Judge evaluation](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/evaluation/judge.py): `backend/evaluation/judge.py`
- [LLM judge](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/evaluation/llm_judge.py): `backend/evaluation/llm_judge.py`
- [Execution DAG](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/graph/builder.py): `backend/graph/builder.py`
- [Replay and diff](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/replay/engine.py): `backend/replay/engine.py`

### Adversarial testing

- [Red-team campaigns](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/redteam/engine.py): `backend/redteam/engine.py`
- [Attack catalogue](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/redteam/catalogue.py): `backend/redteam/catalogue.py`

### API and persistence

- [Domain policies](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/domains/definitions.py): `backend/domains/definitions.py`
- [FastAPI routes](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/main.py): `backend/main.py`
- [Trace repository](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/storage/pg_repository.py): `backend/storage/pg_repository.py`
- [PostgreSQL store](https://github.com/jaswanthyamana/agent-hub/blob/main/backend/storage/pg_database.py): `backend/storage/pg_database.py`

### Observability UI

- [React workspace](https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/App.jsx): `frontend-react/src/App.jsx`
- [API client](https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/services/api.js): `frontend-react/src/services/api.js`
- [Observability views](https://github.com/jaswanthyamana/agent-hub/tree/main/frontend-react/src/views): `frontend-react/src/views`
- [Trace visualizations](https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/components/graph/ExecutionGraph.jsx): `frontend-react/src/components/graph/ExecutionGraph.jsx`
- [Analytics view](https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/views/Analytics.jsx): `frontend-react/src/views/Analytics.jsx`
- [Red-team view](https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/views/RedTeam.jsx): `frontend-react/src/views/RedTeam.jsx`
- [Replay view](https://github.com/jaswanthyamana/agent-hub/blob/main/frontend-react/src/views/Replay.jsx): `frontend-react/src/views/Replay.jsx`

### Other components

- **OTLP agents**

## Connections

- OTLP agents → Span ingestion: sends OTLP (evidence: `backend/api/ingest.py`)
- Tracing SDK → Span ingestion: posts spans (evidence: `backend/api/ingest.py`)
- Agent adapters → Tracing SDK: instruments (evidence: `backend/integrations/langchain_adapter.py`)
- Span ingestion → Span normalizer: normalizes (evidence: `backend/api/ingest.py`)
- Span ingestion → Trace repository: saves spans (evidence: `backend/api/ingest.py`)
- Span normalizer → Trace models: creates spans (evidence: `backend/ingestion/normalizer.py`)
- Instrumented agents → Trace models: emits traces (evidence: `backend/agents/demo_agent.py`)
- FastAPI routes → Span ingestion: registers route (evidence: `backend/main.py`)
- FastAPI routes → Trace repository: initializes storage (evidence: `backend/main.py`)
- Trace repository → PostgreSQL store: uses pool (evidence: `backend/storage/pg_repository.py`)
- Red-team campaigns → Instrumented agents: runs baseline (evidence: `backend/redteam/engine.py`)
- Red-team campaigns → Reliability metrics: computes scores (evidence: `backend/redteam/engine.py`)
- Red-team campaigns → Anomaly detection: checks attacks (evidence: `backend/redteam/engine.py`)
- Red-team campaigns → Attack catalogue: selects payload (evidence: `backend/redteam/engine.py`)
- Red-team campaigns → Trace repository: persists results
- FastAPI routes → Red-team campaigns: registers route (evidence: `backend/main.py`)
- FastAPI routes → Domain policies: loads policies (evidence: `backend/main.py`)
- Anomaly detection → Trace models: analyzes traces (evidence: `backend/anomaly/detector.py`)
- Reliability metrics → Trace models: scores traces (evidence: `backend/evaluation/metrics.py`)
- LLM judge → Trace models: assesses traces (evidence: `backend/evaluation/llm_judge.py`)
- LLM judge → Judge evaluation: uses fallback
- Execution DAG → Trace models: builds DAG (evidence: `backend/graph/builder.py`)
- Replay and diff → Trace models: captures frames (evidence: `backend/replay/engine.py`)
- Trace repository → Trace models: loads traces (evidence: `backend/storage/pg_repository.py`)
- React workspace → Observability views: routes to (evidence: `frontend-react/src/App.jsx`)
- React workspace → API client: checks health
- Analytics view → API client: requests analytics (evidence: `frontend-react/src/views/Analytics.jsx`)
- API client → FastAPI routes: calls REST
- Trace visualizations → Execution DAG: visualizes DAG
- Red-team view → API client: submits campaigns
- Replay view → API client: requests replay
