Skip to content

NayaneshGupte/RAG-Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flux ⚑ - AI Email Automation

An intelligent customer support automation system using Retrieval-Augmented Generation (RAG) with multi-LLM support and real-time email processing.

🎯 Features

  • πŸ“§ Gmail Integration: Secure OAuth 2.0 authentication with automatic email monitoring
  • πŸ€– AI-Powered Responses: Automated email replies using RAG with multi-LLM fallback (Gemini, Claude)
  • πŸ“„ Knowledge Base: Web-based PDF upload and management with semantic search
  • πŸ“Š Real-Time Dashboard: Beautiful analytics with ApexCharts and live data updates
  • πŸ” Separated Auth: Clean architecture with distinct landing and dashboard experiences
  • 🌐 Multi-User Support: Isolated data per user with session-based authentication
  • ⚑ Sub-Second Processing: Lightning-fast email classification and response generation

πŸš€ Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Configure Environment

Create a .env file with required credentials:

# LLM Configuration
GOOGLE_API_KEY=your_gemini_api_key
ANTHROPIC_API_KEY=your_claude_api_key  # Optional fallback
LLM_PRIMARY_PROVIDER=gemini
LLM_FALLBACK_PROVIDERS=claude

# Vector Database
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX_NAME=your_index_name
VECTOR_DB_TYPE=pinecone

3. Setup Gmail OAuth

Follow the OAuth Setup Guide to configure Gmail API credentials.

4. Run the Application

# Start the web dashboard
python wsgi.py

# In another terminal, start the email agent
python run.py agent --poll-interval 60

Access the dashboard at http://127.0.0.1:5001

πŸ› οΈ Tech Stack

Backend

  • Python 3.12+
  • Flask - Web framework with Blueprint architecture
  • Multi-LLM Support: Gemini (primary), Claude (fallback)
  • Embeddings: Google Gemini Embeddings (embedding-004)
  • Vector DB: Pinecone (with abstraction for future providers)
  • Email: Gmail API with OAuth 2.0

Frontend

  • Vanilla JavaScript - No framework dependencies
  • ApexCharts - Beautiful, interactive charts
  • Flatpickr - Date range selection
  • Modern CSS - Glassmorphism, gradients, animations

Architecture

  • Application Factory Pattern - Scalable Flask setup
  • Provider System - Abstract LLM and Vector DB providers with automatic fallback
  • Separated Auth/Dashboard - Clean routing with / (landing) and /dashboard
  • Multi-User Isolation - Session-based auth with per-user data segregation

πŸ“š Documentation

🎯 Start Here

πŸ“– For Users

πŸ—οΈ For Developers

🎨 For AI Engineers

🌟 Key Capabilities

Email Processing

  • Automatic Classification: Intelligent email categorization using LLM
  • RAG-Enhanced Responses: Context-aware replies using knowledge base
  • Multi-User Isolation: Each user's data completely segregated
  • Domain Filtering: Configurable domain exclusion list

Dashboard

  • Real-Time Analytics: Email volume charts, category distribution
  • Custom Date Ranges: Flexible time period selection with Flatpickr
  • Activity Logs: Detailed processing history with filtering
  • Knowledge Base Viewer: Browse uploaded documents with pagination

Web Architecture

  • Landing Page (/): Unauthenticated landing with features showcase
  • Dashboard (/dashboard): Protected dashboard with metrics and charts
  • Client-Side Routing: Smart redirects based on auth status in auth.js
  • Auto-Refresh: Dashboard updates every 30 seconds

πŸ”§ Development

Project Structure

RAG-Demo/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/              # REST API routes
β”‚   β”œβ”€β”€ web/              # Web page routes
β”‚   β”œβ”€β”€ services/         # Business logic
β”‚   β”‚   β”œβ”€β”€ llm_providers/     # Multi-LLM system
β”‚   β”‚   β”œβ”€β”€ vector_db_providers/ # Vector DB abstraction
β”‚   β”‚   └── gmail/             # Gmail sub-services
β”‚   β”œβ”€β”€ static/
β”‚   β”‚   β”œβ”€β”€ css/          # Stylesheets
β”‚   β”‚   β”œβ”€β”€ js/           # Client-side logic
β”‚   β”‚   └── images/       # Static assets
β”‚   └── templates/        # Jinja2 templates
β”œβ”€β”€ docs/                 # Comprehensive documentation
β”œβ”€β”€ run.py               # CLI entry point
└── wsgi.py              # Web server entry point

Running Tests

pytest tests/

πŸ“Š Architecture Highlights

Multi-LLM Fallback

Gemini (primary) β†’ Claude (fallback) β†’ Exponential backoff retry
  • Automatic provider switching on quota errors (HTTP 429)
  • Configurable fallback chain via environment variables
  • Transparent to application code

Separated Auth Flow

/ (landing.html) ←→ /dashboard (dashboard.html)
         ↑                    ↑
         └─── auth.js β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              (redirects based on session)

Data Fetching Architecture

dashboard.js β†’ /api/metrics/summary β†’ Database
charts.js    β†’ /api/metrics/email-volume β†’ Database
             β†’ /api/metrics/categories β†’ Database

πŸŽ₯ Demo Videos

Screen.Recording.2025-11-22.at.5.38.33.PM.mov
Flux.-.Agent.2.mp4

🀝 Contributing

This is an educational project showcasing RAG implementation with production-ready patterns. Feel free to fork and extend!

πŸ“ License

MIT License


Last Updated: November 30, 2025
Architecture: Multi-LLM βœ… | Multi-Vector DB βœ… | Separated Auth/Dashboard βœ…

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published