A production-grade, AI-augmented Data Analytics & SQL Intelligence platform designed for enterprise data teams and business analysts. Features natural language query generation via Google Gemini, automated dataset profiling with Health Scores (0-100%) and IQR outlier detection, a multi-format export engine (CSV, JSON, Excel, Markdown), time-series trend forecasting with linear regression and sqlglot, dynamic Recharts auto-visualization, interactive dashboard pinboards, and AES-256 encrypted database credential storage.
- Natural Language to SQL Engine: Ask complex analytical questions in plain English — Google Gemini generates executable SQL with complete schema context and conversation memory
- Spreadsheet & DB Ingestion: Drag & drop CSV/XLSX uploads with automatic type inference (INTEGER, FLOAT, TIMESTAMP, TEXT, BOOLEAN) and support for direct external database connections
- Read-Only SQL Execution Guardrails:
sqlglotAST parsing enforces strict security controls, rejecting any destructive operation (DROP,DELETE,UPDATE,INSERT,ALTER) with automaticLIMITclause injection - Session Memory & Context Awareness: Multi-turn conversation tracking that preserves dataset context across natural language queries
- Interactive Query Result Table: Paginated data grid with sorting, formatted numeric columns, and execution timing indicators
-
Automated Anomaly & Outlier Detection Engine: Statistical Z-Score (
$\sigma$ ) scanner identifying anomalous records across dataset attributes with customizable sensitivity sliders ($1.5\sigma - 4.0\sigma$ ) and severity classification (EXTREME,MODERATE,MILD) - Executive BI Report Generator: AI-synthesized executive briefings powered by Google Gemini, generating automated KPI scorecards, risk/growth category insights, strategic recommendations, and downloadable Markdown reports
- Automated Data Profiling & Health Scoring: Computes statistical column summaries, missingness percentages, distinct ratios, IQR (Interquartile Range) outlier bounds, and an overall dataset Health Score (0-100%) displayed with an SVG progress ring
- Guided Data Cleaning: Automated defect detection (nulls, duplicates, type mismatches, outliers) generating actionable, one-click cleaning suggestions with live visual diff previews before atomically modifying database tables
- Automated Exploratory Data Analysis (EDA): Comprehensive engine computing Pearson correlation matrices, dynamic Freedman-Diaconis histograms, categorical distributions, and pairwise scatterplots, summarized by a grounded Gemini AI executive narrative
- Multi-Format Analytics Export Engine: Instant streaming export of query results into CSV, JSON, Excel (.xlsx), and Markdown (.md) table files with client-side trigger integration
-
Trend & Forecast Prediction Engine: Linear regression analysis with
$R^2$ quality fit scoring, slope calculation, moving-average forward forecasting, and RechartsForecastChartdisplaying actual historical areas vs projected forecast lines -
Real-Time Metric Watchdog & Automated Alerting: Configurable threshold rules (
>,<,>=,<=,==) monitoring live dataset metrics across aggregations (AVG,SUM,MAX,MIN,COUNT) with real-time alert evaluation and severity badges (info,warning,critical) -
SQL Performance Optimizer & Query Plan Explainer: Powered by
sqlglotAST parsing, static analysis detects anti-patterns (SELECT *, missingLIMIT, non-sargableLIKE '%term', function wrappers inWHERE, cross joins), transpiles queries across dialects (SQLite, Postgres, Snowflake, BigQuery, DuckDB), and scores query complexity (1-100) - Automatic Chart Type Inference Engine: Rule-based heuristic analyzer that evaluates query result shapes (dates, numerical metrics, categories) to auto-select optimal chart types (Bar, Line, Area, Pie, Scatter, KPI)
- Saved Dashboard Pinboard: Pin visual chart cards from chat sessions directly onto interactive dashboards with automatic live SQL re-execution on page load
- AES-256 Credential Encryption: High-security Fernet encryption for external database credentials stored at rest
- Python 3.14 with FastAPI
- SQLAlchemy for ORM & database session management
- Pandas & NumPy for statistical profiling, IQR outlier detection, Z-Score anomaly analysis, and linear regression
- sqlglot for SQL AST parsing, read-only validation, linting, transpilation, and formatting
- openpyxl for native Excel workbook generation
- Pydantic v2 for strict schema validation
- Pytest for backend unit test suites (42/42 passing)
- Google Gemini AI for natural language translation to SQL and executive BI report synthesis
- React 19 with Next.js 16 App Router
- TypeScript for type safety across API boundaries
- Recharts for dark-mode financial & analytical chart visualizations
- Lucide React for consistent iconography
- Vanilla CSS Design System with CSS custom properties (variables) for sleek glassmorphism and theme consistency
graph TD
subgraph Client ["Frontend (Next.js 16 App Router)"]
UI["UI Components (Lucide / Glassmorphism)"]
Chat["Chat Explorer & SqlCodeViewer"]
Profiling["Data Quality & Health Score UI"]
ForecastUI["Forecast & Trend Visualizer"]
AlertsUI["Metric Watchdog Dashboard"]
ExportUI["ExportButton Multi-Format Exporter"]
end
subgraph Server ["Backend (FastAPI / Python 3.14)"]
Routes["APIRouter Aggregator (v1)"]
NL2SQL["NL-to-SQL Pipeline (Gemini AI)"]
Profiler["ProfilingService (IQR / Health Score)"]
Exporter["ExportService (CSV / JSON / XLSX / MD)"]
Forecaster["ForecastService (Linear Reg / MA)"]
Watchdog["AlertService (Metric Watchdog)"]
Optimizer["OptimizerService (sqlglot AST)"]
SQLValidator["SQL AST Security Guardrails"]
end
subgraph Storage ["Database & Execution"]
DB[(Metadata DB - SQLite/Postgres)]
DataEngine[(Analytics Database / SQLite Engine)]
end
UI <--> Routes
Chat <--> NL2SQL
Profiling <--> Profiler
ForecastUI <--> Forecaster
AlertsUI <--> Watchdog
ExportUI <--> Exporter
Routes --> SQLValidator
SQLValidator --> DataEngine
Profiler --> DataEngine
Forecaster --> DataEngine
Watchdog --> DataEngine
Optimizer --> sqlglot
graph LR
subgraph BE_Deps ["Backend Module Flow"]
API[api.py Router] --> Chat[Chat Endpoint]
API --> ProfileEP[Profiling Endpoint]
API --> ExportEP[Export Endpoint]
API --> ForecastEP[Forecast Endpoint]
API --> AlertEP[Alerts Endpoint]
API --> OptimizeEP[Optimizer Endpoint]
Chat --> Gemini[Gemini NL2SQL Service]
Chat --> Guardrails[sqlglot Validator]
ProfileEP --> Profiler[ProfilingService]
ExportEP --> Exporter[ExportService]
ForecastEP --> Forecaster[ForecastService]
AlertEP --> Watchdog[AlertService]
OptimizeEP --> Optimizer[OptimizerService]
end
subgraph FE_Deps ["Frontend Module Flow"]
Pages[Next.js App Pages] --> ChatPage[Chat Explorer]
Pages --> QualityPage[Quality / Profiling]
Pages --> TrendPage[Forecast / Trends]
Pages --> WatchdogPage[Alerts / Watchdog]
ChatPage --> SqlViewer[SqlCodeViewer]
SqlViewer --> OptimizerPanel[SqlOptimizerPanel]
ChatPage --> ExportBtn[ExportButton Dropdown]
QualityPage --> HealthMeter[HealthScoreMeter & ColumnProfileCard]
TrendPage --> ForecastChart[ForecastChart Recharts]
end
AI Data Analyst/
├── backend/
│ ├── app/
│ │ ├── api/v1/
│ │ │ ├── api.py # Aggregated v1 Router
│ │ │ └── endpoints/
│ │ │ ├── health.py # GET /health check
│ │ │ ├── upload.py # POST /upload (CSV/XLSX ingestion)
│ │ │ ├── datasets.py # GET /datasets, GET /datasets/{id}
│ │ │ ├── connect_db.py # POST /connect-db (external DBs)
│ │ │ ├── chat.py # POST /chat (NL-to-SQL pipeline)
│ │ │ ├── dashboards.py # CRUD /dashboards & card pinning
│ │ │ ├── profiling.py # GET /datasets/{id}/profile endpoint
│ │ │ ├── export.py # POST /export (CSV/JSON/XLSX/MD)
│ │ │ ├── forecast.py # GET /datasets/{id}/forecast
│ │ │ ├── alerts.py # CRUD /alerts & /evaluate endpoints
│ │ │ └── optimizer.py # POST /sql/optimize endpoint
│ │ ├── core/
│ │ │ ├── config.py # Pydantic BaseSettings configuration
│ │ │ ├── database.py # SQLAlchemy engine & session maker
│ │ │ └── security.py # AES-256 Fernet credential encryption
│ │ ├── models/
│ │ │ ├── dataset.py # DatasetModel SQLAlchemy schema
│ │ │ ├── chat_session.py # ChatSessionModel, ChatMessageModel
│ │ │ ├── dashboard.py # DashboardModel, DashboardCardModel
│ │ │ └── alert.py # AlertRuleModel SQLAlchemy schema
│ │ ├── schemas/
│ │ │ ├── dataset.py # Dataset Pydantic schemas
│ │ │ ├── chat.py # Chat Pydantic schemas
│ │ │ ├── dashboard.py # Dashboard Pydantic schemas
│ │ │ ├── profiling.py # ColumnProfile & DataQualityReport schemas
│ │ │ ├── forecast.py # ForecastPoint & ForecastResponse schemas
│ │ │ ├── alert.py # AlertRuleCreate & AlertEvalResult schemas
│ │ │ └── optimizer.py # SqlOptimizeRequest & SqlOptimizeResponse schemas
│ │ └── services/
│ │ ├── ingestion_service.py # CSV/XLSX ingestion & SQLite table creator
│ │ ├── db_introspection.py # DB schema inspection & encryption
│ │ ├── sql_validator.py # sqlglot AST read-only security validator
│ │ ├── nl_to_sql.py # Gemini prompt pipeline & conversation memory
│ │ ├── chart_generator.py # Auto chart-type inference engine
│ │ ├── profiling_service.py # Missingness analysis, IQR outliers & health score
│ │ ├── export_service.py # Multi-format byte stream exporter
│ │ ├── forecast_service.py # Linear regression & moving average forecaster
│ │ ├── alert_service.py # Metric watchdog threshold evaluator
│ │ └── optimizer_service.py # sqlglot SQL linting & transpiler engine
│ ├── tests/
│ │ ├── test_ingestion.py # 3 tests: CSV parsing, type mapping, sanitization
│ │ ├── test_db_introspection.py # 2 tests: credential encryption & decryption
│ │ ├── test_sql_validator.py # 5 tests: read-only guardrails & limit injection
│ │ ├── test_chart_generator.py # 3 tests: KPI, line, and bar chart inference
│ │ ├── test_profiling.py # 4 tests: Health score, nulls, IQR, duplicate detection
│ │ ├── test_export.py # 6 tests: CSV, JSON, XLSX, Markdown exports
│ │ ├── test_forecast.py # 4 tests: Trend direction, moving avg, labels, R²
│ │ ├── test_alerts.py # 5 tests: Alert operators, aggregates, thresholds
│ │ └── test_optimizer.py # 5 tests: SELECT *, missing LIMIT, LIKE, transpilation
│ └── requirements.txt
└── frontend/
├── app/
│ ├── page.tsx # Landing page with header & nav links
│ ├── chat/page.tsx # Interactive natural language chat explorer
│ ├── datasets/page.tsx # Dataset upload & connector manager
│ ├── dashboards/page.tsx # Saved dashboards gallery
│ ├── profiling/page.tsx # Data quality profiling & health score report
│ ├── forecast/page.tsx # Trend analysis & forecasting studio
│ └── alerts/page.tsx # Real-time metric watchdog & alert rule manager
├── components/
│ ├── charts/
│ │ ├── DynamicChart.tsx # Multi-type Recharts wrapper
│ │ ├── ChartCard.tsx # Dashboard pin wrapper
│ │ └── ForecastChart.tsx # Forecast & trend ComposedChart visualizer
│ ├── chat/
│ │ ├── ChatMessageList.tsx # User & AI message bubbles
│ │ ├── SqlCodeViewer.tsx # SQL viewer with Optimize SQL integration
│ │ ├── SqlOptimizerPanel.tsx # AST complexity & suggestion breakdown card
│ │ └── QueryResultTable.tsx # Tabular query result grid
│ ├── profiling/
│ │ ├── HealthScoreMeter.tsx # SVG circular progress meter
│ │ └── ColumnProfileCard.tsx # Expandable column stats & null bar indicator
│ └── shared/
│ ├── ExportButton.tsx # Multi-format download dropdown menu
│ └── PipelineLoader.tsx # Multi-stage step loader animation
├── lib/
│ ├── api-client.ts # Fetch wrapper with typed response helpers
│ └── utils.ts # Number formatting & duration utilities
└── types/
├── chat.ts # Chat message interfaces
├── dataset.ts # Dataset & table schema interfaces
├── dashboard.ts # Dashboard & card interfaces
├── profiling.ts # Column profile & data quality report types
├── forecast.ts # Forecast point & trend summary types
├── alert.ts # Alert rule & eval result interfaces
└── optimizer.ts # SQL optimization & suggestion interfaces
| Method | Path | Tag | Description |
|---|---|---|---|
| GET | /api/v1/health |
Health | Service health status check |
| POST | /api/v1/upload |
Upload | Ingest CSV or XLSX dataset with auto schema inference |
| GET | /api/v1/datasets |
Datasets | List all ingested & connected datasets |
| GET | /api/v1/datasets/{id} |
Datasets | Retrieve dataset schema and column definitions |
| POST | /api/v1/connect-db |
Database | Connect external database with AES-256 encrypted credentials |
| POST | /api/v1/chat |
Chat | Natural language to SQL query execution pipeline |
| GET | /api/v1/datasets/{id}/profile |
Profiling | Compute statistical profiling, missingness, IQR outliers & Health Score |
| GET | /api/v1/datasets/{id}/cleaning-suggestions |
Cleaning | Detect data quality issues and suggest one-click fixes |
| POST | /api/v1/datasets/{id}/clean |
Cleaning | Execute or preview (dry-run) a guided data cleaning operation |
| GET | /api/v1/datasets/{id}/cleaning-history |
Cleaning | Fetch audit log of applied data cleaning actions |
| GET | /api/v1/datasets/{id}/eda |
EDA | Fetch Automated EDA report and Gemini AI narrative summary |
| POST | /api/v1/datasets/{id}/eda/refresh |
EDA | Force re-compute Automated EDA metrics |
| POST | /api/v1/export |
Export | Stream query results in CSV, JSON, XLSX, or Markdown format |
| GET | /api/v1/datasets/{id}/forecast |
Forecast | Linear regression & moving average time-series forecasting |
| GET | /api/v1/alerts |
Alerts | List all configured metric alert rules |
| POST | /api/v1/alerts |
Alerts | Create a new metric watchdog threshold alert rule |
| DELETE | /api/v1/alerts/{id} |
Alerts | Delete an existing metric alert rule |
| POST | /api/v1/alerts/{id}/evaluate |
Alerts | Evaluate a single alert rule against live dataset metrics |
| POST | /api/v1/alerts/evaluate-all |
Alerts | Run batch evaluation across all active alert rules |
| POST | /api/v1/sql/optimize |
SQL Optimizer | AST static analysis, anti-pattern detection & dialect transpilation |
| GET | /api/v1/dashboards |
Dashboards | List saved BI dashboards |
| POST | /api/v1/dashboards |
Dashboards | Create a new dashboard container |
| POST | /api/v1/dashboards/{id}/cards |
Dashboards | Pin a chart card to a dashboard |
| GET | /api/v1/dashboards/{id} |
Dashboards | Retrieve dashboard with live SQL re-execution |
- Total Test Cases: 80 Passed / 80 Total (100% Success Rate)
- Modules Covered: 14 Test Modules (Including
test_cleaning_actions.py,test_cleaning_suggestions.py,test_eda_service.py,test_eda_narrative.pyand 10 others) - Execution Time: ~19.5 seconds for complete suite execution
- AST Parse Time: < 10ms via
sqlglot - Dialect Transpilation: Real-time conversion across SQLite, Postgres, Snowflake, BigQuery, DuckDB
- Static Analysis Rules: 5 anti-pattern checks (SELECT *, Missing LIMIT, Non-sargable LIKE, Function in WHERE, Cross Join)
- IQR Outlier Bounds: Computed in < 50ms for 100,000 rows using Pandas vectorized quantiles
- Data Health Score: Multi-factor weighted score calculation (Null penalty, Duplicate penalty, Outlier penalty)
- Streaming Speed: CSV/JSON/MD generated in < 20ms; native Excel (.xlsx) generated via
openpyxlin < 100ms for 10,000 rows
The data quality profiler evaluates every column in a dataset, analyzing data types, null counts, missingness percentages, distinct ratios, and min/max/mean/std-dev bounds. For numerical columns, it calculates Interquartile Range (IQR) bounds (
When the profiler detects defects, the Guided Cleaning engine recommends precise operations (e.g., median imputation, z-score winsorization, regex type casting). Before applying changes, it uses a non-destructive dry-run pipeline across in-memory pandas DataFrames to surface a JSON sample diff to the user. Once confirmed, changes are atomically mutated in the database (to_sql(if_exists="replace")) and permanently audit-logged.
The EDA engine automatically identifies relationships across the entire dataset without writing SQL. It computes Pearson correlation matrices, dynamic Freedman-Diaconis histograms for numeric distributions, and value-counts for categorical columns. Highly correlated features are rendered as heavily sampled X/Y scatter plots using Recharts. A Google Gemini AI service ingests these statistics to synthesize a deterministic, grounded executive narrative summarizing the dataset's characteristics.
Using sqlglot, the optimizer parses raw SQL queries into Abstract Syntax Trees (ASTs). It analyzes the tree structure to identify performance bottlenecks—such as unbounded queries missing a LIMIT clause, unnecessary SELECT * column pulls, or functions applied directly to filtering columns in WHERE clauses that prevent B-tree index lookup. It also formats raw queries into clean, standardized SQL and transpiles syntax to target dialects including PostgreSQL, Snowflake, BigQuery, and DuckDB.
The forecasting module analyzes time-series trends using linear regression and moving-average algorithms. It computes the regression line slope, percent change over time, and the coefficient of determination (ForecastChart with distinct styling for actual versus projected values.
The alerting service lets users define declarative monitoring rules on top of dataset metrics. Rules specify aggregate functions (AVG, SUM, MAX, MIN, COUNT), metric columns, comparison operators (>, <, >=, <=, ==), and threshold values. When executed, the watchdog queries live data, evaluates the rule condition, records evaluation timestamps, and surfaces alert states (triggered: true/false) with severity indicators (info, warning, critical).
- Python 3.11+ (Python 3.14 recommended) and Node.js 20+
- A Google Gemini API key (obtain from Google AI Studio)
cd backend
python -m pip install -r requirements.txt
# Create and configure environment file
cp .env.example .env
# Set GEMINI_API_KEY in .env
python main.py
# Server runs at http://localhost:8000
# OpenAPI Docs available at http://localhost:8000/api/v1/docscd frontend
npm install
npm run dev
# Frontend application runs at http://localhost:3000cd backend
python -m pytest tests/ -v
# 37/37 tests pass