# oseghalep/cloud-cost-optimization-hub architecture

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

- Interactive diagram: https://gitdiagram.com/oseghalep/cloud-cost-optimization-hub
- Repository: https://github.com/oseghalep/cloud-cost-optimization-hub

## Overview

CCOH is a multi-cloud cost observability and optimization web application. Users register or log in, add cloud accounts, and view cost dashboards and optimization recommendations. The backend exposes authenticated API routes; account handlers trigger cost ingestion, while recommendation generation and dashboard queries are separate product stages. The README documents AWS, GCP, and Azure support, authentication, dashboard, and demo cost data. Some frontend-to-API wiring and unsampled handler behavior are not shown, so those links are omitted.

Main entry points: [`backend/internal/api/router.go`](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/router.go) (API routing), [`backend/internal/repository/postgres`](https://github.com/oseghalep/cloud-cost-optimization-hub/tree/main/backend/internal/repository/postgres) (PostgreSQL repositories), [`backend/internal/api/handlers/multi_cloud_handlers.go`](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/multi_cloud_handlers.go) (GCP and Azure accounts), [`backend/internal/services/cost_ingestion/gcp_service.go`](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/services/cost_ingestion/gcp_service.go) (GCP cost ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_login["Login and register<br/>[page.tsx]"]
  node_accounts_ui["Cloud accounts<br/>[page.tsx]"]
  node_dashboard_ui["Cost dashboard<br/>[page.tsx]"]
  node_recommendations_ui["Recommendations view<br/>[page.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and identity"]
  node_server["HTTP server<br/>[main.go]"]
  node_router["API routing<br/>[router.go]"]
  node_auth_handler["Authentication<br/>[auth.go]"]
  node_account_handler["Account management<br/>[accounts.go]"]
  node_multicloud_handler["GCP and Azure accounts"]
  node_dashboard_handler["Dashboard queries<br/>[dashboard.go]"]
  node_recommendation_handler["Recommendation actions<br/>[recommendations.go]"]
end

subgraph group_cloud["Cloud cost services"]
  node_aws_ingest["AWS cost ingestion<br/>[aws_service.go]"]
  node_gcp_ingest["GCP cost ingestion<br/>[gcp_service.go]"]
  node_azure_ingest["Azure cost ingestion<br/>[azure_service.go]"]
  node_recommendation_engine["Recommendation engine<br/>[engine.go]"]
end

subgraph group_data["Persistence and models"]
  node_repositories["PostgreSQL repositories"]
  node_database[("PostgreSQL database<br/>[db.go]")]
  node_domain_models["Cost and account models"]
end

node_user(("Cloud cost user"))
node_aws{{"AWS Cost Explorer"}}
node_gcp_azure{{"GCP and Azure"}}

node_user -->|"registers or logs in"| node_login
node_user -->|"manages accounts"| node_accounts_ui
node_user -->|"views costs"| node_dashboard_ui
node_user -.->|"reviews savings"| node_recommendations_ui
node_server -->|"serves routes"| node_router
node_router -->|"routes auth"| node_auth_handler
node_router -->|"routes accounts"| node_account_handler
node_router -->|"routes cloud setup"| node_multicloud_handler
node_router -->|"routes dashboard"| node_dashboard_handler
node_router -->|"routes recommendations"| node_recommendation_handler
node_router -->|"initializes repositories"| node_repositories
node_router -->|"initializes service"| node_aws_ingest
node_router -->|"initializes service"| node_gcp_ingest
node_router -->|"initializes service"| node_azure_ingest
node_router -->|"initializes engine"| node_recommendation_engine
node_multicloud_handler -->|"triggers cost fetch"| node_gcp_ingest
node_multicloud_handler -->|"triggers cost fetch"| node_azure_ingest
node_auth_handler -->|"reads and creates users"| node_repositories
node_aws_ingest -->|"queries costs"| node_aws
node_gcp_ingest -->|"stores costs"| node_repositories
node_azure_ingest -->|"stores costs"| node_repositories
node_recommendation_engine -->|"reads and writes"| node_repositories
node_server -->|"connects database"| node_database
node_repositories -.->|"persists product data"| node_database

click node_login "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/app/login/page.tsx"
click node_accounts_ui "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/app/accounts/page.tsx"
click node_dashboard_ui "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/app/dashboard/page.tsx"
click node_recommendations_ui "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/app/recommendations/page.tsx"
click node_api_client "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/lib/api.ts"
click node_server "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/cmd/api/main.go"
click node_router "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/router.go"
click node_auth_handler "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/auth.go"
click node_account_handler "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/accounts.go"
click node_multicloud_handler "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/multi_cloud_handlers.go"
click node_dashboard_handler "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/dashboard.go"
click node_recommendation_handler "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/recommendations.go"
click node_aws_ingest "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/services/cost_ingestion/aws_service.go"
click node_gcp_ingest "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/services/cost_ingestion/gcp_service.go"
click node_azure_ingest "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/services/cost_ingestion/azure_service.go"
click node_recommendation_engine "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/services/recommendations/engine.go"
click node_repositories "https://github.com/oseghalep/cloud-cost-optimization-hub/tree/main/backend/internal/repository/postgres"
click node_database "https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/pkg/db/db.go"
click node_domain_models "https://github.com/oseghalep/cloud-cost-optimization-hub/tree/main/backend/internal/models"

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_login,node_accounts_ui,node_dashboard_ui,node_recommendations_ui,node_api_client,node_user toneBlue
class node_server,node_router,node_auth_handler,node_account_handler,node_multicloud_handler,node_dashboard_handler,node_recommendation_handler toneAmber
class node_aws_ingest,node_gcp_ingest,node_azure_ingest,node_recommendation_engine toneMint
class node_repositories,node_database,node_domain_models toneRose
class node_aws,node_gcp_azure toneIndigo
```

## Components

### Web interface

- [Login and register](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/app/login/page.tsx): `frontend/app/login/page.tsx`
- [Cloud accounts](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/app/accounts/page.tsx): `frontend/app/accounts/page.tsx`
- [Cost dashboard](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/app/dashboard/page.tsx): `frontend/app/dashboard/page.tsx`
- [Recommendations view](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/app/recommendations/page.tsx): `frontend/app/recommendations/page.tsx`
- [API client](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`

### API and identity

- [HTTP server](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/cmd/api/main.go): `backend/cmd/api/main.go`
- [API routing](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/router.go): `backend/internal/api/router.go`
- [Authentication](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/auth.go): `backend/internal/api/handlers/auth.go`
- [Account management](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/accounts.go): `backend/internal/api/handlers/accounts.go`
- [GCP and Azure accounts](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/multi_cloud_handlers.go): `backend/internal/api/handlers/multi_cloud_handlers.go`
- [Dashboard queries](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/dashboard.go): `backend/internal/api/handlers/dashboard.go`
- [Recommendation actions](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/api/handlers/recommendations.go): `backend/internal/api/handlers/recommendations.go`

### Cloud cost services

- [AWS cost ingestion](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/services/cost_ingestion/aws_service.go): `backend/internal/services/cost_ingestion/aws_service.go`
- [GCP cost ingestion](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/services/cost_ingestion/gcp_service.go): `backend/internal/services/cost_ingestion/gcp_service.go`
- [Azure cost ingestion](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/services/cost_ingestion/azure_service.go): `backend/internal/services/cost_ingestion/azure_service.go`
- [Recommendation engine](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/internal/services/recommendations/engine.go): `backend/internal/services/recommendations/engine.go`

### Persistence and models

- [PostgreSQL repositories](https://github.com/oseghalep/cloud-cost-optimization-hub/tree/main/backend/internal/repository/postgres): `backend/internal/repository/postgres`
- [PostgreSQL database](https://github.com/oseghalep/cloud-cost-optimization-hub/blob/main/backend/pkg/db/db.go): `backend/pkg/db/db.go`
- [Cost and account models](https://github.com/oseghalep/cloud-cost-optimization-hub/tree/main/backend/internal/models): `backend/internal/models`

### Other components

- **Cloud cost user**
- **AWS Cost Explorer**
- **GCP and Azure**

## Connections

- Cloud cost user → Login and register: registers or logs in
- Cloud cost user → Cloud accounts: manages accounts
- Cloud cost user → Cost dashboard: views costs
- Cloud cost user → Recommendations view: reviews savings
- HTTP server → API routing: serves routes (evidence: `backend/cmd/api/main.go`)
- API routing → Authentication: routes auth (evidence: `backend/internal/api/router.go`)
- API routing → Account management: routes accounts (evidence: `backend/internal/api/router.go`)
- API routing → GCP and Azure accounts: routes cloud setup (evidence: `backend/internal/api/router.go`)
- API routing → Dashboard queries: routes dashboard (evidence: `backend/internal/api/router.go`)
- API routing → Recommendation actions: routes recommendations (evidence: `backend/internal/api/router.go`)
- API routing → PostgreSQL repositories: initializes repositories (evidence: `backend/internal/api/router.go`)
- API routing → AWS cost ingestion: initializes service (evidence: `backend/internal/api/router.go`)
- API routing → GCP cost ingestion: initializes service (evidence: `backend/internal/api/router.go`)
- API routing → Azure cost ingestion: initializes service (evidence: `backend/internal/api/router.go`)
- API routing → Recommendation engine: initializes engine (evidence: `backend/internal/api/router.go`)
- GCP and Azure accounts → GCP cost ingestion: triggers cost fetch (evidence: `backend/internal/api/handlers/multi_cloud_handlers.go`)
- GCP and Azure accounts → Azure cost ingestion: triggers cost fetch (evidence: `backend/internal/api/handlers/multi_cloud_handlers.go`)
- Authentication → PostgreSQL repositories: reads and creates users (evidence: `backend/internal/api/handlers/auth.go`)
- AWS cost ingestion → AWS Cost Explorer: queries costs (evidence: `backend/internal/services/cost_ingestion/aws_service.go`)
- GCP cost ingestion → PostgreSQL repositories: stores costs (evidence: `backend/internal/services/cost_ingestion/gcp_service.go`)
- Azure cost ingestion → PostgreSQL repositories: stores costs (evidence: `backend/internal/services/cost_ingestion/azure_service.go`)
- Recommendation engine → PostgreSQL repositories: reads and writes (evidence: `backend/internal/services/recommendations/engine.go`)
- HTTP server → PostgreSQL database: connects database (evidence: `backend/cmd/api/main.go`)
- PostgreSQL repositories → PostgreSQL database: persists product data
