Skip to content

harsh-pandhe/IIC-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

IIC Compliance Officer Bot πŸ›‘οΈ

An intelligent AI-powered chatbot for the Institution's Innovation Council (IIC) that provides instant answers about SOPs, rules, responsibilities, and compliance requirements. Built with RAG (Retrieval-Augmented Generation) architecture using LangChain, Pinecone, and Groq LLaMA 3.3.

Version License

✨ Features

Core Functionality

  • πŸ€– AI-Powered Q&A - Get instant answers about IIC SOPs and compliance rules
  • πŸ“š Vector Search - RAG architecture with Pinecone for accurate document retrieval
  • πŸ’¬ Streaming Responses - Real-time SSE streaming for smooth user experience
  • 🎯 Contextual Answers - Provides source documents for transparency
  • πŸ’‘ Follow-up Questions - Suggests related questions based on context

Authentication & Security

  • πŸ” JWT Authentication - Secure token-based authentication
  • πŸ‘₯ Role-Based Access - Administrator, Club Member, and Guest roles
  • πŸ›‘οΈ Rate Limiting - Multi-tier protection (Chat, Login, Learn, API)
  • πŸ”’ bcrypt Encryption - Secure password hashing

Admin Features

  • πŸ“Š Analytics Dashboard - Track queries, ratings, and response times
  • 🧠 /learn Command - Teach the bot new information dynamically
  • πŸ“ˆ Query Insights - Top questions, user activity, and performance metrics

User Experience

  • πŸŒ— Dark/Light Mode - Fully customizable theme with persistence
  • ⭐ Rating System - 5-star feedback on bot responses
  • πŸ“‹ Copy Responses - One-click clipboard copy
  • ⌨️ Keyboard Shortcuts - Ctrl+K (focus), Ctrl+L (clear chat)
  • πŸ“± Responsive Design - Mobile-optimized UI

πŸ› οΈ Tech Stack

Backend

  • Runtime: Node.js 25.2.1
  • Framework: Express.js 5.2.1
  • Database: MongoDB Atlas
  • Vector DB: Pinecone
  • AI/ML:
    • Groq LLaMA 3.3 70B (LLM)
    • HuggingFace BGE Embeddings
    • LangChain
  • Cache: Redis (optional fallback)
  • Auth: JWT + bcryptjs
  • Validation: express-validator
  • Logging: Winston

Frontend

  • Framework: Next.js 16
  • UI Library: React 19
  • Language: TypeScript 5
  • Styling: Tailwind CSS 4
  • Theme: next-themes 0.4.3

DevOps

  • Backend Hosting: Render.com
  • Frontend Hosting: Vercel
  • CI/CD: Git push auto-deploy

πŸ“¦ Installation

Prerequisites

  • Node.js >= 18.0.0
  • MongoDB Atlas account
  • Pinecone account
  • Groq API key
  • HuggingFace API key

Backend Setup

  1. Clone the repository
git clone https://github.com/harsh-pandhe/IIC-Bot.git
cd IIC-Bot/iic-bot-backend
  1. Install dependencies
npm install
  1. Create .env file
# Database
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/?appName=Cluster0

# AI Services
PINECONE_API_KEY=your_pinecone_key
PINECONE_INDEX_NAME=iic-compliance-docs
GROQ_API_KEY=your_groq_key
HF_API_KEY=your_huggingface_key

# Authentication
JWT_SECRET=your_jwt_secret_key

# Optional
REDIS_URL=redis://localhost:6379
FRONTEND_URL=http://localhost:3000
PORT=5000
NODE_ENV=production
  1. Start the server
npm start
# or for development
npm run dev

Frontend Setup

  1. Navigate to frontend
cd ../iic-bot-frontend
  1. Install dependencies
npm install
  1. Create .env.local file
NEXT_PUBLIC_API_URL=http://localhost:5000
  1. Start development server
npm run dev
  1. Build for production
npm run build
npm start

πŸš€ Deployment

Backend (Render)

  1. Push code to GitHub
  2. Create new Web Service on Render
  3. Connect GitHub repository
  4. Configure:
    • Build Command: npm install
    • Start Command: npm start
    • Branch: main
    • Root Directory: iic-bot-backend
  5. Add environment variables in Render dashboard
  6. Deploy!

