# kartiksharma0609/cloud-cost-guardian architecture

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

- Interactive diagram: https://gitdiagram.com/kartiksharma0609/cloud-cost-guardian
- Repository: https://github.com/kartiksharma0609/cloud-cost-guardian

## Overview

Cloud Cost Guardian is a Python CLI that scans AWS resources for waste, estimates monthly costs, and prints findings; optionally, it reports gross usage by billed service and which scanners cover it. Its main flow runs registered scanners independently, collecting each scanner’s findings and errors before the CLI formats the result. The source shows EBS volumes, ECR lifecycle gaps, and unassociated Elastic IPs, plus pricing fallbacks and Cost Explorer reporting. Edges reflect excerpted calls and registration; external AWS interactions are shown at the service boundary.

Main entry points: [`src/guardian/runner.py`](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/runner.py) (Scan runner), [`src/guardian/scanners/ebs.py`](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/ebs.py) (EBS scanner), [`src/guardian/scanners/ecr.py`](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/ecr.py) (ECR scanner), [`src/guardian/scanners/elastic_ip.py`](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/elastic_ip.py) (Elastic IP scanner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and orchestration"]
  node_cli["CLI<br/>[cli.py]"]
  node_runner["Scan runner<br/>[runner.py]"]
end

subgraph group_scanning["Resource scanners"]
  node_registry["Scanner registry<br/>[registry.py]"]
  node_discovery["Scanner discovery<br/>[__init__.py]"]
  node_ebs["EBS scanner<br/>[ebs.py]"]
  node_ecr["ECR scanner<br/>[ecr.py]"]
  node_elasticip["Elastic IP scanner<br/>[elastic_ip.py]"]
end

subgraph group_cost["Pricing and spend"]
  node_pricing["Price provider<br/>[pricing.py]"]
  node_spend["Spend retrieval<br/>[spend.py]"]
end

subgraph group_domain["Finding model"]
  node_finding["Finding model<br/>[models.py]"]
end

node_operator(("Operator"))
node_ec2{{"AWS EC2"}}
node_ecrservice{{"AWS ECR"}}
node_priceapi{{"AWS Price List"}}
node_costexplorer{{"AWS Cost Explorer"}}

node_operator -->|"runs"| node_cli
node_cli -->|"calls scan"| node_runner
node_runner -->|"reads scanners"| node_registry
node_runner -->|"imports"| node_discovery
node_discovery -->|"loads modules"| node_ebs
node_discovery -->|"loads modules"| node_ecr
node_discovery -->|"loads modules"| node_elasticip
node_ebs -->|"registers"| node_registry
node_ecr -->|"registers"| node_registry
node_elasticip -->|"registers"| node_registry
node_runner -->|"dispatches"| node_ebs
node_runner -->|"dispatches"| node_ecr
node_runner -->|"dispatches"| node_elasticip
node_ebs -->|"queries volumes"| node_ec2
node_elasticip -->|"queries addresses"| node_ec2
node_ecr -->|"queries repositories"| node_ecrservice
node_runner -->|"creates provider"| node_pricing
node_ebs -->|"gets price"| node_pricing
node_ecr -->|"gets estimate"| node_pricing
node_elasticip -->|"gets estimate"| node_pricing
node_pricing -->|"looks up EBS"| node_priceapi
node_ebs -->|"creates findings"| node_finding
node_ecr -->|"creates findings"| node_finding
node_elasticip -->|"creates findings"| node_finding
node_cli -->|"optionally reports"| node_spend
node_spend -->|"imports scanners"| node_discovery
node_spend -->|"matches coverage"| node_registry
node_spend -->|"fetches usage"| node_costexplorer

click node_cli "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/cli.py"
click node_runner "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/runner.py"
click node_registry "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/registry.py"
click node_discovery "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/__init__.py"
click node_ebs "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/ebs.py"
click node_ecr "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/ecr.py"
click node_elasticip "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/elastic_ip.py"
click node_pricing "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/pricing.py"
click node_spend "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/spend.py"
click node_finding "https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/models.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_cli,node_runner toneBlue
class node_registry,node_discovery,node_ebs,node_ecr,node_elasticip toneAmber
class node_pricing,node_spend toneMint
class node_finding toneRose
class node_operator,node_ec2,node_ecrservice,node_priceapi,node_costexplorer toneIndigo
```

## Components

### CLI and orchestration

- [CLI](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/cli.py): `src/guardian/cli.py`
- [Scan runner](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/runner.py): `src/guardian/runner.py`

### Resource scanners

- [Scanner registry](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/registry.py): `src/guardian/registry.py`
- [Scanner discovery](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/__init__.py): `src/guardian/scanners/__init__.py`
- [EBS scanner](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/ebs.py): `src/guardian/scanners/ebs.py`
- [ECR scanner](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/ecr.py): `src/guardian/scanners/ecr.py`
- [Elastic IP scanner](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/scanners/elastic_ip.py): `src/guardian/scanners/elastic_ip.py`

### Pricing and spend

- [Price provider](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/pricing.py): `src/guardian/pricing.py`
- [Spend retrieval](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/spend.py): `src/guardian/spend.py`

### Finding model

- [Finding model](https://github.com/kartiksharma0609/cloud-cost-guardian/blob/main/src/guardian/models.py): `src/guardian/models.py`

### Other components

- **Operator**
- **AWS EC2**
- **AWS ECR**
- **AWS Price List**
- **AWS Cost Explorer**

## Connections

- Operator → CLI: runs
- CLI → Scan runner: calls scan (evidence: `src/guardian/cli.py`)
- Scan runner → Scanner registry: reads scanners (evidence: `src/guardian/runner.py`)
- Scan runner → Scanner discovery: imports (evidence: `src/guardian/runner.py`)
- Scanner discovery → EBS scanner: loads modules (evidence: `src/guardian/scanners/__init__.py`)
- Scanner discovery → ECR scanner: loads modules (evidence: `src/guardian/scanners/__init__.py`)
- Scanner discovery → Elastic IP scanner: loads modules (evidence: `src/guardian/scanners/__init__.py`)
- EBS scanner → Scanner registry: registers (evidence: `src/guardian/scanners/ebs.py`)
- ECR scanner → Scanner registry: registers (evidence: `src/guardian/scanners/ecr.py`)
- Elastic IP scanner → Scanner registry: registers (evidence: `src/guardian/scanners/elastic_ip.py`)
- Scan runner → EBS scanner: dispatches (evidence: `src/guardian/runner.py`)
- Scan runner → ECR scanner: dispatches (evidence: `src/guardian/runner.py`)
- Scan runner → Elastic IP scanner: dispatches (evidence: `src/guardian/runner.py`)
- EBS scanner → AWS EC2: queries volumes (evidence: `src/guardian/scanners/ebs.py`)
- Elastic IP scanner → AWS EC2: queries addresses (evidence: `src/guardian/scanners/elastic_ip.py`)
- ECR scanner → AWS ECR: queries repositories (evidence: `src/guardian/scanners/ecr.py`)
- Scan runner → Price provider: creates provider (evidence: `src/guardian/runner.py`)
- EBS scanner → Price provider: gets price (evidence: `src/guardian/scanners/ebs.py`)
- ECR scanner → Price provider: gets estimate (evidence: `src/guardian/scanners/ecr.py`)
- Elastic IP scanner → Price provider: gets estimate (evidence: `src/guardian/scanners/elastic_ip.py`)
- Price provider → AWS Price List: looks up EBS (evidence: `src/guardian/pricing.py`)
- EBS scanner → Finding model: creates findings (evidence: `src/guardian/scanners/ebs.py`)
- ECR scanner → Finding model: creates findings (evidence: `src/guardian/scanners/ecr.py`)
- Elastic IP scanner → Finding model: creates findings (evidence: `src/guardian/scanners/elastic_ip.py`)
- CLI → Spend retrieval: optionally reports (evidence: `src/guardian/cli.py`)
- Spend retrieval → Scanner discovery: imports scanners (evidence: `src/guardian/spend.py`)
- Spend retrieval → Scanner registry: matches coverage (evidence: `src/guardian/spend.py`)
- Spend retrieval → AWS Cost Explorer: fetches usage (evidence: `src/guardian/spend.py`)
