{"id":49732680,"url":"https://github.com/govinddwivedi-git/chatbot-for-students-queries","last_synced_at":"2026-05-09T06:41:25.249Z","repository":{"id":274167109,"uuid":"922113472","full_name":"govinddwivedi-git/chatbot-for-students-queries","owner":"govinddwivedi-git","description":"An interactive chatbot system designed to help resolve student queries efficiently. The system features both user and admin interfaces, allowing for dynamic query handling and response management.","archived":false,"fork":false,"pushed_at":"2026-04-17T18:49:33.000Z","size":30504,"stargazers_count":8,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-17T20:36:57.472Z","etag":null,"topics":["flask","python","rag","reactjs"],"latest_commit_sha":null,"homepage":"https://chatbot-for-students-queries.vercel.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/govinddwivedi-git.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-25T10:59:25.000Z","updated_at":"2026-04-17T18:49:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"a0241d77-a336-43f5-8feb-da744549acb7","html_url":"https://github.com/govinddwivedi-git/chatbot-for-students-queries","commit_stats":null,"previous_names":["govinddwivedi-git/chatbot-for-students-queries"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/govinddwivedi-git/chatbot-for-students-queries","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/govinddwivedi-git%2Fchatbot-for-students-queries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/govinddwivedi-git%2Fchatbot-for-students-queries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/govinddwivedi-git%2Fchatbot-for-students-queries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/govinddwivedi-git%2Fchatbot-for-students-queries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/govinddwivedi-git","download_url":"https://codeload.github.com/govinddwivedi-git/chatbot-for-students-queries/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/govinddwivedi-git%2Fchatbot-for-students-queries/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32810373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","python","rag","reactjs"],"created_at":"2026-05-09T06:41:22.064Z","updated_at":"2026-05-09T06:41:25.239Z","avatar_url":"https://github.com/govinddwivedi-git.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Student Query Resolution Chatbot\n\nAn intelligent AI-powered chatbot system designed to help resolve student queries efficiently using **Retrieval-Augmented Generation (RAG)** technology. The system features both user and admin interfaces, allowing for dynamic query handling, AI-powered responses, and comprehensive query management with cloud storage integration.\n\n## 🚀 Key Features\n\n### 🤖 AI-Powered Query Resolution\n- **RAG (Retrieval-Augmented Generation)** for intelligent responses\n- **Google AI (Gemini)** integration for natural language processing\n- **LangChain** framework for advanced language processing\n- **Pinecone** vector database for semantic search and embedding storage\n- **PDF document processing** for knowledge base creation with Cloudinary integration\n\n### 🔐 User Authentication System\n- Secure user signup and login\n- JWT-based authentication with session management\n- Password encryption using Bcrypt\n- Admin authentication with role-based access\n\n### 💬 Advanced Query Management\n- Real-time AI-powered query responses\n- Automatic query storage and categorization\n- Historical query search and analytics\n- Unanswered query tracking for admin review\n\n### 🎛️ Comprehensive Admin Dashboard\n- Dedicated admin login system\n- Query analytics and statistics\n- Manage unanswered queries with bulk operations\n- Add and update responses manually\n- PDF management with Cloudinary integration\n- One-click embedding rebuilding for knowledge base updates\n- Email notification system for critical queries\n- Chat history management\n\n### 📧 Email Integration\n- Automated email notifications\n- Admin alerts for unanswered queries\n- Test email functionality for system verification\n\n### ☁️ Cloud Storage Integration\n- Cloudinary PDF storage for document management\n- PDF preview with Google Docs viewer\n- Original filename preservation\n- Public/private access management\n\n## 🛠️ Technology Stack\n\n### Backend (Flask)\n- **Flask 2.3.3** - Modern Python web framework\n- **Flask-CORS** - Cross-Origin Resource Sharing support\n- **Gunicorn** - WSGI HTTP Server for production deployment\n- **MongoDB with PyMongo** - NoSQL database for scalable data storage\n- **Google AI (Gemini)** - Advanced language model integration\n- **LangChain** - AI application framework\n- **Pinecone** - Vector database for production-ready RAG systems\n- **Cloudinary** - Cloud-based PDF storage and management\n- **Flask-Mail** - Email service integration\n- **JWT** - Secure token-based authentication\n- **Flask-CORS** - Cross-origin resource sharing\n\n### Frontend (React + Vite)\n- **React 18.3.1** - Modern UI library\n- **Vite** - Fast build tool and dev server\n- **Tailwind CSS** - Utility-first CSS framework\n- **ShadCN/UI** - Modern component library\n- **React Router** - Client-side routing\n- **Axios** - HTTP client for API communication\n- **Lucide React** - Beautiful icons\n\n### AI \u0026 ML Stack\n- **Google AI API** - Generative AI responses\n- **LangChain Community** - Extended AI capabilities\n- **Pinecone** - Managed vector database for production RAG deployments\n- **TextBlob** - Text processing and analysis\n- **PyPDF2** - PDF document processing\n- **ReportLab** - PDF generation for Q\u0026A documents\n- **Cloudinary SDK** - Cloud storage API integration\n\n## 📡 API Endpoints\n\n### 🔐 Authentication\n```http\nPOST /api/signup              # Register new user\nPOST /api/login               # User login  \nPOST /api/admin/login         # Admin authentication\n```\n\n### 💬 Chat \u0026 Query Management\n```http\nPOST /api/query               # Submit query (AI-powered response)\nGET  /api/chat-history        # Retrieve user chat history\nPOST /api/add-response        # Add manual response to query\n```\n\n### 🎛️ Admin Management\n```http\nGET  /api/admin/stats         # Get system statistics\nGET  /api/admin/chat-history  # Get all chat history (admin)\nGET  /api/admin/query-analytics # Get query analytics\nGET  /api/unanswered-queries  # Get pending queries\nDELETE /api/delete-query/\u003cid\u003e # Delete specific query\n```\n\n### 📄 PDF Management\n```http\nGET  /api/pdfs/               # List all PDFs\nPOST /api/pdfs/upload         # Upload a PDF file\nDELETE /api/pdfs/\u003cpublic_id\u003e  # Delete a PDF\nPOST /api/pdfs/rebuild-embeddings # Rebuild embeddings from PDFs\n```\n\n### 🔍 System Endpoints\n```http\nGET  /health                  # Health check\nGET  /debug/routes            # List all available routes\nGET  /debug/email             # Test email service\nPOST /debug/send-test-email   # Send test email\n```\n\n## 🚀 Getting Started\n\n### Prerequisites\n- **Python 3.8+** (recommended 3.10+)\n- **Node.js 16+** and npm\n- **MongoDB Atlas** account or local MongoDB\n- **Google AI API** key\n- **Gmail account** for email services (with app password)\n- **LangSmith account** (optional, for AI tracing)\n\n### 🔧 Backend Setup\n\n1. **Clone the repository:**\n```bash\ngit clone https://github.com/Arnavkesari/chatbot-for-students-queries.git\ncd chatbot-for-students-queries\n```\n\n2. **Navigate to backend directory:**\n```bash\ncd backend\n```\n\n3. **Create and activate virtual environment:**\n```bash\n# Windows\npython -m venv venv\nvenv\\Scripts\\activate\n\n# macOS/Linux  \npython3 -m venv venv\nsource venv/bin/activate\n```\n\n4. **Install dependencies:**\n```bash\npip install -r requirements.txt\n```\n\n5. **Set up environment variables:**\nCreate `.env` file in the backend directory:\n\n```env\n# Database Configuration\nMONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/chatbot?retryWrites=true\u0026w=majority\n\n# Google AI Configuration  \nGOOGLE_API_KEY=your_google_ai_api_key\n\n# LangChain Configuration (Optional - for AI tracing)\nLANGSMITH_API_KEY=your_langsmith_api_key\nLANGCHAIN_TRACING_V2=true\nLANGCHAIN_PROJECT=Faculty Chatbot\nLANGCHAIN_ENDPOINT=https://api.smith.langchain.com\n\n# Email Configuration (Gmail SMTP)\nEMAIL_USER=your_email@gmail.com\nEMAIL_PASS=your_gmail_app_password\n\n# Security\nSECRET_KEY=your_secure_random_secret_key\n\n# Flask Configuration\nFLASK_ENV=development\nPORT=5000\n\n# Admin Credentials\nADMIN_EMAIL=\nADMIN_PASSWORD=\n```\n\n6. **Add PDF documents to resources folder:**\n```bash\n# Place your PDF documents in:\nbackend/resources/\n```\n\n7. **Start the backend server:**\n```bash\npython app.py\n```\n\n### 🎨 Frontend Setup\n\n1. **Navigate to frontend directory:**\n```bash\ncd frontend\n```\n\n2. **Install dependencies:**\n```bash\nnpm install\n```\n\n3. **Configure environment variables:**\n```bash\n# Create .env.local file\ncp .env.local.example .env.local\n\n# Edit .env.local to set the API base URL\n# For development:\nVITE_API_BASE_URL=http://localhost:5000\n\n# For production (when deploying):\n# VITE_API_BASE_URL=https://your-backend-url.onrender.com\n```\n\n4. **Start the development server:**\n```bash\nnpm run dev\n```\n\nThe frontend will run on `http://localhost:5173`\n\n## 🏗️ Project Structure\n\n```\nchatbot-for-students-queries/\n├── backend/\n│   ├── app.py                    # Main Flask application\n│   ├── requirements.txt          # Python dependencies\n│   ├── config/\n│   │   ├── config.py            # Configuration settings\n│   │   └── database.py          # Database connection\n│   ├── controllers/             # Business logic controllers\n│   ├── middleware/              # Custom middleware\n│   ├── models/                  # Database models\n│   ├── routes/                  # API route definitions\n│   ├── services/                # Business services\n│   ├── utils/                   # Utility functions\n│   └── resources/               # PDF documents for RAG\n├── frontend/\n│   ├── src/\n│   │   ├── components/          # React components\n│   │   ├── assets/              # Static assets\n│   │   └── lib/                 # Utility libraries\n│   ├── package.json             # Frontend dependencies\n│   └── vite.config.js           # Vite configuration\n└── RAG/                         # RAG implementation notes\n```\n\n## 🗃️ Database Schema\n\n### Users Collection\n```json\n{\n  \"_id\": \"ObjectId\",\n  \"username\": \"string\",\n  \"email\": \"string\", \n  \"password\": \"bcrypt_hashed_string\",\n  \"created_at\": \"datetime\",\n  \"last_login\": \"datetime\"\n}\n```\n\n### Queries Collection\n```json\n{\n  \"_id\": \"ObjectId\",\n  \"question\": \"string\",\n  \"answer\": \"string\", \n  \"answered\": \"boolean\",\n  \"user_id\": \"ObjectId\",\n  \"timestamp\": \"datetime\",\n  \"ai_generated\": \"boolean\",\n  \"similarity_score\": \"float\",\n  \"category\": \"string\"\n}\n```\n\n## 🔧 Configuration Details\n\n### 🤖 AI Configuration\n- **Google AI (Gemini)**: Powers intelligent response generation\n- **LangChain**: Handles RAG pipeline and document processing\n- **FAISS**: Vector database for semantic similarity search\n- **LangSmith**: Optional AI tracing and monitoring\n\n### 📧 Email Service\n- **Gmail SMTP** integration for notifications\n- **Flask-Mail** for email management\n- Automated alerts for unanswered queries\n\n### 🛡️ Security Features\n- **Bcrypt password hashing** with salt rounds\n- **JWT token authentication** with expiration\n- **Admin role-based access control**\n- **Environment variable protection**\n- **CORS middleware** for secure API access\n- **Session timeout management**\n\n## 🎛️ Admin \n\n### Admin Capabilities:\n- View system statistics and analytics\n- Manage unanswered queries\n- Add manual responses to queries  \n- Delete inappropriate queries\n- Monitor chat history across all users\n- Receive email notifications for critical queries\n\n## 🔍 Development\n\n### Environment Modes\n- **Development**: `FLASK_ENV=development` (Hot reloading enabled)\n- **Production**: `FLASK_ENV=production` (Optimized for performance)\n- **Testing**: `FLASK_ENV=testing` (Test configuration)\n\n### Testing the System\n1. **Health Check**: `GET http://localhost:5000/health`\n2. **Email Service**: `GET http://localhost:5000/debug/email`  \n3. **Send Test Email**: `POST http://localhost:5000/debug/send-test-email`\n4. **List Routes**: `GET http://localhost:5000/debug/routes`\n\n### API Testing with cURL\n```bash\n# Test user signup\ncurl -X POST http://localhost:5000/api/signup \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"username\":\"testuser\",\"email\":\"test@example.com\",\"password\":\"password123\"}'\n\n# Test query submission  \ncurl -X POST http://localhost:5000/api/query \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer YOUR_JWT_TOKEN\" \\\n  -d '{\"question\":\"What are the admission requirements?\"}'\n```\n\n## 📚 RAG Implementation\n\nThe system uses **Retrieval-Augmented Generation** to provide accurate, context-aware responses:\n\n1. **Document Processing**: PDF files in `resources/` are processed and chunked\n2. **Vector Embeddings**: Text chunks are converted to vectors using Google AI\n3. **Vector Storage**: FAISS stores embeddings for fast similarity search  \n4. **Query Processing**: User questions are embedded and matched against knowledge base\n5. **Response Generation**: Relevant context + user query sent to Google AI for response generation\n\n### Adding New Documents\n1. Upload PDF files through the admin dashboard\n2. Rebuild embeddings using the dedicated button\n3. System automatically processes and indexes new content\n\n## 🚀 Deployment\n\n### Backend Deployment (Render)\n\nThe backend is configured for deployment on Render.com:\n\n1. **Render.yaml Configuration**: The project includes a `render.yaml` file with all the necessary configuration for deployment on Render.\n\n2. **Environment Variables**: Make sure to set up all required environment variables in the Render Dashboard:\n   - `MONGODB_URI`\n   - `JWT_SECRET_KEY`\n   - `GOOGLE_API_KEY`\n   - All email configuration variables\n   - Cloudinary credentials\n   - Pinecone API key and environment\n\n3. **CORS Configuration**: The backend is configured to accept requests from the frontend domain. Make sure to update the `CORS_ALLOW_ORIGIN` environment variable with your frontend URL.\n\n### Frontend Deployment (Vercel/Netlify)\n\n1. **Build the frontend**:\n```bash\ncd frontend\nnpm run build\n```\n\n2. **Environment Variables**: Set the `VITE_API_BASE_URL` to your deployed backend URL:\n```\nVITE_API_BASE_URL=https://your-backend-url.onrender.com\n```\n\n3. **Deploy**: Use Vercel, Netlify, or any static hosting service to deploy the `dist` folder.\n\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Add tests for new functionality  \n5. Commit changes (`git commit -m 'Add amazing feature'`)\n6. Push to branch (`git push origin feature/amazing-feature`)\n7. Open a Pull Request\n\n### Development Guidelines\n- Follow PEP 8 for Python code\n- Use ESLint configuration for JavaScript\n- Add docstrings to all functions\n- Write tests for new features\n- Update README for significant changes\n\n## 📄 License\n\nThis project is licensed under the **MIT License** - see the LICENSE file for details.\n\n## 🆘 Support \u0026 Contact\n\n- **Email**: sahayak.iiitdmj@gmail.com\n- **GitHub Issues**: [Create an issue](https://github.com/Arnavkesari/chatbot-for-students-queries/issues)\n- **Documentation**: See `/docs` folder for detailed documentation\n\n---\n\n**Built with ❤️ for educational institutions and student success**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgovinddwivedi-git%2Fchatbot-for-students-queries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgovinddwivedi-git%2Fchatbot-for-students-queries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgovinddwivedi-git%2Fchatbot-for-students-queries/lists"}