Skip to content

About

AI-Powered Business Intelligence Platform: An AI-powered analytics platform combining sales data intelligence with RAG-based document Q&A for real-time business insights using LLMs, FAISS, and Streamlit

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

AI-Powered Business Intelligence Platform

An AI-powered analytics platform that combines sales data intelligence with RAG-based document Q&A for real-time business insights — featuring LLM-generated recommendations, semantic search, and interactive dashboards.

Built as a portfolio project demonstrating skills in LLM integration, RAG systems, data engineering, and production-grade Python.


Architecture

┌─────────────────────────────────────────────────────────────────────────────┐
│                    AI-Powered Business Intelligence Platform                 │
└─────────────────────────────────────────────────────────────────────────────┘

  DATA SOURCES                    PROCESSING                    CONSUMERS
  ────────────────                ────────────────────────      ──────────────────
  sales_data.csv    ──┐
  (2,500+ records)    │
                      ├──► DataLoader
  PDF Documents:      │    (Preprocessing)
  · AI Business       │         │
  · BI Approaches     │         ▼
  · Time Series    ───┘   ┌──────────────┐
  · Walmart Sales         │ SalesAnalyzer │
                          │              │
                          │ · Trends     │
                          │ · Products   │
                          │ · Customers  │
                          │ · Seasonal   │
                          └──────┬───────┘
                                 │
                    ┌────────────▼────────────┐
                    │                         │
                    ▼                         ▼
           ┌──────────────┐         ┌──────────────────┐
           │ RAG Pipeline │         │  LLM Gateway     │
           │              │         │  (OpenAI GPT)    │
           │ · PDF Parse  │         │                  │
           │ · Chunking   │         │  · Sales Insights│
           │ · Embeddings │         │  · Document Q&A  │
           │ · FAISS Index│         │  · Recommendations│
           └──────┬───────┘         └────────┬─────────┘
                  │                          │
                  └────────────┬─────────────┘
                               │
                    ┌──────────▼──────────┐
                    │  Streamlit Dashboard │
                    │                      │
                    │  · KPI Metrics       │
                    │  · Trend Charts      │
                    │  · Product Analysis  │
                    │  · AI Chat Interface │
                    └──────────┬───────────┘
                               │
                    ┌──────────▼──────────┐
                    │   Safety Layer      │
                    │   · Logging         │
                    │   · Metrics         │
                    │   · Token Monitor   │
                    └─────────────────────┘


Tech Stack

Layer Technology
LLM OpenAI GPT-3.5/GPT-4 (chat completions API)
Embeddings Sentence Transformers (all-MiniLM-L6-v2)
Vector Store FAISS (Facebook AI Similarity Search)
Data Processing Pandas, NumPy (preprocessing, feature engineering)
PDF Processing PyPDF2, pdfplumber (text extraction)
Dashboard Streamlit + Plotly (interactive visualizations)
API Framework FastAPI (REST endpoints)
Observability Custom logging + metrics + token cost tracking
Containerization Docker + Docker Compose
CI/CD GitHub Actions (lint, test, build)
Testing pytest (unit + integration tests)
Config python-dotenv + pydantic

Project Structure

ai-powered-business-intelligence/
│
├── .github/
│   └── workflows/
│       └── ci.yml                    # GitHub Actions CI pipeline
│
├── api/
│   └── __init__.py                   # FastAPI REST endpoints
│
├── apps/
│   ├── dashboard/
│   │   └── main.py                   # Streamlit dashboard application
│   └── cli/
│       └── __init__.py               # Command-line interface
│
├── config/
│   └── settings.py                   # Centralized configuration
│
├── core/
│   ├── analytics/
│   │   ├── data_loader.py            # CSV ingestion + preprocessing
│   │   └── sales_analyzer.py         # Business intelligence analysis
│   └── orchestration/
│       └── __init__.py               # Workflow management
│
├── data/
│   ├── documents/                    # PDF research papers for RAG
│   │   ├── AI business model innovation.pdf
│   │   ├── BI approaches.pdf
│   │   ├── Time-Series-Data-Prediction.pdf
│   │   └── Walmarts sales data analysis.pdf
│   ├── embeddings/                   # Generated vector embeddings
│   ├── processed/                    # Processed datasets
│   └── raw/
│       └── sales_data.csv            # Source sales data (2,500+ rows)
│
├── deployment/
│   └── docker/
│       ├── Dockerfile                # Container image definition
│       └── docker-compose.yml        # Multi-service orchestration
│
├── docs/
│   ├── architecture.md               # System design documentation
│   ├── api_reference.md              # API endpoint reference
│   └── getting_started.md            # Setup guide
│
├── examples/
│   └── notebooks/                    # Jupyter notebook tutorials
│
├── knowledge/
│   ├── document_processor.py         # PDF parsing + chunking + indexing
│   └── __init__.py
│
├── llm/
│   ├── gateway.py                    # OpenAI API integration
│   ├── model_evaluator.py            # LLM response evaluation
│   └── __init__.py
│
├── logs/                             # Application log files
│
├── safety/
│   ├── logging_config.py             # Structured JSON logging
│   ├── metrics.py                    # Performance metrics collector
│   └── token_monitor.py              # LLM token usage + cost tracking
│
├── tests/
│   ├── unit/                         # Unit tests
│   ├── integration/                  # Integration tests
│   └── conftest.py                   # pytest fixtures
│
├── .env.example                      # Environment variable template
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── main.py                           # Application entry point
├── Makefile                          # Development commands
├── pyproject.toml                    # Modern Python packaging
├── README.md
└── requirements.txt


