# sidd07-hub/ai-incident-response architecture

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

- Interactive diagram: https://gitdiagram.com/sidd07-hub/ai-incident-response
- Repository: https://github.com/sidd07-hub/ai-incident-response

## Overview

The repository’s product is an AWS incident-response agent: an alarm event enters through SNS and Lambda, the agent gathers evidence, requests AI analysis, and notifies responders; the README also documents S3 report storage. Source-index references support the handler-to-agent and agent-to-tool calls. Tool implementations beyond the indexed excerpts, including report persistence and the additional remediation/RCA/risk tools, were not inspected, so their runtime links are omitted. The bundled AWS and Slack SDKs are represented as supporting internal layers, not as the product workflow.

Main entry points: [`src/agents/incident_agent.py`](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/agents/incident_agent.py) (Incident Agent), [`src/handler.py`](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/handler.py) (Lambda Handler), [`src/tools/cloudwatch_reader.py`](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/cloudwatch_reader.py) (CloudWatch Reader), [`src/tools/groq_analyzer.py`](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/groq_analyzer.py) (AI Analyzer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Event Ingestion"]
  node_lambda["Lambda Handler<br/>[handler.py]"]
  node_agent["Incident Agent<br/>[incident_agent.py]"]
end

subgraph group_response["Incident Response"]
  node_log_reader["CloudWatch Reader"]
  node_analyzer["AI Analyzer<br/>[groq_analyzer.py]"]
  node_notifier["Slack Notifier<br/>[slack_notifier.py]"]
  node_risk["Risk Assessor<br/>[risk_assessor.py]"]
  node_rca["RCA Generator<br/>[rca_generator.py]"]
  node_remediation["Auto Remediation"]
end

subgraph group_integrations["External Services"]
  node_cloudwatch_alarm(("CloudWatch Alarm"))
  node_sns["SNS Topic"]
  node_openrouter["OpenRouter AI"]
  node_slack["Slack"]
  node_s3[("S3 Reports")]
end

subgraph group_sdk["SDK Layer"]
  node_boto3["Boto3 Session<br/>[session.py]"]
  node_botocore_client["AWS Client Runtime<br/>[client.py]"]
  node_botocore_core["AWS Core Modules"]
  node_slack_webhook["Slack Webhook Client<br/>[client.py]"]
  node_slack_async["Slack Async Web Client<br/>[async_client.py]"]
  node_slack_retry["Slack Retry Request<br/>[request.py]"]
  node_slack_proxy["Slack Proxy Loader"]
end

node_cloudwatch_alarm -->|"publishes event"| node_sns
node_sns -->|"invokes"| node_lambda
node_lambda -->|"calls"| node_agent
node_agent -->|"calls"| node_log_reader
node_agent -->|"calls"| node_analyzer
node_agent -->|"calls"| node_notifier
node_log_reader -->|"reads logs"| node_cloudwatch_alarm
node_analyzer -->|"requests analysis"| node_openrouter
node_notifier -->|"sends alert"| node_slack
node_agent -->|"stores report"| node_s3
node_agent -->|"uses"| node_boto3
node_boto3 -->|"creates clients"| node_botocore_client
node_slack_webhook -.->|"sends webhook"| node_slack
node_risk -.->|"feeds assessment"| node_agent
node_rca -.->|"feeds RCA"| node_agent
node_remediation -.->|"offers remediation"| node_agent

click node_lambda "https://github.com/sidd07-hub/ai-incident-response/blob/main/src/handler.py"
click node_agent "https://github.com/sidd07-hub/ai-incident-response/blob/main/src/agents/incident_agent.py"
click node_log_reader "https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/cloudwatch_reader.py"
click node_analyzer "https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/groq_analyzer.py"
click node_notifier "https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/slack_notifier.py"
click node_risk "https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/risk_assessor.py"
click node_rca "https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/rca_generator.py"
click node_remediation "https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/auto_remediation.py"
click node_boto3 "https://github.com/sidd07-hub/ai-incident-response/blob/main/package/boto3/session.py"
click node_botocore_client "https://github.com/sidd07-hub/ai-incident-response/blob/main/package/botocore/client.py"
click node_botocore_core "https://github.com/sidd07-hub/ai-incident-response/tree/main/package/botocore"
click node_slack_webhook "https://github.com/sidd07-hub/ai-incident-response/blob/main/package/slack_sdk/webhook/client.py"
click node_slack_async "https://github.com/sidd07-hub/ai-incident-response/blob/main/package/slack_sdk/web/async_client.py"
click node_slack_retry "https://github.com/sidd07-hub/ai-incident-response/blob/main/package/slack_sdk/http_retry/request.py"
click node_slack_proxy "https://github.com/sidd07-hub/ai-incident-response/blob/main/package/slack_sdk/proxy_env_variable_loader.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_lambda,node_agent toneBlue
class node_log_reader,node_analyzer,node_notifier,node_risk,node_rca,node_remediation toneAmber
class node_cloudwatch_alarm,node_sns,node_openrouter,node_slack,node_s3 toneMint
class node_boto3,node_botocore_client,node_botocore_core,node_slack_webhook,node_slack_async,node_slack_retry,node_slack_proxy toneRose
```

## Components

### Event Ingestion

- [Lambda Handler](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/handler.py): `src/handler.py`
- [Incident Agent](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/agents/incident_agent.py): `src/agents/incident_agent.py`

### Incident Response

- [CloudWatch Reader](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/cloudwatch_reader.py): `src/tools/cloudwatch_reader.py`
- [AI Analyzer](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/groq_analyzer.py): `src/tools/groq_analyzer.py`
- [Slack Notifier](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/slack_notifier.py): `src/tools/slack_notifier.py`
- [Risk Assessor](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/risk_assessor.py): `src/tools/risk_assessor.py`
- [RCA Generator](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/rca_generator.py): `src/tools/rca_generator.py`
- [Auto Remediation](https://github.com/sidd07-hub/ai-incident-response/blob/main/src/tools/auto_remediation.py): `src/tools/auto_remediation.py`

### External Services

- **CloudWatch Alarm**
- **SNS Topic**
- **OpenRouter AI**
- **Slack**
- **S3 Reports**

### SDK Layer

- [Boto3 Session](https://github.com/sidd07-hub/ai-incident-response/blob/main/package/boto3/session.py): `package/boto3/session.py`
- [AWS Client Runtime](https://github.com/sidd07-hub/ai-incident-response/blob/main/package/botocore/client.py): `package/botocore/client.py`
- [AWS Core Modules](https://github.com/sidd07-hub/ai-incident-response/tree/main/package/botocore): `package/botocore`
- [Slack Webhook Client](https://github.com/sidd07-hub/ai-incident-response/blob/main/package/slack_sdk/webhook/client.py): `package/slack_sdk/webhook/client.py`
- [Slack Async Web Client](https://github.com/sidd07-hub/ai-incident-response/blob/main/package/slack_sdk/web/async_client.py): `package/slack_sdk/web/async_client.py`
- [Slack Retry Request](https://github.com/sidd07-hub/ai-incident-response/blob/main/package/slack_sdk/http_retry/request.py): `package/slack_sdk/http_retry/request.py`
- [Slack Proxy Loader](https://github.com/sidd07-hub/ai-incident-response/blob/main/package/slack_sdk/proxy_env_variable_loader.py): `package/slack_sdk/proxy_env_variable_loader.py`

## Connections

- CloudWatch Alarm → SNS Topic: publishes event (evidence: `README.md`)
- SNS Topic → Lambda Handler: invokes (evidence: `README.md`)
- Lambda Handler → Incident Agent: calls (evidence: `src/handler.py`)
- Incident Agent → CloudWatch Reader: calls (evidence: `src/agents/incident_agent.py`)
- Incident Agent → AI Analyzer: calls (evidence: `src/agents/incident_agent.py`)
- Incident Agent → Slack Notifier: calls (evidence: `src/agents/incident_agent.py`)
- CloudWatch Reader → CloudWatch Alarm: reads logs (evidence: `README.md`)
- AI Analyzer → OpenRouter AI: requests analysis (evidence: `README.md`)
- Slack Notifier → Slack: sends alert (evidence: `README.md`)
- Incident Agent → S3 Reports: stores report (evidence: `README.md`)
- Incident Agent → Boto3 Session: uses (evidence: `src/agents/incident_agent.py`)
- Boto3 Session → AWS Client Runtime: creates clients (evidence: `package/boto3/session.py`)
- Slack Webhook Client → Slack: sends webhook
- Risk Assessor → Incident Agent: feeds assessment
- RCA Generator → Incident Agent: feeds RCA
- Auto Remediation → Incident Agent: offers remediation
