# deveshpardhi/ai-business-analytics architecture

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

- Interactive diagram: https://gitdiagram.com/deveshpardhi/ai-business-analytics
- Repository: https://github.com/deveshpardhi/ai-business-analytics

## Overview

AI Business Analytics is a web application for uploading and profiling business datasets, running deterministic analyses, and reviewing, comparing, and exporting evidence-backed insights. Users upload a dataset in the React interface; backend routes validate and inspect it, then start a pipeline that plans and executes analyses before verifying, scoring, explaining, and recommending insights. Results and run history are persisted for later retrieval and export. Optional LLM explanations are separate from deterministic results. Several runtime connections are supported by the source index or README rather than full excerpts; those links are marked dashed where their exact call is unverified.

Main entry points: [`backend/app/services/analysis_pipeline.py`](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/analysis_pipeline.py) (Analysis orchestrator), [`backend/app/db/database.py`](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/db/database.py) (SQL database), [`backend/app/api/datasets.py`](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/api/datasets.py) (Dataset routes), [`backend/app/api/analysis_runs.py`](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/api/analysis_runs.py) (Run routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Analytics UI<br/>[App.jsx]"]
  node_client_api["API client<br/>[api.js]"]
end

subgraph group_api["API and persistence"]
  node_dataset_api["Dataset routes<br/>[datasets.py]"]
  node_run_api["Run routes<br/>[analysis_runs.py]"]
  node_database[("SQL database<br/>[database.py]")]
  node_dataset_model["Dataset records<br/>[dataset.py]"]
  node_run_model["Analysis run records<br/>[analysis.py]"]
end

subgraph group_analysis["Analysis pipeline"]
  node_pipeline["Analysis orchestrator"]
  node_validation["Validation<br/>[validator.py]"]
  node_pii["PII detection<br/>[pii_detector.py]"]
  node_profiling["Dataset profiling<br/>[profiler.py]"]
  node_semantics["Semantic detection"]
  node_planner["Analytics planning"]
  node_executor["Analytics execution"]
  node_discovery["Insight discovery"]
  node_timeseries["Time-series metrics"]
  node_verification["Insight verification"]
end

subgraph group_outputs["Insight outputs"]
  node_confidence["Confidence scoring"]
  node_scoring["Insight scoring<br/>[insight_scorer.py]"]
  node_selection["Insight selection"]
  node_explanation["Insight explanations"]
  node_llm["LLM provider<br/>[llm_client.py]"]
  node_recommendations["Recommendations"]
  node_exporter["Report export<br/>[report_exporter.py]"]
end

node_user(("Analyst"))
node_web["Web API"]

node_user -->|"uses"| node_app
node_app -->|"requests data"| node_client_api
node_client_api -.->|"calls API"| node_web
node_web -.->|"routes datasets"| node_dataset_api
node_web -.->|"routes runs"| node_run_api
node_dataset_api -->|"uses sessions"| node_database
node_dataset_api -->|"queries records"| node_dataset_model
node_dataset_api -.->|"starts analysis"| node_pipeline
node_run_api -->|"uses sessions"| node_database
node_run_api -->|"loads runs"| node_run_model
node_run_api -->|"builds exports"| node_exporter
node_pipeline -->|"validates data"| node_validation
node_pipeline -->|"scans sensitive data"| node_pii
node_pipeline -->|"profiles data"| node_profiling
node_pipeline -->|"infers semantics"| node_semantics
node_pipeline -->|"builds plan"| node_planner
node_pipeline -->|"executes analyses"| node_executor
node_pipeline -->|"discovers insights"| node_discovery
node_pipeline -->|"verifies insights"| node_verification
node_pipeline -->|"calculates confidence"| node_confidence
node_pipeline -->|"scores insights"| node_scoring
node_pipeline -->|"selects insights"| node_selection
node_pipeline -->|"explains ranked insights"| node_explanation
node_pipeline -->|"generates recommendations"| node_recommendations
node_explanation -->|"requests explanation"| node_llm
node_discovery -->|"uses metrics"| node_timeseries
node_verification -->|"uses metrics"| node_timeseries
node_llm -.->|"calls provider"| node_web
node_pipeline -.->|"persists run"| node_database
node_database -->|"maps records"| node_dataset_model
node_database -->|"maps records"| node_run_model

click node_app "https://github.com/deveshpardhi/ai-business-analytics/blob/main/frontend/src/App.jsx"
click node_client_api "https://github.com/deveshpardhi/ai-business-analytics/blob/main/frontend/src/api.js"
click node_dataset_api "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/api/datasets.py"
click node_run_api "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/api/analysis_runs.py"
click node_pipeline "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/analysis_pipeline.py"
click node_validation "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/validator.py"
click node_pii "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/security/pii_detector.py"
click node_profiling "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/profiler.py"
click node_semantics "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/semantic_detector.py"
click node_planner "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/analytics_planner.py"
click node_executor "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/analytics_executor.py"
click node_discovery "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_discovery.py"
click node_timeseries "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/time_series_metrics.py"
click node_verification "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_verifier.py"
click node_confidence "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/confidence_engine.py"
click node_scoring "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_scorer.py"
click node_selection "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_selector.py"
click node_explanation "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_explainer.py"
click node_llm "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/llm_client.py"
click node_recommendations "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/recommendation_engine.py"
click node_exporter "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/report_exporter.py"
click node_database "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/db/database.py"
click node_dataset_model "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/models/dataset.py"
click node_run_model "https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/models/analysis.py"

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_client_api toneBlue
class node_dataset_api,node_run_api,node_database,node_dataset_model,node_run_model toneAmber
class node_pipeline,node_validation,node_pii,node_profiling,node_semantics,node_planner,node_executor,node_discovery,node_timeseries,node_verification,node_web toneMint
class node_confidence,node_scoring,node_selection,node_explanation,node_llm,node_recommendations,node_exporter toneRose
class node_user toneIndigo
```

## Components

### Web client

- [Analytics UI](https://github.com/deveshpardhi/ai-business-analytics/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/deveshpardhi/ai-business-analytics/blob/main/frontend/src/api.js): `frontend/src/api.js`

### API and persistence

- [Dataset routes](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/api/datasets.py): `backend/app/api/datasets.py`
- [Run routes](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/api/analysis_runs.py): `backend/app/api/analysis_runs.py`
- [SQL database](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/db/database.py): `backend/app/db/database.py`
- [Dataset records](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/models/dataset.py): `backend/app/models/dataset.py`
- [Analysis run records](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/models/analysis.py): `backend/app/models/analysis.py`

### Analysis pipeline

- [Analysis orchestrator](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/analysis_pipeline.py): `backend/app/services/analysis_pipeline.py`
- [Validation](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/validator.py): `backend/app/services/validator.py`
- [PII detection](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/security/pii_detector.py): `backend/app/security/pii_detector.py`
- [Dataset profiling](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/profiler.py): `backend/app/services/profiler.py`
- [Semantic detection](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/semantic_detector.py): `backend/app/services/semantic_detector.py`
- [Analytics planning](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/analytics_planner.py): `backend/app/services/analytics_planner.py`
- [Analytics execution](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/analytics_executor.py): `backend/app/services/analytics_executor.py`
- [Insight discovery](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_discovery.py): `backend/app/services/insight_discovery.py`
- [Time-series metrics](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/time_series_metrics.py): `backend/app/services/time_series_metrics.py`
- [Insight verification](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_verifier.py): `backend/app/services/insight_verifier.py`

### Insight outputs

- [Confidence scoring](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/confidence_engine.py): `backend/app/services/confidence_engine.py`
- [Insight scoring](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_scorer.py): `backend/app/services/insight_scorer.py`
- [Insight selection](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_selector.py): `backend/app/services/insight_selector.py`
- [Insight explanations](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/insight_explainer.py): `backend/app/services/insight_explainer.py`
- [LLM provider](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/llm_client.py): `backend/app/services/llm_client.py`
- [Recommendations](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/recommendation_engine.py): `backend/app/services/recommendation_engine.py`
- [Report export](https://github.com/deveshpardhi/ai-business-analytics/blob/main/backend/app/services/report_exporter.py): `backend/app/services/report_exporter.py`

### Other components

- **Analyst**
- **Web API**

## Connections

- Analyst → Analytics UI: uses (evidence: `README.md`)
- Analytics UI → API client: requests data (evidence: `frontend/src/App.jsx`)
- API client → Web API: calls API (evidence: `README.md`)
- Web API → Dataset routes: routes datasets
- Web API → Run routes: routes runs
- Dataset routes → SQL database: uses sessions (evidence: `backend/app/api/datasets.py`)
- Dataset routes → Dataset records: queries records (evidence: `backend/app/api/datasets.py`)
- Dataset routes → Analysis orchestrator: starts analysis (evidence: `backend/app/api/datasets.py`)
- Run routes → SQL database: uses sessions (evidence: `backend/app/api/analysis_runs.py`)
- Run routes → Analysis run records: loads runs (evidence: `backend/app/api/analysis_runs.py`)
- Run routes → Report export: builds exports (evidence: `backend/app/api/analysis_runs.py`)
- Analysis orchestrator → Validation: validates data (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → PII detection: scans sensitive data (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Dataset profiling: profiles data (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Semantic detection: infers semantics (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Analytics planning: builds plan (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Analytics execution: executes analyses (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Insight discovery: discovers insights (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Insight verification: verifies insights (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Confidence scoring: calculates confidence (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Insight scoring: scores insights (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Insight selection: selects insights (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Insight explanations: explains ranked insights (evidence: `backend/app/services/analysis_pipeline.py`)
- Analysis orchestrator → Recommendations: generates recommendations (evidence: `backend/app/services/analysis_pipeline.py`)
- Insight explanations → LLM provider: requests explanation (evidence: `backend/app/services/insight_explainer.py`)
- Insight discovery → Time-series metrics: uses metrics (evidence: `backend/app/services/insight_discovery.py`)
- Insight verification → Time-series metrics: uses metrics (evidence: `backend/app/services/insight_verifier.py`)
- LLM provider → Web API: calls provider (evidence: `README.md`)
- Analysis orchestrator → SQL database: persists run (evidence: `backend/app/services/analysis_pipeline.py`)
- SQL database → Dataset records: maps records (evidence: `backend/app/models/dataset.py`)
- SQL database → Analysis run records: maps records (evidence: `backend/app/models/analysis.py`)
