Lannon Khau

Business Intelligence SQL Analyst Team Playbook

Marketing Analytics Team
Lannon Khau

By Lannon Khau

· 5 min read
Analytics Team Orchestration Diagram
T his playbook is your guide to building a fully AI-powered analytics system that transforms raw business data into fast, actionable insights. By leveraging a modular β€œAI Data Science Team” of SQL and visualization agents, this repo makes it easy to:

  • Query your business database in plain English, no SQL needed
  • Get instant answers, charts, and summaries from GPT-4o and LangChain agents
  • Visualize and explain your data with flexible, plug-and-play AI modules
  • Run the whole workflow in your own secure cloud, using Flask, Streamlit, and AWS

🌐 Live Architecture

  • EC2: Flask backend with Gunicorn and Nginx
  • S3: Secure file storage for datasets
  • RDS (MySQL): Stores metadata and session logs
  • Lambda: Triggers OpenAI agents for data cleaning
  • Secrets Manager: Secure API key management
  • GitHub Actions: Handles CI/CD deployment

Backend

Flask Flask
Python Python
Gunicorn Gunicorn

Frontend

HTML HTML
Streamlit Streamlit
Jinja2 Jinja2
TailwindCSS TailwindCSS

AI Agents

OpenAI GPT-4o
AI Data Science Team AI Data Science Team
LangChain LangChain

Infrastructure

S3 S3
EC2 EC2
RDS RDS
Lambda Lambda
Secrets Manager Secrets Manager

CI / CD

GitHub Actions GitHub Actions

Each chapter guides you through designing and wiring up modular agentsβ€”so you can ask complex business questions in plain English and get back SQL, clean data, or beautiful visualizations instantly. Every step of the pipeline for your own business needs.

βœ… AI Agent Task Force

Data Visualization AI Agent Icon

Data Visualization

Business SQL Agent Icon

Business SQL Agent

Data Wrangling AI Agent Icon

Data Wrangling

Feature Engineering AI Agent Icon

Feature Engineering

πŸ“š Playbook Chapters

1. ML Lead Scoring (H2O)

Kick off with automated machine learning: train and deploy an H2O AutoML model to score your leads, helping sales and marketing prioritize with real predictive power.

2. Natural Language SQL Agent

Use LangChain + OpenAI to ask questions in plain English and get optimized SQL queries with real answersβ€”no manual SQL needed.

3. Orchestrating Agents with LangGraph

Build modular workflows as Directed Acyclic Graphs (DAGs), connecting agents together so your system is transparent, debuggable, and scalable.

4. From SQL to DataFrames and Visualization

Teach your agents to transform SQL results into Pandas DataFrames, and automatically decide when to display a chart or a table.

5. Charting Agent (Plotly + AI)

Let AI write and execute Python code that turns data into beautiful, interactive Plotly chartsβ€”on the fly, based on the user’s intent.

6. Modularization & Production

Wrap up all agents and workflows into reusable Python modulesβ€”plug and play for any future data pipeline or product.

7. Live Copilot Dashboard

Deliver a user-friendly, live dashboard with Streamlitβ€”powered by your agentic backend, with authentication, history, and live analytics.

8. Multi-Agent Teamwork

See how specialized agents (SQL, EDA, Charting) work as a teamβ€”ready to be extended with more business logic, analytics, or LLM-powered features.


"This is super cool! I remember struggling to bridge that gap between insights and code. A tool that shows the 'how' is a total game-changer for learning." - Tran Tien Van

πŸ“ Repository Structure

sql_agent_orchestration/
β”‚
β”œβ”€β”€ 01_machine_learning_h2o.py
β”œβ”€β”€ 02_sql_agent.py
β”œβ”€β”€ 03_sql_agent_langgraph.py
β”œβ”€β”€ 04_add_pandas_langgraph.py
β”œβ”€β”€ 05_add_routing_langgraph.py
β”œβ”€β”€ 06_add_plotting_langgraph.py
β”œβ”€β”€ 07_modular_bi_agent.py
β”œβ”€β”€ 08_streamlit_app_persistant_plot_and_df.py
β”œβ”€β”€ 09_streamlit_app_bi_copilot.py
β”œβ”€β”€ 10_ai_data_science_team.py
β”‚
β”œβ”€β”€ additional-requirements.txt
β”œβ”€β”€ credentials.yml
β”œβ”€β”€ README.md
β”‚
β”œβ”€β”€ business_intelligence_agent/       # BI agent Python package
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ leads_scored.db                # SQLite database
β”‚   β”œβ”€β”€ leads_scored.db-shm
β”‚   └── leads_scored.db-wal
β”œβ”€β”€ models/                            # ML models
β”œβ”€β”€ notebooks/                         # Jupyter notebooks
└── project2_architecture.drawio       # Project architecture diagram
                

πŸ“ Run Locally

git clone https://github.com/LannonTheCannon/Cloudberry_AWS_Bootcamp.git
cd Cloudberry_AWS_Bootcamp/Portfolio_V2
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 app.py