SeekAI-786/Pak_Constitution_chatbot
An AI-powered chatbot that answers questions about the Constitution of Pakistan using RAG (Retrieval Augmented Generation) with Pinecone vector database and Google Gemini.
Pakistan Constitution AI Chatbot
An AI-powered chatbot that answers questions about the Constitution of Pakistan using RAG (Retrieval Augmented Generation) with Pinecone vector database and Google Gemini.
๐๏ธ Project Structure
pak_constitution/
โโโ backend/ # FastAPI backend
โ โโโ backend.py # Main API server
โ โโโ requirements.txt
โ โโโ .env.example # Environment variables template
โโโ frontend/ # Next.js frontend
โ โโโ app/
โ โ โโโ page.tsx # Main chat page
โ โ โโโ contact/ # Contact page
โ โ โโโ layout.tsx
โ โ โโโ globals.css
โ โโโ package.json
โ โโโ ...config files
โโโ README.md
๐ Features
- RAG-based Q&A: Uses Pinecone for semantic search and Gemini for answer generation
- ChatGPT-style UI: Clean, modern interface with sidebar navigation
- Responsive Design: Works on desktop and mobile
- Pakistan Theme: Green color scheme inspired by Pakistan's flag
๐ ๏ธ Setup
Backend (FastAPI)
-
Navigate to backend folder:
cd backend -
Create virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Create
.envfile from example:cp .env.example .env
-
Add your API keys to
.env:PINECONE_API_KEY=your_pinecone_api_key GEMINI_API_KEY=your_gemini_api_key -
Run the server:
uvicorn backend:app --reload
Backend will be available at http://localhost:8000
Frontend (Next.js)
-
Navigate to frontend folder:
cd frontend -
Install dependencies:
npm install
-
Create
.env.localfile:NEXT_PUBLIC_API_URL=http://localhost:8000 -
Run development server:
npm run dev
Frontend will be available at http://localhost:3000
๐ Deployment
Backend on Railway
- Push to GitHub
- Connect Railway to your GitHub repo
- Add environment variables in Railway dashboard
- Deploy!
Frontend on Vercel
- Push to GitHub
- Import project in Vercel
- Set
NEXT_PUBLIC_API_URLto your Railway backend URL - Deploy!
๐ API Endpoints
-
POST /ask- Ask a question about the Constitution{ "question": "What are the fundamental rights?" } -
GET /health- Health check endpoint
๐ก๏ธ Tech Stack
- Backend: FastAPI, Pinecone, Google Gemini
- Frontend: Next.js 16, Tailwind CSS, TypeScript
- Vector DB: Pinecone (llama-text-embed-v2)
- LLM: Google Gemini 2.5 Flash
๐จโ๐ป Developed By
Echytech Solutions
Made with โค๏ธ for Pakistan