Data Model

Source: sales_data.csv

Sales transaction records with customer demographics.

Field Type Description
Date date Transaction date
Product string Product name (Widget A/B/C/D/E)
Sales float Transaction amount in USD
Region string Geographic region (North/South/etc)
Customer_ID int Unique customer identifier
Age int Customer age
Gender string Customer gender
Satisfaction float Customer satisfaction score (1-5)

Document Sources (RAG Knowledge Base)

Document Content
AI business model innovation.pdf AI-driven business transformation
BI approaches.pdf Business intelligence methodologies
Time-Series-Data-Prediction.pdf IoT + ML forecasting techniques
Walmarts sales data analysis.pdf Retail analytics case study

Key Metrics & Analysis

Analysis Type Metrics Computed
Sales Trends Total sales, growth rate, daily averages, peaks
Product Performance Top/bottom products, market share, revenue rank
Seasonal Patterns Monthly/quarterly trends, best/worst periods
Customer Behavior Segmentation, high-value customers, demographics
AI Insights LLM-generated recommendations, strategic advice

Setup

Prerequisites

  • Python 3.10+
  • (Optional) OpenAI API key for LLM features
  • (Optional) Docker for containerized deployment

1. Clone & install

git clone https://github.com/IFirstYou/ai-powered-business-intelligence.git
cd ai-powered-business-intelligence
pip install -r requirements.txt

2. Configure environment

cp .env.example .env
# Edit .env and fill in your values

OPENAI_API_KEY=sk-...
LOG_LEVEL=INFO

3. Run the dashboard

streamlit run apps/dashboard/main.py
# Opens at http://localhost:8501

4. Run with Docker

cd deployment/docker
docker-compose up -d
# Dashboard at http://localhost:8501
# API at http://localhost:8000

5. Run tests

pytest tests/ -v

Example Usage

Data Analysis

from core.analytics import DataLoader, SalesAnalyzer

# Load and preprocess data
loader = DataLoader("data/raw/sales_data.csv")
data = loader.preprocess_data()

# Analyze sales trends
analyzer = SalesAnalyzer(data)
trends = analyzer.analyze_sales_trends()
print(f"Total Sales: ${trends['total_sales']:,.2f}")
print(f"Growth Rate: {trends['sales_growth_rate']:.2f}%")

Document Intelligence (RAG)

from knowledge import DocumentProcessor

# Process PDF documents
processor = DocumentProcessor()
processor.process_pdf_documents("data/documents")
processor.build_index()

# Semantic search
results = processor.search_similar_documents(
    "What are best practices for business intelligence?",
    top_k=5
)

AI-Generated Insights

from llm import InsightGenerator

generator = InsightGenerator()

# Generate sales insights
insights = generator.generate_sales_insights(trends)

# Document Q&A
answer = generator.generate_document_insights(
    context=results[0]['chunk'],
    query="How does AI improve business decisions?"
)

# Strategic recommendations
recommendations = generator.generate_business_recommendations(analysis)

Observability

All components use structured JSON logging:

{
  "timestamp": "2026-04-07 14:23:01",
  "level": "INFO",
  "logger": "llm.gateway",
  "message": "Generated sales insights",
  "service": "ai-bi-platform",
  "tokens_used": 1250,
  "cost_usd": 0.0019,
  "elapsed_seconds": 2.4
}

Token usage tracking with budget alerts:

from safety import TokenMonitor

monitor = TokenMonitor(budget_limit=50.0)  # $50/month limit
usage = monitor.get_total_usage()
print(f"Total cost: ${usage['total_cost']:.2f}")
print(f"Requests: {usage['request_count']}")

License

MIT License. See LICENSE.

About

AI-Powered Business Intelligence Platform: An AI-powered analytics platform combining sales data intelligence with RAG-based document Q&A for real-time business insights using LLMs, FAISS, and Streamlit

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages