A Retrieval-Augmented Generation (RAG) pipeline built with LangChain and Groq, specialized as QuantumAI — an AI assistant dedicated exclusively to quantum mechanics and quantum entanglement topics. Features a FastAPI backend, a React frontend with a cutting-edge dark UI, and full Docker + cloud deployment support.
🧠 What It Does
This project implements a complete RAG system that:
1. Loads a domain-specific knowledge base (quantum entanglement text)
2. Splits and embeds the documents into a Chroma vector store
3. Retrieves the top-K most relevant chunks for a given query
4. Feeds the retrieved context + query into a Groq-hosted LLM via a FastAPI backend
5. Returns a grounded, in-scope answer through an interactive React chat UI
cd frontend && npm install && npm run build
cd ..
uvicorn main:app --host 0.0.0.0 --port 8000
# visit http://localhost:8000
🐳 Docker Details
The Dockerfile uses a two-stage build:
- Stage 1 (node:20-alpine): installs Node deps and runs npm run build
- Stage 2 (python:3.11-slim): installs Python deps, copies backend + React build
The final image serves everything from a single FastAPI process on one port. docker-compose.yml mounts a named volume (chroma_data) to persist the Chroma vector store across restarts.
bash # Useful commands docker compose up -d # run in background docker compose logs -f # tail logs docker compose down # stop docker compose up --build -d # rebuild after code changes
☁️ Deployment — HuggingFace Spaces
Live at: https://abhroneel-quantumai.hf.space
The app is deployed on HuggingFace Spaces (Docker SDK) with 16GB RAM on the free CPU Basic tier.
To redeploy after changes:
bash git add . git commit -m "your message" git push space master:main --force
HF Spaces auto-rebuilds on every push. Secrets (GROQ_API_KEY, HUGGINGFACEHUB_API_TOKEN) are set in Settings → Variables and Secrets.
🎨 Frontend Features
Feature
Details
Particle background
Animated canvas with 4-color (blue/cyan/violet/green) glowing nodes and gradient connections
Welcome screen
Floating atom icon + 6 suggested query chips
Collapsible sidebar
Chat history + model selector + temperature + context chunk sliders
Live config toolbar
Model, temp, and top-K editable directly in the input bar
Source chunks panel
Click "N sources" under any AI reply to expand retrieved context passages
Typing indicator
Animated dots with "Retrieving context…" label
Markdown rendering
Bold, inline code, headers, bullet lists all rendered natively
Live status indicator
Green/amber/red pulsing dot in the header
Neon design system
Deep navy base, electric blue/cyan/violet accents, gradient text, glowing borders
The LLM is constrained to act as QuantumAI — a strict domain-specific assistant defined in main.py. API keys never touch the frontend.
You are QuantumAI, an AI assistant exclusively dedicated to quantum mechanics and quantum information science. Knowledge scope: - Quantum entanglement theory, history, experimental evidence - Bell's theorem, Bell inequalities, EPR paradox - Quantum information science: teleportation, cryptography, computing - Quantum hardware: ion traps, superconducting qubits, photonic systems - Decoherence, entanglement entropy, quantum error correction Instructions: 1. If factual → use retrieved context only 2. If general physics → use model knowledge 3. If both → clearly separate sources 4. If out of scope → politely refuse
🧪 Sample Test Queries
Type
Query
Factual recall
"What is quantum entanglement?"
Multi-hop
"How do Bell's theorem and the EPR paradox relate?"
Application
"How is entanglement used in quantum cryptography?"
Misconception
"Can entanglement send information faster than light?"