Skip to content

Repository files navigation

RAGHost

Production-ready RAG chatbot platform — build, embed, and manage AI-powered bots with your own knowledge base.

Built from day one to handle thousands of users and bots without breaking a sweat — MongoDB Atlas connection pooling, Redis-backed Bull queues, per-IP rate limiting, gzip/brotli compression, and a horizontally scalable architecture that grows with you. AES-256 encrypted key storage, Firebase JWT auth, and a sharp neo-brutalism dashboard — deploy to Vercel + Render in under 10 minutes.

MIT License Node.js React Live Demo PRs Welcome Production Ready Redis Built for Scale

Live Demo · Report Bug · Request Feature


Live Deployments

Service URL Status
Frontend rag-host.vercel.app Vercel
Backend API raghost-pcgw.onrender.com Render

The backend may take 30–60 seconds to wake from sleep on Render's free tier.


Screenshots

Dashboard Bot Configuration
Dashboard Overview Bot Configuration
Manage all your AI bots from one place Powerful bot setup with templates
Knowledge Base Widget Customizer V2
Knowledge Base Widget Customizer
Upload & manage documents for RAG Live-preview widget with 9 customisation tabs
Analytics Dashboard Embed & Deploy
Analytics Embed Code
Real-time metrics & performance tracking One-click embed code for any website

Table of Contents


What is RAGHost?

RAGHost is a full-stack platform for building and deploying Retrieval-Augmented Generation (RAG) chatbots. Upload documents (PDF, TXT, DOCX, Markdown), connect your Pinecone index and Gemini API key, and get an embeddable chat widget you can drop on any website in seconds.

No infra management required — deploy the frontend to Vercel and the backend to Render with the included config files. Start free, scale when you need to — the architecture supports the journey from 1 user to 100,000+.

Engineered for large user bases — the entire backend is designed with scale in mind:

Layer What scales it
Database MongoDB Atlas with 2–50 connection pooling; add replica sets for read scaling
Caching Redis helpers (getCachedData / setCachedData) reduce DB hits for hot data
Async jobs 3 Bull queues (chat · embedding · analytics) offload heavy work off the request thread
Auth Firebase Authentication — scales to millions of users, zero maintenance
Vector search Pinecone — fully managed, scales to billions of vectors
API protection Per-IP rate limiting on every endpoint prevents abuse at any traffic level
Transport gzip/brotli compression cuts bandwidth 70–90% under load
Clustering ENABLE_CLUSTERING=true spawns one worker per CPU core

Redis and Bull queues activate automatically when REDIS_URL is set. Without it, the app runs synchronously — same code, zero config changes needed.


Features

Bot Management

  • Create multiple bots, each with its own knowledge base, system prompt, color theme, and API keys
  • Per-bot Pinecone + Gemini key storage (AES-256 encrypted at rest)
  • Collapsible sidebar dashboard — toggle between full and icon-only modes, state persisted across sessions

Knowledge Base

  • Upload PDF, TXT, DOCX, and Markdown files per bot
  • Documents chunked, embedded, and stored in your Pinecone index
  • Live upload progress tracking; reprocess or delete individual documents

Chat Widget Embed

  • Copy-paste HTML, React, Vue, or Vanilla JS embed snippets directly from the dashboard
  • Cloud-backed embed code version history (stored in MongoDB, restore any previous version)
  • A/B test copy generator — generate and compare multiple widget headline variants
  • Widget config options: botName, color, position, width, height, showAvatar, responsive, and more

Analytics Dashboard

  • Per-bot and global message count, session count, and user metrics
  • Activity over time visualized with Chart.js line charts
  • Top-performing bots leaderboard

User Profile

  • Edit display name and avatar (12 gradient presets)
  • Preferences synced to MongoDB
  • Account security — change Firebase password from within the app
  • Danger zone — full account deletion

Performance & Scaling

  • Designed for large user bases — multi-layer architecture ensures the platform stays fast as your user count and bot count grow
  • MongoDB connection pooling — 2–50 configurable connections; supports Atlas replica sets for horizontal read scaling
  • Redis caching layer (config/redis.js) — getCachedData / setCachedData / deleteCachedPattern reduce database pressure for frequently accessed data
  • Three Bull queues auto-start with Redis: chat-processing (50 jobs/s, exponential retry), embedding-processing (async doc chunking & vectorisation), analytics-processing (non-blocking metric writes)
  • CPU clusteringENABLE_CLUSTERING=true spawns one worker per core; double the cores, double the throughput
  • Per-IP rate limiting on every endpoint (configurable via env vars) — protects at any traffic scale
  • gzip/brotli compression (70–90% payload reduction), code-split React bundles (~200 KB gzipped)
  • Low-memory mode (ENABLE_LOW_MEMORY=true) fits 512 MB free tier; remove the flag and the same code runs on a 16 GB production server

