๐ฎ An intelligent Business Intelligence assistant powered by AI, built with Python, LangChain, LangGraph, Ollama, and Streamlit.
Capstone Project: Enabling AI-Powered Business Intelligence for Organizations
InsightForge transforms business data into actionable insights using advanced AI technologies including Large Language Models (LLMs), Retrieval-Augmented Generation (RAG), and LangGraph orchestration. It enables organizations to:
- Analyze business data: Comprehensive analysis of sales, products, regions, and customers
- Generate insights: Natural language processing for actionable business recommendations
- Visualize insights: Interactive dashboards and AI-suggested visualizations
- Conversational interface: Chat-based queries with memory and context awareness
- Python 3.10+: Core programming language
- LangChain: LLM application framework
- LangGraph: Workflow orchestration and state management
- Ollama: Local LLM inference (llama3)
- Streamlit: Interactive web interface
- ChromaDB/FAISS: Vector storage and retrieval
- Plotly: Data visualization
- Pandas: Data processing and analytics
AI Powered BI/
โโโ src/ # Core application code
โ โโโ analytics.py # Business analytics functions
โ โโโ data_loader.py # Data loading and preprocessing
โ โโโ vectorstore.py # Vector store management
โ โโโ retriever.py # Hybrid retrieval system
โ โโโ pipeline.py # LangGraph pipeline (main logic)
โ โโโ prompts.py # Prompt templates
โ โโโ memory.py # Conversation memory
โ โโโ visualization.py # Chart generation
โโโ data/
โ โโโ raw/ # Raw input data (CSV/Parquet)
โ โโโ processed/ # Processed data
โ โโโ vectorstore/ # Vector embeddings
โโโ configs/
โ โโโ config.yaml # Application configuration
โโโ ui/streamlit/ # Streamlit interface
โ โโโ app.py # Main app with navigation
โ โโโ chat.py # Chat interface
โ โโโ dashboard.py # Analytics dashboard
โโโ scripts/ # Utility scripts
โ โโโ generate_sample_data.py
โ โโโ preprocess_data.py
โ โโโ build_vectorstore.py
โ โโโ evaluate_model.py
โโโ tests/ # Unit tests
โโโ docs/ # Documentation
โโโ notebooks/ # Jupyter notebooks (optional)
โโโ requirements.txt # Python dependencies
โโโ .env.example # Environment variables template
โโโ README.md # This file
- Python 3.10+ installed
- Ollama installed and running (Download Ollama)
- Git (optional, for cloning)
# Clone or navigate to project directory
cd "c:\AI Projects\AI Powered BI"
# Create virtual environment
python -m venv .venv
# Activate virtual environment
# Windows:
.venv\Scripts\activate
# Linux/Mac:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt# Copy environment template
cp .env.example .env
# Edit .env if needed (default values work for local Ollama)# Start Ollama service (if not running)
ollama serve
# In another terminal, pull the model
ollama pull llama3Option A: Use Sample Data (for testing)
python scripts/generate_sample_data.pyOption B: Use Your Own Data
- Place your CSV or Parquet files in
data/raw/ - Ensure data includes columns like: date, sales_amount, product_name, region, customer_segment
# Step 1: Preprocess raw data
python scripts/preprocess_data.py
# Step 2: Build vector store (may take a few minutes)
python scripts/build_vectorstore.py# Start Streamlit app
streamlit run ui/streamlit/app.pyThe app will open in your browser at http://localhost:8501
- Ask natural language questions about your business data
- Example queries:
- "What were the total sales last month?"
- "Which products are performing best?"
- "Show me sales trends by region"
- "Compare customer segments"
- Conversation memory maintains context across questions
- AI suggests appropriate visualizations
- Interactive filters (date range, region, product, segment)
- Real-time KPIs and metrics
- Pre-built visualizations:
- Sales trends over time
- Product performance rankings
- Regional analysis
- Customer segmentation
Run evaluation to assess model performance:
python scripts/evaluate_model.pyEvaluates:
- Grounding: Does the model cite actual data?
- Refusal accuracy: Does it refuse when data is unavailable?
- Intent detection: Does it understand user queries correctly?
- Numeric precision: Are numbers accurate?
Results saved to evaluation_results.csv
Run unit tests:
pytest tests/Expected columns (flexible, adjust as needed):
| Column | Type | Description |
|---|---|---|
| date | datetime | Transaction or period date |
| sales_amount | float | Revenue amount |
| quantity | int | Units sold |
| product_name | string | Product identifier |
| product_id | string/int | Product ID |
| category | string | Product category |
| region | string | Sales region |
| customer_id | string/int | Customer identifier |
| customer_segment | string | Customer type (Enterprise/SMB/Consumer) |
| customer_age_group | string | Age demographic |
| customer_gender | string | Gender demographic |
See docs/data_dictionary.md for details.
This project follows a structured approach covering:
- โ Data preparation and loading
- โ Knowledge base creation (vector store)
- โ LLM application development (analytics functions)
- โ RAG system implementation
- โ Chain prompts and prompt engineering
- โ Memory integration for context awareness
- โ Model evaluation (QAEvalChain concepts)
- โ Data visualization (multiple chart types)
- โ Streamlit UI (chat + dashboard)
Edit configs/config.yaml to customize:
- Ollama model and host
- Vector store parameters
- Retrieval settings (top_k, chunk_size)
- UI settings
Edit .env for:
- Ollama model name
- API endpoints
- Environment-specific settings
"Ollama connection error"
- Ensure Ollama is running:
ollama serve - Check connection:
curl http://localhost:11434 - Verify model is pulled:
ollama list
"No data found"
- Check
data/raw/has CSV/Parquet files - Run
python scripts/preprocess_data.py - Verify
data/processed/business_data.parquetexists
"Vector store error"
- Ensure preprocessing completed successfully
- Delete
data/vectorstore/and rebuild - Check Ollama model is available for embeddings
"Import errors"
- Activate virtual environment
- Reinstall:
pip install -r requirements.txt
- Add more data sources: Extend
data_loader.py - Custom analytics: Add functions to
analytics.py - New visualizations: Extend
visualization.py - Advanced prompts: Modify
prompts.py - Additional LLM providers: Replace Ollama with OpenAI/Anthropic
- Enhanced retrieval: Improve
retriever.pywith better filtering
Built for educational/capstone project purposes.
This is a capstone project. For production use, consider:
- Authentication and authorization
- Database integration (vs. file-based data)
- Caching and performance optimization
- Error handling and logging enhancements
- Deployment configuration (Docker, cloud platforms)
For issues or questions, refer to:
docs/folder for detailed documentation- Code comments in source files
- Streamlit "About" page for feature overview
InsightForge - Transforming Data into Intelligence ๐ฎ
Built with Python, LangChain, LangGraph, Ollama, and Streamlit