# ayushraghuwanshi1704/aws-finops-cost-optimizer architecture

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

- Interactive diagram: https://gitdiagram.com/ayushraghuwanshi1704/aws-finops-cost-optimizer
- Repository: https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer

## Overview

AWS FinOps Cost Optimizer provides read-only cost and resource analysis, a local dashboard for reviewing findings, and guarded scheduled remediation deployed with Terraform. The main workflow is an engineer running an analysis or opening the dashboard, gathering AWS or demo data, calculating costs/findings, and exporting or reviewing results. Separate automation handles tagging, scheduling, and snapshot retention. Edges follow README statements and shown imports/calls; some deployment wiring is documented rather than visible in sampled Terraform source.

Main entry points: [`web/data.py`](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/data.py) (Payload provider), [`web/app.py`](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/app.py) (Dashboard server), [`scripts/unused_resources.py`](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/unused_resources.py) (Waste detection), [`scripts/rightsizing_recommendations.py`](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/rightsizing_recommendations.py) (Rightsizing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Read-only analysis"]
  node_cost_analysis["Cost reports<br/>[cost_analysis.py]"]
  node_unused["Waste detection"]
  node_rightsizing["Rightsizing"]
  node_commitments["Commitment analysis"]
end

subgraph group_dashboard["Local dashboard"]
  node_http["Dashboard server<br/>[app.py]"]
  node_provider["Payload provider<br/>[data.py]"]
  node_demo["Demo data<br/>[demo_data.py]"]
  node_live["Live cost queries<br/>[live.py]"]
  node_ebs["EBS status<br/>[ebs.py]"]
  node_exports["Report downloads<br/>[reports.py]"]
  node_browser["Dashboard UI<br/>[app.js]"]
end

subgraph group_automation["Scheduled automation"]
  node_tagger["Auto-tagger<br/>[main.py]"]
  node_scheduler["Instance scheduler<br/>[main.py]"]
  node_cleanup["Snapshot cleanup<br/>[main.py]"]
end

subgraph group_deployment["AWS deployment"]
  node_terraform["Infrastructure deployment<br/>[main.tf]"]
  node_lambda_module["Lambda resources<br/>[main.tf]"]
  node_dashboard_config["Cost dashboard config"]
end

subgraph group_services["External services"]
  node_cost_explorer{{"Cost Explorer"}}
  node_cloudwatch{{"CloudWatch"}}
  node_resource_apis{{"EC2 and RDS APIs"}}
  node_eventbridge{{"EventBridge"}}
  node_sns{{"SNS notifications"}}
  node_budgets_anomalies{{"Budgets and anomalies"}}
end

node_engineer(("Engineer"))

node_engineer -->|"runs analysis"| node_cost_analysis
node_engineer -->|"runs analysis"| node_unused
node_engineer -->|"runs analysis"| node_rightsizing
node_engineer -->|"runs analysis"| node_commitments
node_cost_analysis -->|"queries costs"| node_cost_explorer
node_commitments -->|"queries coverage"| node_cost_explorer
node_unused -->|"reads metrics"| node_cloudwatch
node_unused -->|"describes resources"| node_resource_apis
node_rightsizing -->|"reads utilization"| node_cloudwatch
node_rightsizing -->|"describes instances"| node_resource_apis
node_engineer -->|"opens dashboard"| node_http
node_http -->|"builds payload"| node_provider
node_provider -->|"loads sample data"| node_demo
node_provider -->|"queries live data"| node_live
node_provider -->|"loads EBS status"| node_ebs
node_provider -->|"uses analysis"| node_cost_analysis
node_provider -->|"uses analysis"| node_unused
node_provider -->|"uses analysis"| node_rightsizing
node_provider -->|"uses analysis"| node_commitments
node_http -->|"formats downloads"| node_exports
node_http -->|"serves EBS route"| node_ebs
node_live -->|"queries costs"| node_cost_explorer
node_ebs -->|"describes volumes"| node_resource_apis
node_browser -.->|"requests dashboard"| node_http
node_engineer -->|"deploys toolkit"| node_terraform
node_terraform -.->|"configures functions"| node_lambda_module
node_terraform -.->|"deploys monitoring"| node_dashboard_config
node_eventbridge -->|"schedules hourly"| node_tagger
node_eventbridge -->|"schedules stop start"| node_scheduler
node_eventbridge -->|"schedules daily"| node_cleanup
node_tagger -->|"updates tags"| node_resource_apis
node_scheduler -->|"starts and stops"| node_resource_apis
node_cleanup -->|"cleans snapshots"| node_resource_apis
node_tagger -->|"notifies"| node_sns
node_scheduler -->|"notifies"| node_sns
node_cleanup -->|"notifies"| node_sns
node_budgets_anomalies -->|"sends alerts"| node_sns

click node_cost_analysis "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/cost_analysis.py"
click node_unused "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/unused_resources.py"
click node_rightsizing "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/rightsizing_recommendations.py"
click node_commitments "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/commitment_coverage.py"
click node_http "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/app.py"
click node_provider "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/data.py"
click node_demo "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/demo_data.py"
click node_live "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/live.py"
click node_ebs "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/ebs.py"
click node_exports "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/reports.py"
click node_browser "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/static/app.js"
click node_tagger "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/lambda/auto_tagger/main.py"
click node_scheduler "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/lambda/scheduler/main.py"
click node_cleanup "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/lambda/snapshot_cleanup/main.py"
click node_terraform "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/terraform/main.tf"
click node_lambda_module "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/terraform/modules/lambda/main.tf"
click node_dashboard_config "https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/dashboards/cost_overview_dashboard.json"

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_cost_analysis,node_unused,node_rightsizing,node_commitments toneBlue
class node_http,node_provider,node_demo,node_live,node_ebs,node_exports,node_browser toneAmber
class node_tagger,node_scheduler,node_cleanup toneMint
class node_terraform,node_lambda_module,node_dashboard_config toneRose
class node_cost_explorer,node_cloudwatch,node_resource_apis,node_eventbridge,node_sns,node_budgets_anomalies,node_engineer toneIndigo
```

## Components

### Read-only analysis

- [Cost reports](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/cost_analysis.py): `scripts/cost_analysis.py`
- [Waste detection](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/unused_resources.py): `scripts/unused_resources.py`
- [Rightsizing](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/rightsizing_recommendations.py): `scripts/rightsizing_recommendations.py`
- [Commitment analysis](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/scripts/commitment_coverage.py): `scripts/commitment_coverage.py`

### Local dashboard

- [Dashboard server](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/app.py): `web/app.py`
- [Payload provider](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/data.py): `web/data.py`
- [Demo data](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/demo_data.py): `web/demo_data.py`
- [Live cost queries](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/live.py): `web/live.py`
- [EBS status](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/ebs.py): `web/ebs.py`
- [Report downloads](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/reports.py): `web/reports.py`
- [Dashboard UI](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/web/static/app.js): `web/static/app.js`

### Scheduled automation

- [Auto-tagger](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/lambda/auto_tagger/main.py): `lambda/auto_tagger/main.py`
- [Instance scheduler](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/lambda/scheduler/main.py): `lambda/scheduler/main.py`
- [Snapshot cleanup](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/lambda/snapshot_cleanup/main.py): `lambda/snapshot_cleanup/main.py`

### AWS deployment

- [Infrastructure deployment](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/terraform/main.tf): `terraform/main.tf`
- [Lambda resources](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/terraform/modules/lambda/main.tf): `terraform/modules/lambda/main.tf`
- [Cost dashboard config](https://github.com/ayushraghuwanshi1704/aws-finops-cost-optimizer/blob/fix/verified-audit-corrections/dashboards/cost_overview_dashboard.json): `dashboards/cost_overview_dashboard.json`

### External services

- **Cost Explorer**
- **CloudWatch**
- **EC2 and RDS APIs**
- **EventBridge**
- **SNS notifications**
- **Budgets and anomalies**

### Other components

- **Engineer**

## Connections

- Engineer → Cost reports: runs analysis (evidence: `README.md`)
- Engineer → Waste detection: runs analysis (evidence: `README.md`)
- Engineer → Rightsizing: runs analysis (evidence: `README.md`)
- Engineer → Commitment analysis: runs analysis (evidence: `README.md`)
- Cost reports → Cost Explorer: queries costs (evidence: `README.md`)
- Commitment analysis → Cost Explorer: queries coverage (evidence: `README.md`)
- Waste detection → CloudWatch: reads metrics (evidence: `README.md`)
- Waste detection → EC2 and RDS APIs: describes resources (evidence: `README.md`)
- Rightsizing → CloudWatch: reads utilization (evidence: `README.md`)
- Rightsizing → EC2 and RDS APIs: describes instances (evidence: `README.md`)
- Engineer → Dashboard server: opens dashboard (evidence: `README.md`)
- Dashboard server → Payload provider: builds payload (evidence: `web/app.py`)
- Payload provider → Demo data: loads sample data (evidence: `web/data.py`)
- Payload provider → Live cost queries: queries live data (evidence: `web/data.py`)
- Payload provider → EBS status: loads EBS status (evidence: `web/data.py`)
- Payload provider → Cost reports: uses analysis (evidence: `web/data.py`)
- Payload provider → Waste detection: uses analysis (evidence: `web/data.py`)
- Payload provider → Rightsizing: uses analysis (evidence: `web/data.py`)
- Payload provider → Commitment analysis: uses analysis (evidence: `web/data.py`)
- Dashboard server → Report downloads: formats downloads (evidence: `web/app.py`)
- Dashboard server → EBS status: serves EBS route (evidence: `web/app.py`)
- Live cost queries → Cost Explorer: queries costs (evidence: `README.md`)
- EBS status → EC2 and RDS APIs: describes volumes (evidence: `web/ebs.py`)
- Dashboard UI → Dashboard server: requests dashboard
- Engineer → Infrastructure deployment: deploys toolkit (evidence: `README.md`)
- Infrastructure deployment → Lambda resources: configures functions
- Infrastructure deployment → Cost dashboard config: deploys monitoring
- EventBridge → Auto-tagger: schedules hourly (evidence: `README.md`)
- EventBridge → Instance scheduler: schedules stop start (evidence: `README.md`)
- EventBridge → Snapshot cleanup: schedules daily (evidence: `README.md`)
- Auto-tagger → EC2 and RDS APIs: updates tags (evidence: `README.md`)
- Instance scheduler → EC2 and RDS APIs: starts and stops (evidence: `README.md`)
- Snapshot cleanup → EC2 and RDS APIs: cleans snapshots (evidence: `README.md`)
- Auto-tagger → SNS notifications: notifies (evidence: `README.md`)
- Instance scheduler → SNS notifications: notifies (evidence: `README.md`)
- Snapshot cleanup → SNS notifications: notifies (evidence: `README.md`)
- Budgets and anomalies → SNS notifications: sends alerts (evidence: `README.md`)