Security & Auth

  • Firebase Authentication (email/password)
  • Password visibility toggle on all auth forms
  • Rate limiting, Helmet.js headers, CORS whitelist, input sanitization
  • AES-256 encryption for stored API keys

Developer Experience

  • Built-in 6-tab documentation view in the dashboard (Quick Start / Widget / API / Config / Examples / Help)
  • FAQ accordion with common troubleshooting answers
  • Terminal-style code blocks for all integration examples

Tech Stack

Frontend

Technology Version Purpose
React 18.2 UI framework
Vite 5.x Build tool
TailwindCSS 3.x Styling (neo-brutalism design system)
react-chartjs-2 + Chart.js 5.x / 4.x Analytics charts
Lucide React latest Icons
Firebase SDK 10.x Authentication client
React Router 6.x Client-side routing

Backend

Technology Version Purpose
Node.js 18+ Runtime
Express 4.x HTTP server
MongoDB / Mongoose 7.x Primary database
Firebase Admin SDK 12.x JWT verification
Pinecone SDK latest Vector search
Google Gemini AI latest LLM + embeddings
Multer 1.x File uploads
pdf-parse + Mammoth latest Document parsing
Helmet + Compression latest Security & performance
Redis (Upstash) 7+ Session caching, rate-limit state, Bull queue backend
Bull 4.x Async job queues (document processing)

Architecture

+------------------------------------------------------------------+
|                         RAGHost Platform                         |
|                                                                  |
|  +-----------------+    +----------------------------------+     |
|  |   Frontend      |    |         Backend (Express)        |     |
|  |  React + Vite   |<-->|                                  |     |
|  |  TailwindCSS    |    |  +----------+  +-------------+  |     |
|  |                 |    |  |   Auth   |  |  Knowledge  |  |     |
|  |  Dashboard      |    |  |(Firebase)|  |   Base API  |  |     |
|  |  Chat Widget    |    |  +----------+  +-------------+  |     |
|  |  Analytics      |    |  +----------+  +-------------+  |     |
|  |  Documentation  |    |  |   Bot    |  |    Chat     |  |     |
|  +-----------------+    |  | Manager  |  |    API      |  |     |
|                         |  +----------+  +-------------+  |     |
|  +-----------------+    +----------------------------------+     |
|  |  Embed Widget   |              |           |                  |
|  |  (Any Website)  |    +---------v---+ +-----v--------------+  |
|  +-----------------+    |   MongoDB   | |  Vector Database   |  |
|                         |  (Atlas)    | |   (Pinecone)       |  |
|                         +-------------+ +--------------------+  |
|                                               |                  |
|                                    +----------v----------+       |
|                                    |    Google Gemini AI |       |
|                                    |  (LLM + Embeddings) |       |
|                                    +---------------------+       |
+------------------------------------------------------------------+

Getting Started

Prerequisites

  • Node.js 18+ and npm
  • MongoDB Atlas account (free tier works)
  • Firebase project with Authentication enabled
  • Pinecone account and index (1536 dimensions, cosine metric — must match Gemini gemini-embedding-001)
  • Google Gemini API key

Installation

# Clone the repository
git clone https://github.com/pavankumar-vh/RAGHost.git
cd RAGHost

# Install backend dependencies
cd backend && npm install

# Install frontend dependencies
cd ../frontend && npm install

Pinecone Index Setup

When creating your Pinecone index, use these exact settings:

Setting Value Why
Dimensions 1536 Gemini gemini-embedding-001 output size
Metric cosine Best for semantic similarity search
Pod type Starter (free) Sufficient for most use cases

Warning: Using any dimension other than 1536 will cause uploads to appear successful but queries will return no results.


Environment Variables

Backend — backend/.env

NODE_ENV=development
PORT=5001

MONGODB_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/raghost

FIREBASE_PROJECT_ID=your-project-id
FIREBASE_CLIENT_EMAIL=firebase-adminsdk@your-project.iam.gserviceaccount.com
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"

# Generate with: npm run generate-key
ENCRYPTION_KEY=your-64-char-hex-key

# Comma-separated allowed origins
CORS_ORIGINS=https://your-frontend.vercel.app,http://localhost:5173

RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100

ENABLE_COMPRESSION=true
ENABLE_LOW_MEMORY=false

# Redis (optional) — enables Bull queues + caching helpers when set
# Get a free URL from https://upstash.com/ (format: rediss://default:<pw>@<host>:<port>)
# Omit entirely to run synchronously without cache
REDIS_URL=

Generate encryption key

cd backend && npm run generate-key

Firebase service account

  1. Firebase Console → Project Settings → Service Accounts
  2. Click Generate New Private Key and copy values to .env

Frontend — frontend/.env

VITE_API_URL=http://localhost:5001

VITE_FIREBASE_API_KEY=AIzaSy...
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=123456789
VITE_FIREBASE_APP_ID=1:123456789:web:abcdef

