A full-stack RAG-based AI assistant grounded in 500K real Stack Overflow questions and 1.2M answers. Ask any programming question and get a synthesized answer with real Stack Overflow sources.
π Live Demo: stack-overflow-ai-assistant.vercel.app
User Query
β
Guardrail Check (tech or not?)
β
Embed query β Search FAISS (498K vectors)
β
Fetch real SO answers by question_id
β
Build context β Groq LLaMA 3.1
β
Synthesized answer + Source cards
| Path | Trigger | Response |
|---|---|---|
greeting |
"hi", "hello" | Friendly intro message |
rag |
Tech + found in dataset | Answer + 3 source cards |
general |
Tech + not in dataset | LLM answer from own knowledge |
no_answers |
Found questions but no answers | LLM general answer |
rejected |
Non-tech query | Polite rejection message |
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Vercel) β
β React + Tailwind CSS + Marked.js β
βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β POST /chat
βββββββββββββββββββββββΌββββββββββββββββββββββββββββ
β Backend (HuggingFace Spaces) β
β FastAPI β
β β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β RAG Pipeline β β
β β Guardrail β FAISS β AnswerFetcher β β
β β ContextBuilder β Groq LLaMA 3.1 β β
β βββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββΌββββββββββββββββββββββββββββ
β Data (HuggingFace Datasets) β
β questions.index β questions_docs.pkl β
β answers_cleaned.parquet β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
| File | Size | Description |
|---|---|---|
questions_cleaned.parquet |
~320 MB | 498,643 cleaned SO questions |
answers_cleaned.parquet |
~600 MB | 1,199,928 cleaned SO answers |
top_tags.parquet |
~1 KB | Top 30 SO tags with counts |
questions.index |
~730 MB | FAISS IVFFlat index |
questions_docs.pkl |
~400 MB | LangChain Documents with metadata |
Data Source: Google BigQuery public Stack Overflow dataset
Stratified sampling: Top 30 programming tags, 500K questions total
| Metric | Score |
|---|---|
| Top-1 Accuracy | 65.1% |
| Top-3 Accuracy | 84.7% |
| Top-5 Accuracy | 90.0% |
| Score Ranking Accuracy | 38.3% |
| Overall Accuracy | 79.9% |
ML / Data
sentence-transformersβ all-MiniLM-L6-v2 embeddings (384 dims)FAISSβ IVFFlat index for semantic searchLangChainβ Document ingestion and pipelineGroqβ LLaMA 3.1 8B for answer generationGoogle BigQueryβ Data extraction
Backend
FastAPIβ REST APIHuggingFace Spacesβ Deployment (Docker)HuggingFace Hubβ Data storage
Frontend
HTML/CSS/JavaScriptβ Chat interfaceTailwind CSSβ StylingMarked.jsβ Markdown renderingVercelβ Deployment
- Python 3.11+
- GROQ API key (free at console.groq.com)
- HuggingFace account
# Clone the repo
git clone https://github.com/retronoob99/stack-overflow-ai-assistant
cd stack-overflow-ai-assistant/backend
# Install dependencies
pip install -r requirements.txt
# Create .env file
echo "GROQ_API_KEY=your_groq_key_here" > .env
echo "VECTOR_STORE_PATH=../data/vector_store" >> .env
echo "ANSWERS_PATH=../data/answers_cleaned.parquet" >> .env
# Run the backend
python app.py# Open index.html directly in browser
# Or use Live Server in VS Code
# Update API URL in index.html to localhost
# Find: fetch("https://...hf.space/chat"
# Replace with: fetch("http://localhost:7860/chat"from huggingface_hub import hf_hub_download
# Download FAISS index
hf_hub_download(
repo_id="retronoob99/stackoverflow-ai-data",
filename="questions.index",
repo_type="dataset",
local_dir="data/vector_store"
)
# Download documents
hf_hub_download(
repo_id="retronoob99/stackoverflow-ai-data",
filename="questions_docs.pkl",
repo_type="dataset",
local_dir="data/vector_store"
)
# Download answers
hf_hub_download(
repo_id="retronoob99/stackoverflow-ai-data",
filename="answers_cleaned.parquet",
repo_type="dataset",
local_dir="data"
)stack-overflow-ai-assistant/
β
βββ backend/
β βββ app.py β FastAPI app + endpoints
β βββ rag_pipeline.py β RAG logic (AnswerFetcher, ContextBuilder, LLMCaller, Guardrail)
β βββ utils.py β EmbeddingManager, VectorStore, RAGRetriever
β βββ Dockerfile β HuggingFace Spaces deployment
β βββ requirements.txt
β
βββ frontend/
β βββ index.html β Full chat UI (HTML + CSS + JS)
β
βββ notebook/
β βββ vector_indexing_pipeline.ipynb β One-time embedding + FAISS setup
β βββ Data_Cleaning_EDA.ipynb β Data cleaning pipeline
β
βββ README.md
// Request
{
"query": "How do I reverse a list in Python?",
"top_k": 5
}
// Response
{
"answer": "You can reverse a list using [::-1]...",
"is_relevant": true,
"is_tech": true,
"sources": [
{
"rank": 1,
"question_id": 3940128,
"title": "How do I reverse a list or loop over it backwards?",
"primary_tag": "python",
"top_answers": ["To get a new reversed list..."]
}
],
"path": "rag"
}{
"status": "ok",
"pipeline_ready": true,
"total_vectors": 498643,
"total_answers": 1199928,
"model": "all-MiniLM-L6-v2",
"score_threshold": 0.5
}- Lewis et al. (2020) β Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
- Johnson et al. (2017) β Billion-scale similarity search with GPUs (FAISS)
- Reimers & Gurevych (2019) β Sentence-BERT
- Greco (2018) β A Behavior-Driven Recommendation System for Stack Overflow Posts
- Stack Overflow for the public dataset via Google BigQuery
- HuggingFace for free hosting
- Groq for blazing fast LLM inference
- Vercel for frontend deployment
MIT License β feel free to use, modify and build on this project.
