# naveenkumarbs/rootpilot architecture

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

- Interactive diagram: https://gitdiagram.com/naveenkumarbs/rootpilot
- Repository: https://github.com/naveenkumarbs/rootpilot

## Overview

RootPilot is an observability and incident-investigation service. Its visible API workflow queries Prometheus for metrics or OpenSearch for service logs; the memory endpoint evaluates a metric against a threshold and returns an anomaly result. A separate RCA agent can ask an LLM to investigate using registered tools, including log search, and produce a report. The supplied excerpts do not show an API route invoking that agent, and remediation is not implemented in the sampled code. Arrows below reflect shown calls or documented HTTP behavior.

Main entry points: [`app/agents/rca_agent.py`](https://github.com/naveenkumarbs/rootpilot/blob/main/app/agents/rca_agent.py) (RCA Agent), [`app/main.py`](https://github.com/naveenkumarbs/rootpilot/blob/main/app/main.py) (FastAPI Routes), [`app/config/settings.py`](https://github.com/naveenkumarbs/rootpilot/blob/main/app/config/settings.py) (Runtime Settings), [`app/llm/gemini_provider.py`](https://github.com/naveenkumarbs/rootpilot/blob/main/app/llm/gemini_provider.py) (Gemini Provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_api["FastAPI Routes<br/>[main.py]"]
  node_settings["Runtime Settings<br/>[settings.py]"]
end

subgraph group_detection["Anomaly Detection"]
  node_detector["Memory Detector"]
end

subgraph group_rca["RCA Agent"]
  node_agent["RCA Agent<br/>[rca_agent.py]"]
  node_tooldefs["RCA Tool Definitions<br/>[definitions.py]"]
  node_dispatcher["Tool Registry<br/>[registry.py]"]
  node_logtool["Log Search Tool"]
end

subgraph group_llm["LLM Layer"]
  node_providerfactory["Provider Factory<br/>[factory.py]"]
  node_provider["Gemini Provider<br/>[gemini_provider.py]"]
  node_providerbase["Provider Interface<br/>[base.py]"]
  node_llmmodels["LLM Data Models<br/>[models.py]"]
end

subgraph group_telemetry["Telemetry Access"]
  node_promclient["Prometheus Client"]
  node_osclient["OpenSearch Client"]
end

node_client(("API Caller"))
node_prometheus["Prometheus"]
node_opensearch[("OpenSearch")]
node_geminiservice["Gemini API"]

node_client -->|"calls HTTP"| node_api
node_api -->|"reads settings"| node_settings
node_api -->|"queries metrics"| node_promclient
node_api -->|"searches logs"| node_osclient
node_api -->|"checks memory"| node_detector
node_promclient -->|"reads URL"| node_settings
node_promclient -->|"queries"| node_prometheus
node_osclient -->|"reads URL"| node_settings
node_osclient -->|"searches logs"| node_opensearch
node_agent -->|"reads limits"| node_settings
node_agent -->|"creates provider"| node_providerfactory
node_agent -->|"offers tools"| node_tooldefs
node_agent -->|"executes calls"| node_dispatcher
node_dispatcher -->|"dispatches to"| node_logtool
node_logtool -->|"searches logs"| node_osclient
node_providerfactory -->|"selects provider"| node_settings
node_providerfactory -->|"creates Gemini"| node_provider
node_provider -->|"implements"| node_providerbase
node_provider -->|"uses messages"| node_llmmodels
node_tooldefs -->|"defines tool type"| node_llmmodels
node_agent -->|"builds messages"| node_llmmodels
node_provider -->|"generates content"| node_geminiservice

click node_api "https://github.com/naveenkumarbs/rootpilot/blob/main/app/main.py"
click node_settings "https://github.com/naveenkumarbs/rootpilot/blob/main/app/config/settings.py"
click node_detector "https://github.com/naveenkumarbs/rootpilot/blob/main/app/detection/anomaly_detector.py"
click node_agent "https://github.com/naveenkumarbs/rootpilot/blob/main/app/agents/rca_agent.py"
click node_tooldefs "https://github.com/naveenkumarbs/rootpilot/blob/main/app/tools/definitions.py"
click node_dispatcher "https://github.com/naveenkumarbs/rootpilot/blob/main/app/tools/registry.py"
click node_logtool "https://github.com/naveenkumarbs/rootpilot/blob/main/app/tools/opensearch_tools.py"
click node_providerfactory "https://github.com/naveenkumarbs/rootpilot/blob/main/app/llm/factory.py"
click node_provider "https://github.com/naveenkumarbs/rootpilot/blob/main/app/llm/gemini_provider.py"
click node_providerbase "https://github.com/naveenkumarbs/rootpilot/blob/main/app/llm/base.py"
click node_llmmodels "https://github.com/naveenkumarbs/rootpilot/blob/main/app/llm/models.py"
click node_promclient "https://github.com/naveenkumarbs/rootpilot/blob/main/app/telemetry/prometheus_client.py"
click node_osclient "https://github.com/naveenkumarbs/rootpilot/blob/main/app/telemetry/opensearch_client.py"

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_api,node_settings toneBlue
class node_detector,node_opensearch toneAmber
class node_agent,node_tooldefs,node_dispatcher,node_logtool,node_client,node_geminiservice toneMint
class node_providerfactory,node_provider,node_providerbase,node_llmmodels toneRose
class node_promclient,node_osclient,node_prometheus toneIndigo
```

## Components

### HTTP API

- [FastAPI Routes](https://github.com/naveenkumarbs/rootpilot/blob/main/app/main.py): `app/main.py`
- [Runtime Settings](https://github.com/naveenkumarbs/rootpilot/blob/main/app/config/settings.py): `app/config/settings.py`

### Anomaly Detection

- [Memory Detector](https://github.com/naveenkumarbs/rootpilot/blob/main/app/detection/anomaly_detector.py): `app/detection/anomaly_detector.py`

### RCA Agent

- [RCA Agent](https://github.com/naveenkumarbs/rootpilot/blob/main/app/agents/rca_agent.py): `app/agents/rca_agent.py`
- [RCA Tool Definitions](https://github.com/naveenkumarbs/rootpilot/blob/main/app/tools/definitions.py): `app/tools/definitions.py`
- [Tool Registry](https://github.com/naveenkumarbs/rootpilot/blob/main/app/tools/registry.py): `app/tools/registry.py`
- [Log Search Tool](https://github.com/naveenkumarbs/rootpilot/blob/main/app/tools/opensearch_tools.py): `app/tools/opensearch_tools.py`

### LLM Layer

- [Provider Factory](https://github.com/naveenkumarbs/rootpilot/blob/main/app/llm/factory.py): `app/llm/factory.py`
- [Gemini Provider](https://github.com/naveenkumarbs/rootpilot/blob/main/app/llm/gemini_provider.py): `app/llm/gemini_provider.py`
- [Provider Interface](https://github.com/naveenkumarbs/rootpilot/blob/main/app/llm/base.py): `app/llm/base.py`
- [LLM Data Models](https://github.com/naveenkumarbs/rootpilot/blob/main/app/llm/models.py): `app/llm/models.py`

### Telemetry Access

- [Prometheus Client](https://github.com/naveenkumarbs/rootpilot/blob/main/app/telemetry/prometheus_client.py): `app/telemetry/prometheus_client.py`
- [OpenSearch Client](https://github.com/naveenkumarbs/rootpilot/blob/main/app/telemetry/opensearch_client.py): `app/telemetry/opensearch_client.py`

### Other components

- **API Caller**
- **Prometheus**
- **OpenSearch**
- **Gemini API**

## Connections

- API Caller → FastAPI Routes: calls HTTP (evidence: `app/main.py`)
- FastAPI Routes → Runtime Settings: reads settings (evidence: `app/main.py`)
- FastAPI Routes → Prometheus Client: queries metrics (evidence: `app/main.py`)
- FastAPI Routes → OpenSearch Client: searches logs (evidence: `app/main.py`)
- FastAPI Routes → Memory Detector: checks memory (evidence: `app/main.py`)
- Prometheus Client → Runtime Settings: reads URL (evidence: `app/telemetry/prometheus_client.py`)
- Prometheus Client → Prometheus: queries (evidence: `app/telemetry/prometheus_client.py`)
- OpenSearch Client → Runtime Settings: reads URL (evidence: `app/telemetry/opensearch_client.py`)
- OpenSearch Client → OpenSearch: searches logs (evidence: `app/telemetry/opensearch_client.py`)
- RCA Agent → Runtime Settings: reads limits (evidence: `app/agents/rca_agent.py`)
- RCA Agent → Provider Factory: creates provider (evidence: `app/agents/rca_agent.py`)
- RCA Agent → RCA Tool Definitions: offers tools (evidence: `app/agents/rca_agent.py`)
- RCA Agent → Tool Registry: executes calls (evidence: `app/agents/rca_agent.py`)
- Tool Registry → Log Search Tool: dispatches to (evidence: `app/tools/registry.py`)
- Log Search Tool → OpenSearch Client: searches logs (evidence: `app/tools/opensearch_tools.py`)
- Provider Factory → Runtime Settings: selects provider (evidence: `app/llm/factory.py`)
- Provider Factory → Gemini Provider: creates Gemini (evidence: `app/llm/factory.py`)
- Gemini Provider → Provider Interface: implements (evidence: `app/llm/gemini_provider.py`)
- Gemini Provider → LLM Data Models: uses messages (evidence: `app/llm/gemini_provider.py`)
- RCA Tool Definitions → LLM Data Models: defines tool type (evidence: `app/tools/definitions.py`)
- RCA Agent → LLM Data Models: builds messages (evidence: `app/agents/rca_agent.py`)
- Gemini Provider → Gemini API: generates content (evidence: `app/llm/gemini_provider.py`)
