Skip to content

A complete full-stack Retrieval-Augmented Generation (RAG) system with modern web interface and intelligent backend, delivering specialized AI assistance across multiple domains.

Notifications You must be signed in to change notification settings

karanhimadri/RAG-Based-ChatBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– RAG Chatbot System - Intelligent Domain-Specific Assistant

FastAPI Next.js React Python Tailwind CSS Pinecone Google Gemini Cohere Redis Supabase

A complete full-stack Retrieval-Augmented Generation (RAG) system with modern web interface and intelligent backend, delivering specialized AI assistance across multiple domains.

πŸ“Έ Project Screenshots

Chat Interface

Chat Interface Modern, responsive chat interface with real-time messaging and typing indicators

RAG Backend Pipeline
Backend Architecture
Complete RAG pipeline architecture diagram
Authentication Page
Authentication System
Secure user authentication with Supabase integration
Citation Sources Panel
Source Citations Panel
Source citations and references for transparent AI responses

πŸš€ Project Highlights

Backend System

  • 🎯 Business Impact: Intelligent knowledge assistant across 5 critical domains (Agriculture, Education, Environment, Finance, Healthcare)
  • ⚑ Performance: Sub-second response times with real-time performance tracking
  • πŸ’° Cost Management: Smart credit-based usage control preventing API abuse
  • πŸ”’ Production-Ready: Secure API key management, CORS support, and scalable serverless architecture

Frontend Application

  • πŸ€– Multi-Domain AI Assistant: 5 specialized categories with domain-specific knowledge bases
  • πŸ’¬ Advanced Chat Interface: Real-time chat with typing indicators and message history
  • πŸ” User Authentication: Supabase integration with credit-based usage system
  • 🎨 Modern UI/UX: Built with Next.js 15, React 19, and Tailwind CSS
  • πŸ“± Responsive Design: Works seamlessly across desktop and mobile devices

πŸ—οΈ System Architecture

Core RAG Pipeline

  1. Query Embedding β†’ Cohere's embed-english-v3.0 converts queries to 1024-dim vectors
  2. Semantic Search β†’ Pinecone retrieves top-3 relevant documents with domain filtering
  3. Context Augmentation β†’ Retrieved documents provide contextual knowledge
  4. Response Generation β†’ Google Gemini 1.5 Flash generates human-like responses
  5. Metadata Enrichment β†’ Returns sources, confidence scores, and performance metrics

πŸ› οΈ Technology Stack

Frontend Technologies

  • Next.js 15 - React framework with App Router and dynamic routing
  • React 19 - Latest React with enhanced performance
  • Tailwind CSS - Utility-first CSS framework with dark/light theme support
  • Supabase - User authentication and management
  • LocalStorage - Message history persistence

Backend & API

  • FastAPI - High-performance async web framework
  • Python - Latest Python with enhanced performance
  • Pydantic - Data validation and serialization

AI & Machine Learning

  • Google Gemini 1.5 Flash - Large Language Model for response generation
  • Cohere v3.0 - State-of-the-art text embeddings
  • Custom System Instructions - Optimized prompts for consistent output

Data & Storage

  • Pinecone - Serverless vector database (AWS us-east-1)
  • Redis - Managed Redis for credit tracking
  • JSON Data Sources - Curated domain-specific knowledge bases
  • Supabase Database - User data and chat history storage

πŸ“Š Business Domains & Use Cases

Domain Use Cases Sample Query
🌾 Agriculture Farming practices, crop management, agricultural policies "What are the best drought-resistant crops for Indian farmers?"
πŸŽ“ Education Educational policies, curriculum, learning resources "What are the key features of India's National Education Policy 2020?"
🌍 Environment Climate policies, renewable energy, sustainability "What are India's commitments under COP26?"
πŸ’Ό Finance Economic policies, financial regulations, market insights "What are the latest RBI monetary policy changes?"
πŸ₯ Healthcare Health policies, medical guidelines, public health "What are India's vaccination strategies for rural areas?"

πŸ”§ Installation & Setup

Prerequisites

  • Node.js 18+ and npm/yarn
  • Python 3.12+
  • API Keys: Google Gemini, Cohere, Pinecone, Upstash Redis
  • Supabase project for authentication

Backend Setup

# Clone the repository git clone <repository-url> cd Rag_ChatBot_Backend # Install dependencies pip install -r requirements.txt # Set environment variables cp .env.example .env # Add your API keys to .env # Run the backend uvicorn main:app --reload

Frontend Setup

# Navigate to frontend directory cd rag-frontend # Install dependencies npm install # Set environment variables cp .env.local.example .env.local # Add your Supabase keys # Run the development server npm run dev

Environment Variables

Backend (.env)

GEMINI_API_KEY=your_gemini_api_key COHERE_API_KEY=your_cohere_api_key PINECONE_API_KEY=your_pinecone_api_key REDIS_URL=your_upstash_redis_url REDIS_TOKEN=your_upstash_redis_token

Frontend (.env.local)

NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key NEXT_PUBLIC_BACKEND_URL=http://localhost:8000

πŸ“ Project Structure

ChatBot/ β”œβ”€β”€ Rag_ChatBot_Backend/ # Backend API β”‚ β”œβ”€β”€ main.py # FastAPI application entry point β”‚ β”œβ”€β”€ requirements.txt # Python dependencies β”‚ β”œβ”€β”€ config/ β”‚ β”œβ”€β”€ embeddings/ β”‚ β”œβ”€β”€ llms/ β”‚ β”œβ”€β”€ response/ β”‚ └── sample_data/ └── rag-frontend/ # Next.js Frontend β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ app/ # Next.js App Router β”‚ β”‚ β”œβ”€β”€ layout.js # Root layout β”‚ β”‚ β”œβ”€β”€ page.js # Home page β”‚ β”‚ └── chat/ # Chat routes β”‚ β”œβ”€β”€ components/ # Reusable components β”‚ β”œβ”€β”€ context/ # React context providers β”‚ β”œβ”€β”€ lib/ β”‚ └── utils/ └── public/ # Static assets 

Developer Profile

Ready to discuss how this RAG system can solve your business challenges?


Built with ❀️ for intelligent information retrieval and enhanced user experiences. A complete full-stack solution combining cutting-edge AI with modern web technologies.

About

A complete full-stack Retrieval-Augmented Generation (RAG) system with modern web interface and intelligent backend, delivering specialized AI assistance across multiple domains.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published