Frontend (Vercel)

  1. Push code to GitHub
  2. Import project on Vercel
  3. Configure:
    • Framework Preset: Next.js
    • Root Directory: iic-bot-frontend
    • Build Command: npm run build
    • Output Directory: .next
  4. Add environment variables:
    • NEXT_PUBLIC_API_URL: Your Render backend URL
  5. Deploy automatically on git push

πŸ”‘ Default Credentials

Administrator Account

  • Username: admin
  • Password: cb394a138eace8ade809d0b95924f468
  • Permissions: Full access, Analytics, /learn command

Club Member Account

  • Username: user
  • Password: 94a582b27d0fc2607d1f400773b4ffe8
  • Permissions: Member SOPs access

⚠️ Security Note: Change these credentials in production!

πŸ“– Usage

Chat Commands

Regular Chat

What are the duties of the Student President?

Admin /learn Command

/learn John Smith is the new Technical Head of IIC

Keyboard Shortcuts

  • Ctrl+K (Cmd+K on Mac) - Focus input field
  • Ctrl+L (Cmd+L on Mac) - Clear chat history
  • Ctrl+Enter - Send message

API Endpoints

Authentication

POST /login
Body: { username, password }
Response: { token, user }

Chat (Streaming)

POST /chat/stream
Headers: { Authorization: Bearer <token> }
Body: { question, history?, sessionId? }
Response: SSE stream

Analytics (Admin)

GET /analytics
Headers: { Authorization: Bearer <token> }
Response: { totalQueries, avgRating, avgResponseTime, ... }

Health Check

GET /health
Response: { status, timestamp, version }

πŸ“Š Rate Limits

Endpoint Limit Window
Chat 20 requests 1 hour
Login 5 requests 15 minutes
/learn 10 requests 1 hour
API 100 requests 15 minutes

πŸ—οΈ Project Structure

IIC-Bot/
β”œβ”€β”€ iic-bot-backend/
β”‚   β”œβ”€β”€ config/          # Database, Redis, Logger configs
β”‚   β”œβ”€β”€ middleware/      # Auth, Rate limiting, Validation
β”‚   β”œβ”€β”€ models/          # MongoDB schemas
β”‚   β”œβ”€β”€ documents/       # SOPs and training documents
β”‚   β”œβ”€β”€ server.js        # Main Express app
β”‚   └── package.json
β”‚
β”œβ”€β”€ iic-bot-frontend/
β”‚   β”œβ”€β”€ app/             # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ page.tsx     # Main chat interface
β”‚   β”‚   β”œβ”€β”€ layout.tsx   # Root layout
β”‚   β”‚   └── globals.css  # Global styles
β”‚   β”œβ”€β”€ hooks/           # Custom React hooks
β”‚   β”œβ”€β”€ public/          # Static assets
β”‚   └── package.json
β”‚
β”œβ”€β”€ LICENSE              # MIT License
└── README.md            # This file

πŸ”’ Security Features

  • βœ… JWT token authentication with 7-day expiry
  • βœ… bcrypt password hashing (10 rounds)
  • βœ… 4-tier rate limiting
  • βœ… CORS origin whitelist
  • βœ… Input validation on all endpoints
  • βœ… Trust proxy for accurate rate limiting
  • βœ… Secure MongoDB connection
  • βœ… Environment variable protection

πŸ› Troubleshooting

Redis Warnings

Redis is optional. If you see "Redis error - falling back to no caching", the app will work fine without caching.

Build Errors

# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install

Authentication Issues

  • Verify JWT_SECRET is set
  • Check MongoDB connection string
  • Ensure user accounts exist in database

🀝 Contributing

This is a private project. For questions or issues, contact the repository owner.

πŸ“„ License

MIT License - See LICENSE file for details

πŸ™ Acknowledgments

  • Groq - Lightning-fast LLM inference
  • Pinecone - Vector database for semantic search
  • LangChain - RAG framework
  • Vercel - Frontend hosting
  • Render - Backend hosting

Built with ❀️ by Harsh Pandhe

πŸ”— Live Demo: https://iic-bot.vercel.app

About

πŸ›‘οΈ AI-powered IIC Compliance Officer chatbot with RAG architecture - Instant answers about SOPs, rules, and responsibilities using LLaMA 3.3, Pinecone & LangChain

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors