# bh-gaur/cloud-cost-intelligence architecture

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

- Interactive diagram: https://gitdiagram.com/bh-gaur/cloud-cost-intelligence
- Repository: https://github.com/bh-gaur/cloud-cost-intelligence

## Overview

AWS Cost Intelligence is a multi-tenant FinOps platform. Users explore cost and account data in the React app; its API layer scopes requests to an organization, aggregates stored spend and provider data, and returns dashboard, drilldown, and export results. Separate branches analyze optimization opportunities and anomalies, track budgets and tagging, and generate and dispatch reports. The README documents major capabilities that are not fully visible in sampled source; those branches are represented at subsystem level. Arrows use cited excerpts or README statements; unsampled implementation details are not asserted.

Main entry points: [`backend/app/database/base.py`](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/database/base.py) (ORM base), [`backend/app/reports/service.py`](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/reports/service.py) (Report service), [`frontend/src/App.tsx`](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/App.tsx) (Routes and shell), [`backend/app/api/v1/__init__.py`](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/api/v1/__init__.py) (Versioned API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User application"]
  node_app["Routes and shell<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_landing["Landing<br/>[Landing.tsx]"]
  node_admin["Admin users<br/>[AdminUsers.tsx]"]
  node_httpclient["API client<br/>[client.ts]"]
  node_types["API data types<br/>[index.ts]"]
end

subgraph group_api["API and access"]
  node_api["Versioned API<br/>[__init__.py]"]
  node_auth["Auth and tenant scope<br/>[tenant_context.py]"]
  node_costapi["Services endpoint<br/>[services.py]"]
end

subgraph group_finops["FinOps analysis"]
  node_costservice["Cost aggregation<br/>[cost_service.py]"]
  node_optimization["Optimization engine<br/>[engine.py]"]
  node_rules["Optimization rules<br/>[s3_storage.py]"]
  node_alerts["Anomaly detection<br/>[detector.py]"]
  node_tagging["Tag governance<br/>[tagging_service.py]"]
  node_reports["Report service<br/>[service.py]"]
end

subgraph group_integrations["Providers and delivery"]
  node_notifications["Notification dispatch<br/>[service.py]"]
  node_provider["Provider abstraction<br/>[factory.py]"]
end

subgraph group_data["Persistence"]
  node_settings["Runtime settings<br/>[settings.py]"]
  node_session["Database sessions<br/>[session.py]"]
  node_base["ORM base<br/>[base.py]"]
  node_accounts[("AWS accounts<br/>[account.py]")]
  node_costs[("Cost records<br/>[cost.py]")]
  node_orgs[("Organizations<br/>[organization.py]")]
  node_users[("Users<br/>[user.py]")]
  node_alertrecords[("Alert records<br/>[alert.py]")]
  node_recommendations[("Recommendations<br/>[optimization.py]")]
end

node_user(("FinOps user"))
node_aws{{"AWS services"}}

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_admin
node_dashboard -.->|"requests data"| node_httpclient
node_httpclient -.->|"sends requests"| node_api
node_httpclient -->|"uses types"| node_types
node_api -.->|"scopes access"| node_auth
node_api -.->|"routes services"| node_costapi
node_costapi -->|"calls"| node_costservice
node_costservice -->|"queries"| node_costs
node_costservice -->|"queries"| node_accounts
node_costservice -->|"uses provider"| node_provider
node_optimization -->|"evaluates"| node_rules
node_optimization -->|"saves findings"| node_recommendations
node_alerts -.->|"records anomalies"| node_alertrecords
node_tagging -->|"analyzes tags"| node_costs
node_reports -->|"reads spend"| node_costs
node_reports -->|"reads findings"| node_recommendations
node_reports -->|"reads alerts"| node_alertrecords
node_reports -.->|"dispatches reports"| node_notifications
node_notifications -.->|"notifies channels"| node_aws
node_provider -.->|"queries AWS"| node_aws
node_session -->|"configures engine"| node_settings
node_api -->|"injects sessions"| node_session
node_session -.->|"creates sessions"| node_base
node_base -->|"models"| node_accounts
node_base -->|"models"| node_costs
node_base -->|"models"| node_orgs
node_base -->|"models"| node_users

click node_app "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/App.tsx"
click node_dashboard "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/pages/Dashboard.tsx"
click node_landing "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/pages/Landing.tsx"
click node_admin "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/pages/AdminUsers.tsx"
click node_httpclient "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/api/client.ts"
click node_types "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/types/index.ts"
click node_api "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/api/v1/__init__.py"
click node_auth "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/auth/tenant_context.py"
click node_costapi "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/api/v1/services.py"
click node_costservice "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/services/cost_service.py"
click node_optimization "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/optimization/engine.py"
click node_rules "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/optimization/rules/s3_storage.py"
click node_alerts "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/alerts/detector.py"
click node_tagging "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/services/tagging_service.py"
click node_reports "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/reports/service.py"
click node_notifications "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/notifications/service.py"
click node_provider "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/providers/factory.py"
click node_settings "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/config/settings.py"
click node_session "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/database/session.py"
click node_base "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/database/base.py"
click node_accounts "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/account.py"
click node_costs "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/cost.py"
click node_orgs "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/organization.py"
click node_users "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/user.py"
click node_alertrecords "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/alert.py"
click node_recommendations "https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/optimization.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_app,node_dashboard,node_landing,node_admin,node_httpclient,node_types,node_user toneBlue
class node_api,node_auth,node_costapi toneAmber
class node_costservice,node_optimization,node_rules,node_alerts,node_tagging,node_reports toneMint
class node_notifications,node_provider toneRose
class node_settings,node_session,node_base,node_accounts,node_costs,node_orgs,node_users,node_alertrecords,node_recommendations,node_aws toneIndigo
```

## Components

### User application

- [Routes and shell](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Dashboard](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [Landing](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/pages/Landing.tsx): `frontend/src/pages/Landing.tsx`
- [Admin users](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/pages/AdminUsers.tsx): `frontend/src/pages/AdminUsers.tsx`
- [API client](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [API data types](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/frontend/src/types/index.ts): `frontend/src/types/index.ts`

### API and access

- [Versioned API](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/api/v1/__init__.py): `backend/app/api/v1/__init__.py`
- [Auth and tenant scope](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/auth/tenant_context.py): `backend/app/auth/tenant_context.py`
- [Services endpoint](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/api/v1/services.py): `backend/app/api/v1/services.py`

### FinOps analysis

- [Cost aggregation](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/services/cost_service.py): `backend/app/services/cost_service.py`
- [Optimization engine](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/optimization/engine.py): `backend/app/optimization/engine.py`
- [Optimization rules](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/optimization/rules/s3_storage.py): `backend/app/optimization/rules/s3_storage.py`
- [Anomaly detection](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/alerts/detector.py): `backend/app/alerts/detector.py`
- [Tag governance](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/services/tagging_service.py): `backend/app/services/tagging_service.py`
- [Report service](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/reports/service.py): `backend/app/reports/service.py`

### Providers and delivery

- [Notification dispatch](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/notifications/service.py): `backend/app/notifications/service.py`
- [Provider abstraction](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/providers/factory.py): `backend/app/providers/factory.py`

### Persistence

- [Runtime settings](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/config/settings.py): `backend/app/config/settings.py`
- [Database sessions](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/database/session.py): `backend/app/database/session.py`
- [ORM base](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/database/base.py): `backend/app/database/base.py`
- [AWS accounts](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/account.py): `backend/app/models/account.py`
- [Cost records](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/cost.py): `backend/app/models/cost.py`
- [Organizations](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/organization.py): `backend/app/models/organization.py`
- [Users](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/user.py): `backend/app/models/user.py`
- [Alert records](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/alert.py): `backend/app/models/alert.py`
- [Recommendations](https://github.com/bh-gaur/cloud-cost-intelligence/blob/main/backend/app/models/optimization.py): `backend/app/models/optimization.py`

### Other components

- **FinOps user**
- **AWS services**

## Connections

- FinOps user → Routes and shell: uses
- Routes and shell → Dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Routes and shell → Landing: routes to (evidence: `frontend/src/App.tsx`)
- Routes and shell → Admin users: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard → API client: requests data
- API client → Versioned API: sends requests
- API client → API data types: uses types (evidence: `frontend/src/api/client.ts`)
- Versioned API → Auth and tenant scope: scopes access
- Versioned API → Services endpoint: routes services
- Services endpoint → Cost aggregation: calls (evidence: `backend/app/api/v1/services.py`)
- Cost aggregation → Cost records: queries (evidence: `backend/app/services/cost_service.py`)
- Cost aggregation → AWS accounts: queries (evidence: `backend/app/services/cost_service.py`)
- Cost aggregation → Provider abstraction: uses provider (evidence: `backend/app/services/cost_service.py`)
- Optimization engine → Optimization rules: evaluates (evidence: `backend/app/optimization/engine.py`)
- Optimization engine → Recommendations: saves findings (evidence: `backend/app/optimization/engine.py`)
- Anomaly detection → Alert records: records anomalies
- Tag governance → Cost records: analyzes tags (evidence: `backend/app/services/tagging_service.py`)
- Report service → Cost records: reads spend (evidence: `backend/app/reports/service.py`)
- Report service → Recommendations: reads findings (evidence: `backend/app/reports/service.py`)
- Report service → Alert records: reads alerts (evidence: `backend/app/reports/service.py`)
- Report service → Notification dispatch: dispatches reports
- Notification dispatch → AWS services: notifies channels
- Provider abstraction → AWS services: queries AWS
- Database sessions → Runtime settings: configures engine (evidence: `backend/app/database/session.py`)
- Versioned API → Database sessions: injects sessions
- Database sessions → ORM base: creates sessions
- ORM base → AWS accounts: models (evidence: `backend/app/models/account.py`)
- ORM base → Cost records: models (evidence: `backend/app/models/cost.py`)
- ORM base → Organizations: models (evidence: `backend/app/models/organization.py`)
- ORM base → Users: models (evidence: `backend/app/models/user.py`)
