# vedantsingh-0/cloud-cost-optimizer architecture

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

- Interactive diagram: https://gitdiagram.com/vedantsingh-0/cloud-cost-optimizer
- Repository: https://github.com/vedantsingh-0/cloud-cost-optimizer

## Overview

CloudOptimizer is a web application for users to connect AWS accounts, inspect cloud costs and resource usage, configure alerts, and manage paid plans. The principal workflow is account registration/login, AWS credential setup, then dashboard requests for cost, EC2, and S3 data; the UI presents results as charts and summaries. Separate capabilities cover scheduled/email reports and alerts, administrative user access, and Razorpay subscriptions. The frontend excerpt shows these API interactions, while some backend routes and resource controllers were not sampled; their subsystem paths are grounded in the file tree, but uncertain internal wiring is omitted.

Main entry points: [`frontend/src/App.js`](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/frontend/src/App.js) (Dashboard UI), [`backend/index.js`](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/index.js) (Express API), [`backend/middleware/auth.js`](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/middleware/auth.js) (Auth guard), [`backend/models/User.js`](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/models/User.js) (User records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_app["Dashboard UI<br/>[App.js]"]
  node_landing["Landing page<br/>[LandingPage.js]"]
  node_pricing_ui["Pricing UI<br/>[Pricing.js]"]
end

subgraph group_identity["Identity and accounts"]
  node_api["Express API<br/>[index.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_auth["Authentication<br/>[authController.js]"]
  node_auth_middleware["Auth guard<br/>[auth.js]"]
  node_user_model[("User records<br/>[User.js]")]
  node_aws_settings["AWS credentials<br/>[authController.js]"]
end

subgraph group_cloud["AWS insights"]
  node_cost_routes["Cost routes<br/>[costRoutes.js]"]
  node_cost_controller["Cost analysis<br/>[costController.js]"]
  node_aws_clients["Per-user AWS clients<br/>[userAwsClients.js]"]
  node_ec2_routes["EC2 routes<br/>[ec2Routes.js]"]
  node_ec2_controller["EC2 insights<br/>[ec2Controller.js]"]
  node_s3_routes["S3 routes<br/>[s3Routes.js]"]
  node_s3_controller["S3 usage<br/>[s3Controller.js]"]
end

subgraph group_alerts["Cost notifications"]
  node_alert_routes["Alert routes<br/>[alertRoutes.js]"]
  node_alert_controller["Alerts and reports<br/>[alertController.js]"]
end

subgraph group_billing["Plans and billing"]
  node_payment_routes["Payment routes<br/>[paymentRoutes.js]"]
  node_payment_controller["Plans and payment"]
end

node_visitor(("Visitor / user"))
node_cost_explorer["AWS Cost Explorer"]
node_aws_services["AWS EC2 / S3"]
node_email["Email delivery"]
node_razorpay["Razorpay"]

node_visitor -->|"opens"| node_landing
node_landing -->|"starts signup"| node_app
node_visitor -->|"uses"| node_app
node_app -->|"API requests"| node_api
node_api -->|"dispatches"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth
node_auth_routes -->|"protects routes"| node_auth_middleware
node_auth -->|"reads / writes"| node_user_model
node_app -->|"submits credentials"| node_aws_settings
node_auth -->|"stores credentials"| node_user_model
node_api -->|"dispatches"| node_cost_routes
node_cost_routes -->|"protects routes"| node_auth_middleware
node_cost_routes -->|"dispatches"| node_cost_controller
node_cost_controller -->|"reads credentials"| node_user_model
node_cost_controller -->|"queries costs"| node_cost_explorer
node_app -->|"requests idle EC2"| node_ec2_routes
node_api -->|"dispatches"| node_ec2_routes
node_ec2_routes -->|"protects routes"| node_auth_middleware
node_ec2_routes -->|"dispatches"| node_ec2_controller
node_app -->|"requests usage"| node_s3_routes
node_api -->|"dispatches"| node_s3_routes
node_s3_routes -->|"protects routes"| node_auth_middleware
node_s3_routes -->|"dispatches"| node_s3_controller
node_ec2_controller -->|"gets client"| node_aws_clients
node_s3_controller -->|"gets client"| node_aws_clients
node_aws_clients -->|"loads credentials"| node_user_model
node_aws_clients -->|"creates AWS clients"| node_aws_services
node_app -->|"checks / configures"| node_alert_routes
node_api -->|"dispatches"| node_alert_routes
node_alert_routes -->|"protects routes"| node_auth_middleware
node_alert_routes -->|"dispatches"| node_alert_controller
node_alert_controller -->|"gets cost client"| node_aws_clients
node_alert_controller -->|"queries costs"| node_cost_explorer
node_alert_controller -->|"reads / updates"| node_user_model
node_alert_controller -->|"sends notices"| node_email
node_app -->|"opens plans"| node_pricing_ui
node_pricing_ui -->|"requests plans"| node_payment_routes
node_app -->|"creates / verifies"| node_payment_routes
node_api -->|"dispatches"| node_payment_routes
node_payment_routes -->|"protects payments"| node_auth_middleware
node_payment_routes -->|"dispatches"| node_payment_controller
node_payment_controller -->|"creates orders"| node_razorpay
node_payment_controller -->|"updates plan"| node_user_model

click node_app "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/frontend/src/App.js"
click node_landing "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/frontend/src/LandingPage.js"
click node_pricing_ui "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/frontend/src/Pricing.js"
click node_api "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/index.js"
click node_auth_routes "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/authRoutes.js"
click node_auth "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/authController.js"
click node_auth_middleware "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/middleware/auth.js"
click node_user_model "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/models/User.js"
click node_aws_settings "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/authController.js"
click node_cost_routes "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/costRoutes.js"
click node_cost_controller "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/costController.js"
click node_aws_clients "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/config/userAwsClients.js"
click node_ec2_routes "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/ec2Routes.js"
click node_ec2_controller "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/ec2Controller.js"
click node_s3_routes "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/s3Routes.js"
click node_s3_controller "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/s3Controller.js"
click node_alert_routes "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/alertRoutes.js"
click node_alert_controller "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/alertController.js"
click node_payment_routes "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/paymentRoutes.js"
click node_payment_controller "https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/paymentController.js"

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_landing,node_pricing_ui,node_visitor toneBlue
class node_api,node_auth_routes,node_auth,node_auth_middleware,node_user_model,node_aws_settings toneAmber
class node_cost_routes,node_cost_controller,node_aws_clients,node_ec2_routes,node_ec2_controller,node_s3_routes,node_s3_controller toneMint
class node_alert_routes,node_alert_controller toneRose
class node_payment_routes,node_payment_controller,node_cost_explorer,node_aws_services,node_email,node_razorpay toneIndigo
```

## Components

### Web interface

- [Dashboard UI](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Landing page](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/frontend/src/LandingPage.js): `frontend/src/LandingPage.js`
- [Pricing UI](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/frontend/src/Pricing.js): `frontend/src/Pricing.js`

### Identity and accounts

- [Express API](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/index.js): `backend/index.js`
- [Auth routes](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Authentication](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Auth guard](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [User records](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/models/User.js): `backend/models/User.js`
- [AWS credentials](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`

### AWS insights

- [Cost routes](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/costRoutes.js): `backend/routes/costRoutes.js`
- [Cost analysis](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/costController.js): `backend/controllers/costController.js`
- [Per-user AWS clients](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/config/userAwsClients.js): `backend/config/userAwsClients.js`
- [EC2 routes](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/ec2Routes.js): `backend/routes/ec2Routes.js`
- [EC2 insights](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/ec2Controller.js): `backend/controllers/ec2Controller.js`
- [S3 routes](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/s3Routes.js): `backend/routes/s3Routes.js`
- [S3 usage](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/s3Controller.js): `backend/controllers/s3Controller.js`

### Cost notifications

- [Alert routes](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/alertRoutes.js): `backend/routes/alertRoutes.js`
- [Alerts and reports](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/alertController.js): `backend/controllers/alertController.js`

### Plans and billing

- [Payment routes](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/routes/paymentRoutes.js): `backend/routes/paymentRoutes.js`
- [Plans and payment](https://github.com/vedantsingh-0/cloud-cost-optimizer/blob/main/backend/controllers/paymentController.js): `backend/controllers/paymentController.js`

### Other components

- **Visitor / user**
- **AWS Cost Explorer**
- **AWS EC2 / S3**
- **Email delivery**
- **Razorpay**

## Connections

- Visitor / user → Landing page: opens
- Landing page → Dashboard UI: starts signup
- Visitor / user → Dashboard UI: uses
- Dashboard UI → Express API: API requests
- Express API → Auth routes: dispatches
- Auth routes → Authentication: dispatches
- Auth routes → Auth guard: protects routes
- Authentication → User records: reads / writes
- Dashboard UI → AWS credentials: submits credentials
- Authentication → User records: stores credentials
- Express API → Cost routes: dispatches
- Cost routes → Auth guard: protects routes
- Cost routes → Cost analysis: dispatches
- Cost analysis → User records: reads credentials
- Cost analysis → AWS Cost Explorer: queries costs
- Dashboard UI → EC2 routes: requests idle EC2
- Express API → EC2 routes: dispatches
- EC2 routes → Auth guard: protects routes
- EC2 routes → EC2 insights: dispatches
- Dashboard UI → S3 routes: requests usage
- Express API → S3 routes: dispatches
- S3 routes → Auth guard: protects routes
- S3 routes → S3 usage: dispatches
- EC2 insights → Per-user AWS clients: gets client
- S3 usage → Per-user AWS clients: gets client
- Per-user AWS clients → User records: loads credentials
- Per-user AWS clients → AWS EC2 / S3: creates AWS clients
- Dashboard UI → Alert routes: checks / configures
- Express API → Alert routes: dispatches
- Alert routes → Auth guard: protects routes
- Alert routes → Alerts and reports: dispatches
- Alerts and reports → Per-user AWS clients: gets cost client
- Alerts and reports → AWS Cost Explorer: queries costs
- Alerts and reports → User records: reads / updates
- Alerts and reports → Email delivery: sends notices
- Dashboard UI → Pricing UI: opens plans
- Pricing UI → Payment routes: requests plans
- Dashboard UI → Payment routes: creates / verifies
- Express API → Payment routes: dispatches
- Payment routes → Auth guard: protects payments
- Payment routes → Plans and payment: dispatches
- Plans and payment → Razorpay: creates orders
- Plans and payment → User records: updates plan
