# anuragjosyula/autonomous-finops-agent architecture

> Architecture diagram of the GitHub repository anuragjosyula/autonomous-finops-agent, 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/anuragjosyula/autonomous-finops-agent
- Repository: https://github.com/anuragjosyula/autonomous-finops-agent

## Overview

Cloud Cost Anomaly Agent runs on a daily schedule, detects unusual spend, investigates its timing and likely infrastructure cause, asks Bedrock to explain the anomaly and recommend a fix, then sends an alert to Slack. Cost data comes from either Cost Explorer or the CUR-through-Athena provider, selected by configuration. The README documents these integrations and the scheduled workflow; the source excerpts show the agent’s dispatch to its tools and provider implementations, but do not expose every internal call in the CUR query path.

Main entry points: [`Agent/agent.py`](https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/agent.py) (Agent loop), [`Agent/aws_athena_cur.py`](https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/aws_athena_cur.py) (Athena CUR provider), [`Agent/aws_cost_explorer.py`](https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/aws_cost_explorer.py) (Cost Explorer provider), [`Agent/aws_cloudtrail.py`](https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/aws_cloudtrail.py) (CloudTrail lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Agent orchestration"]
  node_agent["Agent loop<br/>[agent.py]"]
end

subgraph group_cost["Cost detection"]
  node_ce["Cost Explorer provider"]
  node_cur["Athena CUR provider<br/>[aws_athena_cur.py]"]
end

subgraph group_investigation["Cause investigation"]
  node_cloudtrail["CloudTrail lookup<br/>[aws_cloudtrail.py]"]
end

subgraph group_delivery["Explanation and alert"]
  node_bedrock["Bedrock model"]
  node_slacknotify["Slack alert builder<br/>[slack_notify.py]"]
end

node_schedule(("Daily schedule"))
node_costexplorer["Cost Explorer API"]
node_curdata[("CUR in S3")]
node_athena["Athena"]
node_glue[("Glue catalog")]
node_cloudtrailservice["AWS CloudTrail"]
node_slack["Slack"]

node_schedule -->|"invokes daily"| node_agent
node_agent -->|"dispatches cost tools"| node_ce
node_agent -->|"dispatches cost tools"| node_cur
node_ce -->|"queries costs"| node_costexplorer
node_cur -->|"queries CUR"| node_athena
node_cur -->|"reads schema"| node_glue
node_curdata -->|"queried through"| node_athena
node_agent -->|"dispatches lookup"| node_cloudtrail
node_cloudtrail -->|"looks up events"| node_cloudtrailservice
node_agent -->|"runs model loop"| node_bedrock
node_agent -->|"dispatches alert"| node_slacknotify
node_slacknotify -->|"posts webhook"| node_slack

click node_agent "https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/agent.py"
click node_ce "https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/aws_cost_explorer.py"
click node_cur "https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/aws_athena_cur.py"
click node_cloudtrail "https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/aws_cloudtrail.py"
click node_slacknotify "https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/slack_notify.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_agent toneBlue
class node_ce,node_cur,node_curdata,node_glue toneAmber
class node_cloudtrail,node_costexplorer toneMint
class node_bedrock,node_slacknotify toneRose
class node_schedule,node_athena,node_cloudtrailservice,node_slack toneIndigo
```

## Components

### Agent orchestration

- [Agent loop](https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/agent.py): `Agent/agent.py`

### Cost detection

- [Cost Explorer provider](https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/aws_cost_explorer.py): `Agent/aws_cost_explorer.py`
- [Athena CUR provider](https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/aws_athena_cur.py): `Agent/aws_athena_cur.py`

### Cause investigation

- [CloudTrail lookup](https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/aws_cloudtrail.py): `Agent/aws_cloudtrail.py`

### Explanation and alert

- **Bedrock model**
- [Slack alert builder](https://github.com/anuragjosyula/autonomous-finops-agent/blob/master/Agent/slack_notify.py): `Agent/slack_notify.py`

### Other components

- **Daily schedule**
- **Cost Explorer API**
- **CUR in S3**
- **Athena**
- **Glue catalog**
- **AWS CloudTrail**
- **Slack**

## Connections

- Daily schedule → Agent loop: invokes daily (evidence: `README.md`)
- Agent loop → Cost Explorer provider: dispatches cost tools (evidence: `Agent/agent.py`)
- Agent loop → Athena CUR provider: dispatches cost tools (evidence: `Agent/agent.py`)
- Cost Explorer provider → Cost Explorer API: queries costs (evidence: `README.md`)
- Athena CUR provider → Athena: queries CUR (evidence: `README.md`)
- Athena CUR provider → Glue catalog: reads schema (evidence: `README.md`)
- CUR in S3 → Athena: queried through (evidence: `README.md`)
- Agent loop → CloudTrail lookup: dispatches lookup (evidence: `Agent/agent.py`)
- CloudTrail lookup → AWS CloudTrail: looks up events (evidence: `Agent/aws_cloudtrail.py`)
- Agent loop → Bedrock model: runs model loop (evidence: `README.md`)
- Agent loop → Slack alert builder: dispatches alert (evidence: `Agent/agent.py`)
- Slack alert builder → Slack: posts webhook (evidence: `Agent/slack_notify.py`)
