# finops-sql

This repository contains a collection of SQL queries and data models designed for multi-cloud FinOps analysis and cost governance. The queries are primarily focused on extracting, transforming, and analyzing billing data from various cloud providers (Alibaba Cloud, AWS, Azure, GCP) to provide insights into cloud spending, resource utilization, and cost optimization opportunities.

## Project Structure

The SQL queries are organized by cloud provider within the `BigQuery/` directory. Each cloud provider subdirectory further categorizes queries based on their purpose (e.g., account-level cost, product-specific analysis, tagging compliance, Kubernetes costs).

*   **`BigQuery/`**: Contains all BigQuery SQL queries, structured by cloud provider.
    *   **`cloud_alibaba/`**: SQL queries for Alibaba Cloud billing data.
    *   **`cloud_aws/`**: SQL queries for AWS Cost and Usage Reports (CUR).
    *   **`cloud_azure/`**: SQL queries for Azure billing data.
    *   **`cloud_gcp/`**: SQL queries for Google Cloud Platform billing data.
    *   **`cloud_prod/`**: Miscellaneous production-related queries.
    *   **`README.md`**: A detailed index and explanation of the SQL queries within the `BigQuery/` directory.
*   **`dbt/`**: dbt project for transforming raw billing data into staging/intermediate models and analysis-ready marts (design docs under `dbt/design/`).
*   **`docs/`**: Schema references and usage guidance (primarily used as data-agent input), including `docs/multi-cloud-billing-core.md` and `docs/schema-data-json/`.
*   **`data-agent/`**: Next.js 14 web agent for generating and validating BigQuery SQL.
    *   **`src/app/`**: UI pages and API routes.
    *   **`src/components/`**: Reusable UI components.

## Getting Started

Refer to the `BigQuery/README.md` file for a comprehensive guide to the SQL queries, their purpose, and how they are organized. For billing dataset details and schema references, start with `docs/multi-cloud-billing-core.md` and `docs/schema-data-json/`.

For the web agent:

```bash
cd data-agent
make install
make dev
```