Get values from Firebase Console → Project Settings → General → Your Apps.


Running the App

Development

# Terminal 1 — Backend (http://localhost:5001)
cd backend && npm run dev

# Terminal 2 — Frontend (http://localhost:5173)
cd frontend && npm run dev

Production

cd frontend && npm run build   # output: frontend/dist/
cd backend && npm start        # or npm run start:low-memory for 512 MB

Deployment

Frontend — Vercel

cd frontend && npx vercel --prod

Or use the dashboard: import repo → Root Directory frontend → Build npm run build → Output dist → add VITE_* env vars → Deploy.

Backend — Render

New Web Service → connect repo → Build: cd backend && npm install → Start: cd backend && npm start → add env vars → Deploy.

Free tier (512 MB): set ENABLE_LOW_MEMORY=true and start with cd backend && npm run start:low-memory.


API Reference

Base URLs

Development:  http://localhost:5001
Production:   https://raghost-pcgw.onrender.com

Auth header

# Dashboard endpoints (Firebase JWT)
Authorization: Bearer <firebase_jwt_token>

# External API v1 endpoints (API key)
X-API-Key: rh_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Endpoints

# Bots
GET    /api/bots
POST   /api/bots
GET    /api/bots/:id
PUT    /api/bots/:id
DELETE /api/bots/:id

# Chat (public)
POST /api/chat/:botId/message
GET  /api/chat/:botId/history/:sessionId

# Knowledge Base
POST   /api/knowledge/:botId/upload
GET    /api/knowledge/:botId
DELETE /api/knowledge/:botId/:docId
POST   /api/knowledge/:botId/:docId/reprocess

# Analytics
GET /api/analytics/overview
GET /api/analytics/daily?days=30
GET /api/analytics/top-bots?limit=5
GET /api/analytics/bot/:botId?days=7

# Keys
GET  /api/keys/:botId
POST /api/keys/:botId

# Widget
GET /api/widget/:botId/embed-code

External API (v1) — Headless Access

Use RAGHost as a backend for your own custom UI. No widget or theme required — just API key authentication.

Setup

  1. Create a bot in the RAGHost dashboard
  2. Go to API KeysExternal API KeysGenerate Key
  3. Choose scopes: query (chat), upload (document upload), or both
  4. Copy the key (starts with rh_) — it's shown once

Query your bot (no widget needed)

curl -X POST https://your-backend/api/v1/query \
  -H "Content-Type: application/json" \
  -H "X-API-Key: rh_your_key_here" \
  -d '{"message": "What is your refund policy?", "sessionId": "user-123"}'

Response:

{
  "success": true,
  "data": {
    "response": "Our refund policy allows returns within 30 days...",
    "sessionId": "user-123",
    "responseTime": 1230,
    "contextUsed": 4,
    "tokensUsed": 285
  }
}

Upload documents from your app

curl -X POST https://your-backend/api/v1/documents/upload \
  -H "X-API-Key: rh_your_key_here" \
  -F "document=@./docs/faq.pdf"

All v1 endpoints

# Key management (Firebase auth — from dashboard)
POST   /api/v1/keys              # Generate API key for a bot
GET    /api/v1/keys/:botId       # List keys for a bot
DELETE /api/v1/keys/:keyId       # Revoke a key

# Headless query (API key auth, scope: query)
POST   /api/v1/query             # Send message, get AI response

# Headless document upload (API key auth, scope: upload)
POST   /api/v1/documents/upload          # Upload PDF/DOCX/TXT/MD/CSV
GET    /api/v1/documents/status/:jobId   # Check processing progress
GET    /api/v1/documents                 # List documents in knowledge base

Rate limits

Endpoint Limit Window
General API 100 req 15 min
Chat 30 msg 1 min
Knowledge upload 50 uploads 15 min
Auth 10 attempts 15 min

Error format

{ "success": false, "error": "message", "code": "ERROR_CODE" }

Security

Layer Implementation
Authentication Firebase JWT, per-request validation
API key storage AES-256 encryption
Transport HTTPS + HSTS (Helmet.js)
Rate limiting Per-IP on all endpoints
CORS Explicit whitelist only
Input Schema validation + sanitization
XSS / injection Helmet headers + Mongoose ODM

Contributing

  1. Fork → git checkout -b feat/your-feature
  2. Commit: git commit -m "feat: add X" (Conventional Commits)
  3. Push → open Pull Request

Commit types: feat · fix · docs · style · refactor · test · chore


License

MIT — see LICENSE.


Contact

Pavan Kumar VH · @pavankumar-vh · rag-host.vercel.app


Acknowledgments

Google Gemini AI · Pinecone · Firebase · MongoDB Atlas · Vercel · Render · Chart.js · TailwindCSS


Made with ❤️ by Pavan Kumar VH  ·  ⬆ Back to Top

About

Resources

Code of conduct

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages