Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AWS RAG Chatbot

Intelligent Documentation Assistant

A modern RAG (Retrieval-Augmented Generation) chatbot system that provides intelligent answers about AWS services using advanced AI technology, featuring document processing, semantic search, and a beautiful web interface.

Python Flask Next.js LangChain Ollama

🌟 Features

  • 🧠 Intelligent Q&A - Advanced RAG system for AWS documentation queries
  • οΏ½ Document Processing - Automated PDF parsing and text chunking
  • οΏ½ Semantic Search - Vector-based similarity search with ChromaDB
  • πŸ’¬ Modern Chat Interface - Elegant, responsive web UI with real-time chat
  • πŸ“Š Source Attribution - Detailed source references with confidence scores
  • ⚑ Local AI Models - Powered by Ollama for privacy and performance
  • 🎨 Beautiful UI - Glassmorphism design with smooth animations
  • οΏ½ Responsive Design - Works perfectly on desktop, tablet, and mobile

πŸ› οΈ Tech Stack

Backend: Python 3.8+, Flask, LangChain, ChromaDB
Frontend: Next.js 15, TypeScript, Tailwind CSS, React
AI/ML: Ollama, nomic-embed-text, Mistral LLM
Vector Database: ChromaDB with persistence
Document Processing: PyPDF, LangChain Text Splitters
API: RESTful API with CORS support

πŸ–ΌοΈ System Screenshots

RAG Chatbot Interface Chat Conversation Example

πŸ—οΈ RAG Architecture

The system follows a modern RAG (Retrieval-Augmented Generation) architecture:

Core Components

  • οΏ½ Document Loader - PDF processing and text extraction from AWS documentation
  • βœ‚οΈ Text Splitter - Intelligent chunking with overlap for context preservation
  • οΏ½ Embedding Function - Vector embeddings using nomic-embed-text model
  • πŸ—„οΈ Vector Database - ChromaDB for efficient similarity search
  • πŸ€– LLM Integration - Mistral model via Ollama for response generation
  • 🌐 Web Interface - Next.js frontend with real-time chat capabilities

Data Flow

  1. οΏ½ Document Ingestion - PDF documents are loaded and processed
  2. ⚑ Text Processing - Documents are split into overlapping chunks
  3. πŸ”’ Vectorization - Text chunks are converted to vector embeddings
  4. οΏ½ Storage - Vectors and metadata stored in ChromaDB
  5. οΏ½ Query Processing - User queries are embedded and matched against stored vectors
  6. πŸ€– Response Generation - Retrieved context is used to generate accurate responses
  7. οΏ½ UI Display - Results shown with sources and confidence scores

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 18+
  • Ollama installed locally
  • Git

Environment Setup

  1. Clone the repository
git clone https://github.com/Haythem532002/RAG-Chatbot.git
cd RAG-Chatbot
  1. Set up Python virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install Python dependencies
pip install -r requirements.txt
  1. Install and setup Ollama models
# Install Ollama (if not already installed)
curl -fsSL https://ollama.ai/install.sh | sh

# Pull required models
ollama pull nomic-embed-text
ollama pull mistral

Running the Application

Backend Setup

  1. Process your documents (one-time setup)
python load_data.py --reset
  1. Start the Flask backend
python flask_backend.py

The backend will be available at http://localhost:5000

Frontend Setup

  1. Navigate to frontend directory
cd rag-chatbot-frontend
  1. Install frontend dependencies
npm install
  1. Start the Next.js development server
npm run dev

The frontend will be available at http://localhost:3000

Quick Test

Test the system via command line:

python query_data.py "What is Amazon EC2?"

Or test the API directly:

curl -X POST http://localhost:5000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "What is AWS Lambda?"}'

Service Endpoints

πŸ“ Project Structure

RAG-Chatbot/
β”œβ”€β”€ data/                           # Source documents directory
β”‚   β”œβ”€β”€ AWS Certified Cloud Practitioner Slides v2.11.0.pdf
β”‚   └── aws-overview.pdf
β”œβ”€β”€ rag/                           # Project screenshots
β”‚   β”œβ”€β”€ Capture d'Γ©cran 2025-10-02 115121.png
β”‚   └── Capture d'Γ©cran 2025-10-02 140024.png
β”œβ”€β”€ chroma/                         # ChromaDB persistence directory
β”‚   └── [vector database files]
β”œβ”€β”€ rag-chatbot-frontend/          # Next.js frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                   # Next.js App Router
β”‚   β”‚   β”‚   β”œβ”€β”€ globals.css        # Global styles and animations
β”‚   β”‚   β”‚   β”œβ”€β”€ layout.tsx         # Root layout with metadata
β”‚   β”‚   β”‚   └── page.tsx           # Main chat page
β”‚   β”‚   └── components/
β”‚   β”‚       └── ChatInterface.tsx  # Main chat component
β”‚   β”œβ”€β”€ package.json
β”‚   └── tailwind.config.js
β”œβ”€β”€ load_data.py                   # Document processing and vectorization
β”œβ”€β”€ query_data.py                  # Query processing and RAG pipeline
β”œβ”€β”€ embedding_function.py          # Ollama embedding integration
β”œβ”€β”€ flask_backend.py               # REST API server
β”œβ”€β”€ requirements.txt               # Python dependencies
β”œβ”€β”€ venv/                          # Python virtual environment
β”œβ”€β”€ __pycache__/                   # Python cache files
β”œβ”€β”€ .git/                          # Git repository
β”œβ”€β”€ .gitignore                     # Git ignore file
└── README.md                      # Project documentation

πŸ”§ Configuration

Customization Options

  • πŸ“ Document Sources: Add your own PDFs to the data/ directory
  • 🎨 UI Themes: Modify Tailwind classes in globals.css
  • πŸ€– Models: Change embedding or LLM models in configuration
  • πŸ“Š Chunk Settings: Adjust chunk size and overlap for different document types
  • πŸ” Search Parameters: Modify similarity thresholds and result counts

πŸ“‘ API Reference

Chat Endpoint

POST /api/chat

{
  "message": "What is Amazon S3?"
}

Response:

{
  "response": "Amazon S3 (Simple Storage Service) is...",
  "sources": ["data/aws-overview.pdf:15:0", "data/aws-overview.pdf:16:1"],
  "context": [
    {
      "content": "Amazon S3 provides...",
      "source": "data/aws-overview.pdf:15:0",
      "score": 0.85,
      "page": "15",
      "file": "data/aws-overview.pdf"
    }
  ],
  "num_sources": 2,
  "query": "What is Amazon S3?",
  "status": "success"
}

Health Check

GET /

{
  "status": "healthy",
  "message": "RAG Chatbot API is running",
  "endpoints": {
    "chat": "POST /api/chat",
    "health": "GET /"
  }
}

πŸ§ͺ Testing

Run Embedding Tests

# Comprehensive embedding tests
python test_embeddings.py

# Quick functionality test
python quick_test.py

Test Individual Components

# Test document loading
python load_data.py

# Test query processing
python query_data.py "test query"

# Test embedding function
python -c "from embedding_function import create_embedding_function; print('Embeddings OK')"

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Install development dependencies (pip install -r requirements-dev.txt)
  4. Make your changes with proper tests
  5. Commit your changes (git commit -m 'Add AmazingFeature')
  6. Push to the branch (git push origin feature/AmazingFeature)
  7. Open a Pull Request

Development Guidelines

  • Follow PEP 8 for Python code
  • Use TypeScript for frontend development
  • Write tests for new features
  • Update documentation for API changes
  • Use conventional commits for clear history

οΏ½ Monitoring and Performance

  • ⚑ Response Times: Typical query response under 2-3 seconds
  • 🎯 Accuracy: High-quality responses with source attribution
  • οΏ½ Storage: Efficient vector storage with ChromaDB
  • πŸ” Search Quality: Semantic similarity matching with confidence scores
  • οΏ½ UI Performance: Optimized React components with smooth animations

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

πŸ™ Acknowledgments

  • 🦜 LangChain for the excellent RAG framework
  • πŸ€– Ollama for local AI model hosting
  • ⚑ Next.js for the amazing React framework
  • 🎨 Tailwind CSS for beautiful styling utilities
  • πŸ“Š ChromaDB for efficient vector storage

Built with ❀️ using Modern AI & RAG Architecture

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages