# sayash42/ai-business-analyst architecture

> Architecture diagram of the GitHub repository sayash42/ai-business-analyst, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sayash42/ai-business-analyst
- Repository: https://github.com/sayash42/ai-business-analyst

## Overview

AI Business Analyst is a Streamlit application that turns business questions into validated SQL, database results, analytical findings, generated insights, and charts. The principal route is documented in the README and the main app’s references; SQL validation and execution ownership are visible in excerpts. The graph also preserves the separately implemented question analyzer and database-loading path. Some UI modules and prompt resources are present in the tree but their runtime wiring is not shown, so no connections to them are inferred.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Application"]
  node_app["Streamlit app"]
end

subgraph group_query["Question To SQL"]
  node_question_analyzer["Question analyzer"]
  node_sql_generator["SQL generator"]
  node_sql_validator["SQL validator"]
end

subgraph group_data["Data Access"]
  node_query_executor["Query executor"]
  node_database[("Business database")]
  node_data_loader["Database loader"]
  node_source_data["CSV business data"]
end

subgraph group_analysis["Analysis And Reporting"]
  node_analysis_engine["Analysis engine"]
  node_insight_generator["Insight generator"]
  node_visualization["Visualization engine"]
end

node_user(("Business user"))

node_user -->|"asks question"| node_app
node_app -->|"generates SQL"| node_sql_generator
node_app -->|"runs queries"| node_query_executor
node_app -->|"analyzes results"| node_analysis_engine
node_app -->|"generates insights"| node_insight_generator
node_app -->|"creates charts"| node_visualization
node_sql_generator -->|"validates SQL"| node_sql_validator
node_query_executor -->|"validates SQL"| node_sql_validator
node_query_executor -->|"queries"| node_database
node_data_loader -->|"reads CSVs"| node_source_data
node_data_loader -->|"loads tables"| node_database

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_user toneBlue
class node_question_analyzer,node_sql_generator,node_sql_validator toneAmber
class node_query_executor,node_database,node_data_loader,node_source_data toneMint
class node_analysis_engine,node_insight_generator,node_visualization toneRose
```

## Components

### Application

- **Streamlit app**

### Question To SQL

- **Question analyzer**
- **SQL generator**
- **SQL validator**

### Data Access

- **Query executor**
- **Business database**
- **Database loader**
- **CSV business data**

### Analysis And Reporting

- **Analysis engine**
- **Insight generator**
- **Visualization engine**

### Other components

- **Business user**

## Connections

- Business user → Streamlit app: asks question (evidence: `README.md`)
- Streamlit app → SQL generator: generates SQL
- Streamlit app → Query executor: runs queries
- Streamlit app → Analysis engine: analyzes results
- Streamlit app → Insight generator: generates insights
- Streamlit app → Visualization engine: creates charts
- SQL generator → SQL validator: validates SQL
- Query executor → SQL validator: validates SQL
- Query executor → Business database: queries
- Database loader → CSV business data: reads CSVs
- Database loader → Business database: loads tables
