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.
┌─────────────────────────────────────────────────────────────────────────────┐
│ 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 │
└─────────────────────┘
| 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 |
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
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 | 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 |
| 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 |
- Python 3.10+
- (Optional) OpenAI API key for LLM features
- (Optional) Docker for containerized deployment
git clone https://github.com/IFirstYou/ai-powered-business-intelligence.git
cd ai-powered-business-intelligence
pip install -r requirements.txtcp .env.example .env
# Edit .env and fill in your values
OPENAI_API_KEY=sk-...
LOG_LEVEL=INFOstreamlit run apps/dashboard/main.py
# Opens at http://localhost:8501cd deployment/docker
docker-compose up -d
# Dashboard at http://localhost:8501
# API at http://localhost:8000pytest tests/ -vfrom 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}%")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
)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)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']}")MIT License. See LICENSE.