# kyunghoon02/agent-rca architecture

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

- Interactive diagram: https://gitdiagram.com/kyunghoon02/agent-rca
- Repository: https://github.com/kyunghoon02/agent-rca

## Overview

Agent RCA accepts alert-driven incidents, collects bounded read-only telemetry, normalizes it into traceable evidence, localizes a frozen investigation context, and analyzes it with KRCA/StateGraph drilldown and a bounded agent. An Evidence Gate accepts a report (including abstention) or records rejection. The Viewer presents incidents, evidence, context, lifecycle, and reports. Several links below are explicit in the README or source index; unsampled integrations are not expanded into guessed call chains.

Main entry points: [`tools/run_incident_worker.py`](https://github.com/kyunghoon02/agent-rca/blob/main/tools/run_incident_worker.py) (Collection worker), [`frontend/viewer/src/components/incident-detail/incident-detail-view.tsx`](https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/components/incident-detail/incident-detail-view.tsx) (Viewer UI), [`src/incident_platform/repository.py`](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/repository.py) (Incident repository), [`src/incident_platform/postgresql.py`](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/postgresql.py) (PostgreSQL storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Incident intake"]
  node_receiver["Alert receiver<br/>[http_receiver.py]"]
  node_incident["Incident lifecycle<br/>[incidents.py]"]
  node_collection_worker["Collection worker"]
end

subgraph group_investigation["Evidence investigation"]
  node_provider_prom["Prometheus provider<br/>[prometheus.py]"]
  node_provider_kube["Kubernetes provider<br/>[kubernetes.py]"]
  node_provider_hubble["Hubble provider<br/>[hubble.py]"]
  node_provider_http["HTTP transport<br/>[http.py]"]
  node_evidence["Evidence normalization<br/>[evidence.py]"]
  node_localization["Context localization<br/>[localization.py]"]
  node_local_collection["Localized collection"]
  node_krca_runtime["KRCA metrics<br/>[krca_runtime.py]"]
  node_krca_pipeline["KRCA drilldown<br/>[krca_pipeline.py]"]
  node_projectors["Domain projectors"]
  node_stategraph["Temporal StateGraph<br/>[stategraph.py]"]
end

subgraph group_analysis["RCA analysis"]
  node_agent_worker["Agent worker"]
  node_agent_rca["Agent RCA and Gate<br/>[agent_rca.py]"]
  node_knowledge["Knowledge retrieval<br/>[knowledge.py]"]
end

subgraph group_storage["Persistence"]
  node_neo4j[("Graph persistence")]
  node_repository["Incident repository<br/>[repository.py]"]
  node_postgres[("PostgreSQL storage<br/>[postgresql.py]")]
end

subgraph group_viewer["Incident viewer"]
  node_viewer["Viewer UI"]
  node_viewer_api["Viewer API<br/>[route.ts]"]
  node_viewer_adapter["HTTP adapter<br/>[http-adapter.ts]"]
  node_incident_list["Incident list"]
  node_viewer_context["Context presentation<br/>[context-tab.tsx]"]
  node_viewer_evidence["Evidence presentation<br/>[evidence-tab.tsx]"]
end

node_alertmanager(("Alertmanager"))

node_alertmanager -->|"sends webhook"| node_receiver
node_receiver -.->|"normalizes alert"| node_incident
node_receiver -->|"stores durable work"| node_postgres
node_collection_worker -->|"claims work"| node_postgres
node_collection_worker -->|"collects metrics"| node_provider_prom
node_collection_worker -->|"collects cluster data"| node_provider_kube
node_collection_worker -->|"collects flows"| node_provider_hubble
node_provider_prom -->|"queries through"| node_provider_http
node_provider_kube -->|"queries through"| node_provider_http
node_collection_worker -->|"builds evidence"| node_evidence
node_evidence -->|"supplies evidence"| node_localization
node_collection_worker -->|"runs scoped collection"| node_local_collection
node_collection_worker -->|"runs metric features"| node_krca_runtime
node_krca_runtime -->|"queries metrics"| node_provider_prom
node_krca_pipeline -->|"localizes scope"| node_localization
node_krca_pipeline -.->|"drills down"| node_stategraph
node_collection_worker -->|"projects observations"| node_projectors
node_projectors -->|"produces graph records"| node_stategraph
node_stategraph -->|"persists graph"| node_neo4j
node_localization -->|"freezes context"| node_repository
node_agent_worker -->|"claims analysis work"| node_postgres
node_agent_worker -->|"runs analysis"| node_agent_rca
node_agent_rca -->|"retrieves references"| node_knowledge
node_agent_rca -->|"reads context and saves result"| node_repository
node_repository -->|"persists artifacts"| node_postgres
node_viewer -.->|"loads resources"| node_viewer_adapter
node_viewer_adapter -.->|"requests data"| node_viewer_api
node_viewer_api -.->|"reads incidents"| node_repository
node_incident_list -->|"lists incidents"| node_viewer
node_viewer -->|"renders context"| node_viewer_context
node_viewer -->|"renders evidence"| node_viewer_evidence

click node_receiver "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/http_receiver.py"
click node_incident "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/incidents.py"
click node_collection_worker "https://github.com/kyunghoon02/agent-rca/blob/main/tools/run_incident_worker.py"
click node_provider_prom "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/providers/prometheus.py"
click node_provider_kube "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/providers/kubernetes.py"
click node_provider_hubble "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/providers/hubble.py"
click node_provider_http "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/providers/http.py"
click node_evidence "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/evidence.py"
click node_localization "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/localization.py"
click node_local_collection "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/localization_collection.py"
click node_krca_runtime "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/krca_runtime.py"
click node_krca_pipeline "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/krca_pipeline.py"
click node_projectors "https://github.com/kyunghoon02/agent-rca/tree/main/src/incident_platform/projectors"
click node_stategraph "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/stategraph.py"
click node_neo4j "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/neo4j_stategraph.py"
click node_agent_worker "https://github.com/kyunghoon02/agent-rca/blob/main/tools/run_agent_worker.py"
click node_agent_rca "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/agent_rca.py"
click node_knowledge "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/knowledge.py"
click node_repository "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/repository.py"
click node_postgres "https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/postgresql.py"
click node_viewer "https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/components/incident-detail/incident-detail-view.tsx"
click node_viewer_api "https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/app/api/viewer/%5B...path%5D/route.ts"
click node_viewer_adapter "https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/lib/adapter/http-adapter.ts"
click node_incident_list "https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/components/incidents/incident-list-view.tsx"
click node_viewer_context "https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/components/incident-detail/tabs/context-tab.tsx"
click node_viewer_evidence "https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/components/incident-detail/tabs/evidence-tab.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_receiver,node_incident,node_collection_worker toneBlue
class node_provider_prom,node_provider_kube,node_provider_hubble,node_provider_http,node_evidence,node_localization,node_local_collection,node_krca_runtime,node_krca_pipeline,node_projectors,node_stategraph toneAmber
class node_agent_worker,node_agent_rca,node_knowledge toneMint
class node_neo4j,node_repository,node_postgres toneRose
class node_viewer,node_viewer_api,node_viewer_adapter,node_incident_list,node_viewer_context,node_viewer_evidence,node_alertmanager toneIndigo
```

## Components

### Incident intake

- [Alert receiver](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/http_receiver.py): `src/incident_platform/http_receiver.py`
- [Incident lifecycle](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/incidents.py): `src/incident_platform/incidents.py`
- [Collection worker](https://github.com/kyunghoon02/agent-rca/blob/main/tools/run_incident_worker.py): `tools/run_incident_worker.py`

### Evidence investigation

- [Prometheus provider](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/providers/prometheus.py): `src/incident_platform/providers/prometheus.py`
- [Kubernetes provider](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/providers/kubernetes.py): `src/incident_platform/providers/kubernetes.py`
- [Hubble provider](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/providers/hubble.py): `src/incident_platform/providers/hubble.py`
- [HTTP transport](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/providers/http.py): `src/incident_platform/providers/http.py`
- [Evidence normalization](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/evidence.py): `src/incident_platform/evidence.py`
- [Context localization](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/localization.py): `src/incident_platform/localization.py`
- [Localized collection](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/localization_collection.py): `src/incident_platform/localization_collection.py`
- [KRCA metrics](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/krca_runtime.py): `src/incident_platform/krca_runtime.py`
- [KRCA drilldown](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/krca_pipeline.py): `src/incident_platform/krca_pipeline.py`
- [Domain projectors](https://github.com/kyunghoon02/agent-rca/tree/main/src/incident_platform/projectors): `src/incident_platform/projectors`
- [Temporal StateGraph](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/stategraph.py): `src/incident_platform/stategraph.py`

### RCA analysis

- [Agent worker](https://github.com/kyunghoon02/agent-rca/blob/main/tools/run_agent_worker.py): `tools/run_agent_worker.py`
- [Agent RCA and Gate](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/agent_rca.py): `src/incident_platform/agent_rca.py`
- [Knowledge retrieval](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/knowledge.py): `src/incident_platform/knowledge.py`

### Persistence

- [Graph persistence](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/neo4j_stategraph.py): `src/incident_platform/neo4j_stategraph.py`
- [Incident repository](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/repository.py): `src/incident_platform/repository.py`
- [PostgreSQL storage](https://github.com/kyunghoon02/agent-rca/blob/main/src/incident_platform/postgresql.py): `src/incident_platform/postgresql.py`

### Incident viewer

- [Viewer UI](https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/components/incident-detail/incident-detail-view.tsx): `frontend/viewer/src/components/incident-detail/incident-detail-view.tsx`
- [Viewer API](https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/app/api/viewer/%5B...path%5D/route.ts): `frontend/viewer/src/app/api/viewer/[...path]/route.ts`
- [HTTP adapter](https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/lib/adapter/http-adapter.ts): `frontend/viewer/src/lib/adapter/http-adapter.ts`
- [Incident list](https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/components/incidents/incident-list-view.tsx): `frontend/viewer/src/components/incidents/incident-list-view.tsx`
- [Context presentation](https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/components/incident-detail/tabs/context-tab.tsx): `frontend/viewer/src/components/incident-detail/tabs/context-tab.tsx`
- [Evidence presentation](https://github.com/kyunghoon02/agent-rca/blob/main/frontend/viewer/src/components/incident-detail/tabs/evidence-tab.tsx): `frontend/viewer/src/components/incident-detail/tabs/evidence-tab.tsx`

### Other components

- **Alertmanager**

## Connections

- Alertmanager → Alert receiver: sends webhook
- Alert receiver → Incident lifecycle: normalizes alert
- Alert receiver → PostgreSQL storage: stores durable work
- Collection worker → PostgreSQL storage: claims work (evidence: `tools/run_incident_worker.py`)
- Collection worker → Prometheus provider: collects metrics (evidence: `tools/run_incident_worker.py`)
- Collection worker → Kubernetes provider: collects cluster data (evidence: `tools/run_incident_worker.py`)
- Collection worker → Hubble provider: collects flows (evidence: `tools/run_incident_worker.py`)
- Prometheus provider → HTTP transport: queries through (evidence: `src/incident_platform/providers/prometheus.py`)
- Kubernetes provider → HTTP transport: queries through (evidence: `src/incident_platform/providers/kubernetes.py`)
- Collection worker → Evidence normalization: builds evidence (evidence: `tools/run_incident_worker.py`)
- Evidence normalization → Context localization: supplies evidence (evidence: `src/incident_platform/localization.py`)
- Collection worker → Localized collection: runs scoped collection (evidence: `tools/run_incident_worker.py`)
- Collection worker → KRCA metrics: runs metric features (evidence: `tools/run_incident_worker.py`)
- KRCA metrics → Prometheus provider: queries metrics (evidence: `src/incident_platform/krca_runtime.py`)
- KRCA drilldown → Context localization: localizes scope (evidence: `src/incident_platform/krca_pipeline.py`)
- KRCA drilldown → Temporal StateGraph: drills down (evidence: `src/incident_platform/krca_pipeline.py`)
- Collection worker → Domain projectors: projects observations (evidence: `tools/run_incident_worker.py`)
- Domain projectors → Temporal StateGraph: produces graph records (evidence: `src/incident_platform/projectors/hubble.py`)
- Temporal StateGraph → Graph persistence: persists graph
- Context localization → Incident repository: freezes context (evidence: `src/incident_platform/localization.py`)
- Agent worker → PostgreSQL storage: claims analysis work (evidence: `tools/run_agent_worker.py`)
- Agent worker → Agent RCA and Gate: runs analysis (evidence: `tools/run_agent_worker.py`)
- Agent RCA and Gate → Knowledge retrieval: retrieves references (evidence: `tools/run_agent_worker.py`)
- Agent RCA and Gate → Incident repository: reads context and saves result
- Incident repository → PostgreSQL storage: persists artifacts (evidence: `src/incident_platform/postgresql.py`)
- Viewer UI → HTTP adapter: loads resources
- HTTP adapter → Viewer API: requests data
- Viewer API → Incident repository: reads incidents
- Incident list → Viewer UI: lists incidents (evidence: `frontend/viewer/src/components/incident-detail/incident-detail-view.tsx`)
- Viewer UI → Context presentation: renders context (evidence: `frontend/viewer/src/components/incident-detail/incident-detail-view.tsx`)
- Viewer UI → Evidence presentation: renders evidence (evidence: `frontend/viewer/src/components/incident-detail/incident-detail-view.tsx`)
