# septblast/aws-resources-cost-board architecture

> Architecture diagram of the GitHub repository septblast/aws-resources-cost-board, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/septblast/aws-resources-cost-board
- Repository: https://github.com/septblast/aws-resources-cost-board

## Overview

##### Main Components
- Frontend: Represented by the React application. This part contains the UI components (in the “components” directory) and a service layer (“services/api.js”) that communicates with the backend.
- Backend API: Constructed in Go, which is split into several modules:
- API Handlers: Contained under “backend/api” (and “backend/internal/api”) where the endpoints and request handling logic reside.
- AWS Integration Layer: Located in “backend/aws” (and similarly under “backend/internal/aws”). This houses service clients and functions to interact with various AWS APIs (EC2, RDS, Cost Explorer, CloudWatch, etc.).
- Models: Both “backend/models” and “backend/internal/models” represent the data structures used across the application.
- Services: “backend/internal/services” for business logic like resource cost calculation and aggregation.
- Configuration: “backend/internal/config” manages application settings and environment variables.
- EC2 for instance data.
- RDS for database instance information.
- Cost Explorer (and CloudWatch for monitoring capabilities) for getting cost and usage reports.

##### Relationships and Interactions
- Client-to-Server Communication: The React frontend sends HTTP requests (likely RESTful API calls) to the Go backend.
- API Layer: In the backend, API endpoints (in “api/server.go”, “cmd/server/main.go”) process incoming requests, call the service layer, and respond with JSON data.
- AWS Integration: The backend service calls functions in the AWS integration modules (i.e. “aws/client.go”, “aws/ec2.go”, “aws/rds.go”, “aws/cost.go”, “aws/cloudwatch.go”) to fetch resource and cost data from AWS.
- Data Flow: Once AWS data is retrieved, the data is processed (using models and services) and returned to the frontend for visualization.

##### Architectural Patterns and Design Principles
- Layered Architecture: The separation between routines that handle HTTP requests (API handlers), business logic (internal services), and external integrations (AWS adapters) is clear.
- Separation of Concerns: Splitting the application into distinct directories (api, aws, models, config, etc.) reflects modular design.
- Client-Server Model: A clear delineation between the frontend (user interface) and backend (logic and integration) is evident.
- Extensibility: The structure (with separation between external service operations and internal application logic) makes it easy to extend functionality (e.g., adding new AWS service integrations).

##### Technologies and Frameworks
- Frontend: Built with React (JavaScript/JSX) using components and service calls to interact with the backend.
- Backend: Built with Go. It uses Go modules (go.mod, go.sum) for dependency management.
- AWS SDK Usage: The backend includes AWS client functionality to query various AWS services, emphasizing the project’s integration with AWS.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Browser/React App"]:::client

    %% Frontend Layer
    subgraph "React Frontend"
        Components["UI Components"]:::frontend
        ApiService["API Service Layer"]:::frontend
    end

    Browser -->|"HTTP_Calls"| Components
    Components -->|"Utilizes"| ApiService
    Browser -->|"calls_API"| APIServer

    %% Backend Layer
    subgraph "Go Backend"
        APIHandlers["API Handlers"]:::backend
        Business["Business Logic Services"]:::backend
        AWSIntegration["AWS Integration Layer"]:::backend
        DataModels["Data Models"]:::backend
        Config["Configuration"]:::backend
        APIMain["API Server Execution"]:::backend
    end

    %% Internal Backend Flow
    APIHandlers -->|"invokes"| Business
    Business -->|"calls"| AWSIntegration
    AWSIntegration -->|"processes_data"| DataModels
    Config -->|"configures"| APIHandlers
    APIMain -->|"starts_server"| APIHandlers
    APIHandlers -->|"returns_JSON"| ApiService

    %% External AWS Services
    subgraph "AWS Services"
        AWS_EC2["EC2 Instances"]:::aws
        AWS_RDS["RDS Instances"]:::aws
        AWS_Cost["Cost Explorer"]:::aws
        AWS_CW["CloudWatch"]:::aws
    end

    AWSIntegration -->|"fetches_EC2_Data"| AWS_EC2
    AWSIntegration -->|"fetches_RDS_Data"| AWS_RDS
    AWSIntegration -->|"fetches_Cost_Data"| AWS_Cost
    AWSIntegration -->|"fetches_CW_Data"| AWS_CW

    %% API Server node to connect Frontend and Backend
    APIServer["Go API Server"]:::backend
    APIServer --> APIHandlers

    %% Click Events for Component Mapping
    click Components "https://github.com/septblast/aws-resources-cost-board/tree/main/frontend/src/components"
    click ApiService "https://github.com/septblast/aws-resources-cost-board/blob/main/frontend/src/services/api.js"
    click APIHandlers "https://github.com/septblast/aws-resources-cost-board/tree/main/backend/api"
    click APIHandlers "https://github.com/septblast/aws-resources-cost-board/blob/main/backend/internal/api/server.go"
    click AWSIntegration "https://github.com/septblast/aws-resources-cost-board/blob/main/backend/aws/client.go"
    click AWSIntegration "https://github.com/septblast/aws-resources-cost-board/blob/main/backend/internal/aws/client.go"
    click DataModels "https://github.com/septblast/aws-resources-cost-board/blob/main/backend/models/models.go"
    click DataModels "https://github.com/septblast/aws-resources-cost-board/blob/main/backend/internal/models/resource.go"
    click Business "https://github.com/septblast/aws-resources-cost-board/blob/main/backend/internal/services/resource_service.go"
    click Config "https://github.com/septblast/aws-resources-cost-board/blob/main/backend/internal/config/config.go"
    click APIMain "https://github.com/septblast/aws-resources-cost-board/blob/main/backend/cmd/server/main.go"

    %% Styling Classes
    classDef client fill:#f9f,stroke:#333,stroke-width:2px;
    classDef frontend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef backend fill:#cfc,stroke:#333,stroke-width:2px;
    classDef aws fill:#fcc,stroke:#333,stroke-width:2px;
```
