Skip to content

Ratnesh-181998/agentic-bi-natural-language-querying

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Agentic BI SaaS: Enterprise Natural Language Analytics

Agentic BI Header

A Production-Grade Generative BI Platform Powered by LangGraph & Multi-Agent Orchestration

Python Streamlit FastAPI LangChain LangGraph License Git LFS


📑 Table of Contents


🌐🎬 Live Demo

🚀 Try it now:

  • Streamlit Profile -[Link]

  • 🌟 Project Demo Try the Live Application Here: Agentic BI SaaS Platform

  • Note: The live demo is hosted on Streamlit Cloud. It provides a full read-only experience of the platform, allowing you to ask queries and visualize data instantly.

  • UI Walkthrough

Project Demo Walkthrough


📖 Overview

Agentic BI SaaS is a next-generation Business Intelligence platform that replaces static dashboards with conversational analytics. Instead of manually filtering charts, users ask questions in plain English (e.g., "Show me the revenue trend for the East region in Feb 2026"), and a swarm of AI Agents collaborates to generate real-time SQL queries, execute them securely, and visualize the results.

Built for Enterprise Scalability, this project features a Service-Oriented Architecture (SOA) with a decoupled React-like UI (Streamlit) and a robust API Backend (FastAPI + LangGraph).


�️ System Architecture

This project leverages a Multi-Agent Swarm Architecture orchestrated by LangGraph. Each agent specializes in a distinct cognitive task, ensuring high accuracy and resilience.

Agentic BI Architecture Diagram

Core Agent Swarm (The "Brain")

  1. � Metadata Agent: Analysis user intent & schema mapping (Context-Aware).
  2. 🕸️ RAG Agent: Retrieves certified business definitions from Vector DB.
  3. 📝 SQL Agent: Generates dialect-specific SQL (SQLite/PostgreSQL) with 99% syntax accuracy.
  4. 🛡️ Impact Agent: Governance layer; predicts query cost & blocks destructive operations (DROP/DELETE).
  5. ⚙️ Execute Agent: Runs verified SQL in a sandboxed environment.
  6. 📊 BI Agent: synthesizes results into JSON configs for Front-end rendering.

🛠️ Tech Stack & Libraries

Component Technology Description
Frontend Streamlit Interactive UI with Tabs, Real-time Logs, and Plotly Charts.
Backend FastAPI High-performance Async REST API for Agent communication.
Orchestration LangGraph Stateful workflow management / Cyclic Graph for Agents.
LLM Framework LangChain Prompt engineering & Tool abstractions.
AI Models Groq (Llama 3) Ultra-fast inference for real-time SQL generation.
Memory Mem0 (mem0ai) Long-term user preference & session storage.
Database SQLite / SQLAlchemy and FAISS , VectorDB Relational data storage with ORM.
Task Scheduling APScheduler Background jobs and reporting.
Visualization Plotly Express Dynamic, interactive data visualizations.

🚀 Agentic BI SaaS: The Conversational Analytics

How businesses interact with data.Instead of navigating complex dashboards, users simply ask questions in natural language and AI swarm does the rest.

🎯 The Problem

Traditional BI tools require SQL expertise,static dashboard configurations, and constant IT dependency.Business users waste hours waiting for reports that could be answered instantly.

💡The Solution: Multi-Agent AI Architecture

I built an Enterprise-Grade Agentic BI Platform using cutting-edge AI orchestration. Here's how it works:

🧠 6-Agent Cognitive Swarm (LangGraph Orchestrated):

  1. Metadata Agent → Analyzes user intent & schema mapping
  2. RAG Agent → Retrieves certified business definitions from Vector DB
  3. SQL Agent → Generates production-ready SQL queries (99% accuracy)
  4. Impact Agent → Governance layer; blocks unsafe queries & PII exposure
  5. Execute Agent → Sandboxed SQL execution
  6. BI Agent → Synthesizes results into intelligent visualizations

🛠️ Tech Stack (Production-Grade)

AI/ML & NLP Layer:

  • LangGraph (Multi-Agent Orchestration)
  • LangChain (Prompt Engineering Framework)
  • Groq (Llama 3.3 - 70B) for ultra-fast inference
  • HuggingFace (Text embeddings & transformer models)
  • FuzzyWuzzy (NLP fuzzy string matching for typo-tolerant queries)
  • Mem0 (Long-term AI memory for user preferences)

Vector & Retrieval:

  • FAISS (Facebook AI Similarity Search - Vector DB)
  • RAG Pipeline (Retrieval Augmented Generation)
  • MCP (Model Context Protocol for agent-tool communication)

Backend:

  • FastAPI (Async REST API)
  • SQLAlchemy + SQLite/PostgreSQL
  • APScheduler (Background task management)

Frontend:

  • Streamlit/Next.js (Interactive UI with Real-time Agent Logs)
  • Plotly (Dynamic, responsive visualizations)

DevOps:

  • Docker-ready containers
  • CI/CD pipeline (GitHub Actions)

🔐Enterprise-Ready Features

  • Self-Healing Pipeline:Auto-corrects SQL errors using reflexion loops
  • Typo-Resilient:FuzzyWuzzy NLP handles misspelled queries intelligently
  • Semantic Search:FAISS-powered vector similarity for context retrieval
  • Governance:Built-in RBAC & PII detection
  • Memory:Learns user preferences across sessions
  • Scalability:SaaS & On-Prem deployment ready

🚀 Key Features

1. Natural Language to SQL

Type complex business questions like "Compare marketing ROI vs Sales for Top 5 products" and get instant charts. No SQL knowledge required.

2. Self-Healing AI Pipeline

The system uses LangGraph to implement Reflexion. If an agent generates invalid SQL, the Execute Agent feeds the error back to the SQL Agent for auto-correction.

3. Enterprise Governance (RBAC)

Built-in Impact Agent ensures security. It calculates "Query Cost" and blocks unauthorized access to sensitive PII columns or tables.

4. Long-Term Memory

Powered by mem0, the system "remembers" your preferred region, currency, and chart types across sessions.

5. Real-Time System Logs

A dedicated "System Logs" tab provides transparency. Watch the "Thought Process" of every agent in real-time (e.g., Metadata Agent identified 'Sales' table, Impact Agent approved query).


🖥️ UI Walkthrough (Application Tabs)

Tab 1: 🤖 Agentic BI Demo

The main workspace.

  • Chat Interface: Ask questions.
  • Dynamic Dashboard: Charts (Bar, Line, Pie) render automatically based on data type.
  • Reasoning Engine: View the "Why" behind the answer (Show SQL & Thinking).
image image image image image image image image image image image

Tab 2:ℹ️ About Project

  • Project Vision & Mission : Agentic BI SaaS is an enterprise-grade Business Intelligence platform powered by Agentic AI. Users can ask business questions in plain English, and the system intelligently converts them into trusted, governed, explainable insights.
  • To democratize data access within enterprises, reducing the dependency on data analyst teams for routine reporting.
  • 🚀 AI Analyst , 🧠 Long-Term Memory ,🔐 Enterprise Gov
  • In simple words: This system replaces manual BI dashboards with an AI analyst that remembers, learns, and scales securely.
image image image image image image

Tab 3: 🛠️ Tech Stack & Specs

Detailed documentation of the libraries used.

  • Interactive badges for every tool.
  • Explanation of RAG (Retrieval Augmented Generation) implementation.
image image image image

Tab 4: 📐 HLD & LLD

  • 📐 Design & Architecture Specification : Comprehensive documentation covering Software Requirements (SRS), High-Level Design (HLD), and Low-Level Design (LLD).
  • 📝 1. Software Requirements Specification (SRS) -m🏗️ 2. High Level Design (HLD)
  • ⚙️ 3. Low Level Design (LLD)
image image image image image

Tab 5: 📊 Architecture & Design

  • High-Level Design (HLD) & Low-Level Design (LLD).
  • Interactive Graphviz flowcharts showing data movement between Frontend -> API -> Database.
image image image image image image

Tab 6: 📋 System Logs

  • Live Event Feed: See backend logs in the frontend.
  • Filters: Filter by Error, Success, or specific Agent.
  • Export: Download logs as CSV or TXT for auditing.
image image image

⚙️ Installation & Setup

Prerequisites

  • Python 3.10+
  • Git

1. Clone the Repository

git clone https://github.com/Ratnesh-181998/agentic-bi-natural-language-querying.git
cd agentic-bi-natural-language-querying/agentic-bi-saas

2. Install Dependencies

pip install -r requirements.txt

3. Configure Environment

Create a .env file in the root directory:

GROQ_API_KEY="your_groq_api_key"
OPENAI_API_KEY="optional_if_using_openai"
SIMULATION_MODE=False

4. Seed the Database

Populate the SQLite database with synthetic enterprise data (Sales, CRM, Inventory):

python seed_db.py

5. Run the Application

The app requires both the Backend (FastAPI) and Frontend (Streamlit) to run.

Terminal 1 (Backend):

uvicorn app.main:app --port 8000 --reload

Terminal 2 (Frontend):

streamlit run ui/presentation_app.py

Access the app at http://localhost:8501


☁️ Deployment Guide

Option 1: Streamlit Cloud (Recommended)

  1. Fork this repo to your GitHub.
  2. Login to share.streamlit.io.
  3. "New App" -> Select Repository.
  4. Main File Path: agentic-bi-saas/ui/presentation_app.py.
  5. Advanced Settings (Secrets): Paste your .env contents here.
  6. Deploy! 🚀

Option 2: Docker (Production)

The project is container-ready.

Dockerfile:

FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
EXPOSE 8501 8000
CMD sh -c "uvicorn app.main:app --host 0.0.0.0 --port 8000 & streamlit run ui/presentation_app.py --server.port 8501"

Build & Run:

docker build -t agentic-bi .
docker run -p 8501:8501 -p 8000:8000 --env-file .env agentic-bi

CI/CD Pipeline (GitHub Actions)

Automate testing and deployment to AWS/GCP.

.github/workflows/deploy.yml

name: Deploy to Cloud
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          lfs: true # Important for Large Files
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'
      - name: Install Dependencies
        run: |
          pip install -r agentic-bi-saas/requirements.txt
      - name: Run Tests
        run: |
          cd agentic-bi-saas
          python -m pytest tests_scripts/

📄 License

Distributed under the Apache 2.0 License. See LICENSE for more information.


📞 CONTACT & NETWORKING 📞

💼 Professional Networks

LinkedIn GitHub X Portfolio Email Medium Stack Overflow

🚀 AI/ML & Data Science AI/ML 1620+ Problem Solved

Streamlit HuggingFace Kaggle

LeetCode HackerRank CodeChef Codeforces GeeksforGeeks HackerEarth InterviewBit


📊 GitHub Stats & Metrics 📊

Profile Views

GitHub Streak Stats


Typing SVG

Footer Typing SVG

About

Agentic BI SaaS platform for natural language analytics using LangGraph, LangChain, LLMs (OpenAI, LLaMA, Mixtral), RAG with FAISS/Chroma, SQL & BI agents, MCP tools, and long-term AI memory (mem0). Built with FastAPI, Streamlit, Plotly, SQLAlchemy, PostgreSQL,Docker,Kubernetes,governance, lineage, RBAC,usage-based billing,SaaS & on-prem deployment.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages