{"id":35909450,"url":"https://github.com/miashraf1818/genai-rag-chatbot","last_synced_at":"2026-04-13T13:04:38.985Z","repository":{"id":324516937,"uuid":"1095976697","full_name":"miashraf1818/genai-rag-chatbot","owner":"miashraf1818","description":"🤖 AI-powered RAG chatbot: Upload documents, ask questions, get intelligent answers. FastAPI + LLaMA 3.1 + Pinecone + Nextjs.","archived":false,"fork":false,"pushed_at":"2026-01-13T10:02:58.000Z","size":345,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-13T10:58:48.382Z","etag":null,"topics":["ai","chatbot","fastapi","lang","llama","pinc","python","rag","streamlit"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/miashraf1818.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-11-13T19:14:58.000Z","updated_at":"2026-01-13T10:03:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/miashraf1818/genai-rag-chatbot","commit_stats":null,"previous_names":["miashraf1818/-genai-rag-chatbot","miashraf1818/genai-rag-chatbot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/miashraf1818/genai-rag-chatbot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miashraf1818%2Fgenai-rag-chatbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miashraf1818%2Fgenai-rag-chatbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miashraf1818%2Fgenai-rag-chatbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miashraf1818%2Fgenai-rag-chatbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miashraf1818","download_url":"https://codeload.github.com/miashraf1818/genai-rag-chatbot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miashraf1818%2Fgenai-rag-chatbot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31753557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ai","chatbot","fastapi","lang","llama","pinc","python","rag","streamlit"],"created_at":"2026-01-10T03:22:25.079Z","updated_at":"2026-04-13T13:04:38.973Z","avatar_url":"https://github.com/miashraf1818.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 GenAI RAG Chatbot\n\nA production-ready, full-stack AI chatbot application featuring **Retrieval-Augmented Generation (RAG)**, real-time streaming, and secure user authentication. Built with modern \"DevOps\" practices using Docker and AWS.\n\n\n## ✨ Key Features\n\n### 🧠 Advanced AI Capabilities\nThis project is a RAG (Retrieval-Augmented Generation) chatbot that allows users to upload documents (PDF, DOCX, TXT) and chat with them using an LLM (Llama 3 via Groq). It features a modern, responsive UI built with Next.js and a robust FastAPI backend.\n\n\u003e **Latest Update:** Optimized for AWS EC2 t2.micro deployment (CPU-only inference).\n-   **Smart Context**: Uses **Pinecone** vector database to retrieve relevant info for every query.\n-   **Llama 3 Powered**: Integrated with **Groq** for lightning-fast AI responses.\n-   **Streaming Responses**: Real-time text generation (like ChatGPT) using WebSockets.\n\n### 🔒 Security \u0026 Auth\n-   **Google OAuth 2.0**: Secure \"Login with Google\" integration.\n-   **User Isolation**: Each user only sees *their* own documents and chat history.\n-   **JWT Sessions**: Stateless, secure session management.\n\n### 💻 Modern UI/UX\n-   **React + TypeScript**: Fast, type-safe frontend.\n-   **Chat History**: Saves all your conversations automatically.\n-   **Dark/Light Mode**: Beautiful UI with theme switching.\n-   **Responsive Design**: Works on desktop and mobile.\n\n### ⚙️ DevOps \u0026 Backend\n-   **Dockerized**: Full stack (Frontend, Backend, Database) runs in containers.\n-   **PostgreSQL**: Robust relational database for user data and history.\n-   **AWS Ready**: Configured for deployment on EC2.\n-   **Cloudflare Tunnel**: Secure exposure without opening firewall ports (Optional).\n\n---\n\n## 🏗️ Architecture\n\n```mermaid\ngraph TD\n    User[👤 User] --\u003e|HTTPS| Cloudflare[☁️ Cloudflare Tunnel]\n    Cloudflare --\u003e|HTTP| Frontend[🖥️ Next.js Frontend]\n    Frontend --\u003e|API Calls| Backend[⚙️ FastAPI Backend]\n    \n    subgraph AWS EC2\n        Frontend\n        Backend\n        DB[(🐘 PostgreSQL)]\n    end\n    \n    Backend --\u003e|SQL| DB\n    Backend --\u003e|Vectors| Pinecone[(🌲 Pinecone)]\n    Backend --\u003e|Inference| Groq[(⚡ Groq LPU)]\n```\n\n## 🌐 Live Demo\n\nThe application is live and accessible via a secure Cloudflare Tunnel:\n\n👉 **[Launch GenAI Chatbot](https://away-lucy-layer-extension.trycloudflare.com)**\n\n*(Note: This is a demo environment running on AWS Free Tier. Initial load might take a few seconds.)*\n\n---\n\n## 📸 Screenshots\n\n### Landing Page\n![Landing Page](docs/screenshots/landing_hero.png)\n\n### Tech Stack \u0026 Architecture\n![Tech Stack](docs/screenshots/tech_stack.png)\n\n### Developer Profile\n![Developer Profile](docs/screenshots/developer_profile.png)\n\n### Secure Login\n![Login Page](docs/screenshots/login_page.png)\n\n### Chat Interface\n![Chat Welcome](docs/screenshots/chat_welcome.png)\n\n### File Upload \u0026 RAG\n![File Upload](docs/screenshots/file_upload.png)\n\n### Admin Dashboard\n![Admin Dashboard](docs/screenshots/admin_dashboard.png)\n\n### User Management\n![User Management](docs/screenshots/user_management.png)\n\n---\n\n## 🛠️ Tech Stack\n\n| Component | Technology |\n| :--- | :--- |\n| **Frontend** | React 18, Next.js 14, TypeScript, Tailwind CSS |\n| **Backend** | FastAPI (Python 3.11), SQLAlchemy, Pydantic |\n| **Database** | PostgreSQL 15 (Data), Pinecone (Vectors) |\n| **AI Model** | Llama 3-8b-8192 (via Groq API) |\n| **Infrastructure** | Docker, Docker Compose, AWS EC2, Nginx/Cloudflare |\n\n---\n\n## 🚀 Quick Start (Local)\n\n### Prerequisites\n-   Docker \u0026 Docker Compose\n-   Git\n\n### 1. Clone the Repository\n```bash\ngit clone https://github.com/miashraf1818/genai-rag-chatbot.git\ncd genai-rag-chatbot\n```\n\n### 2. Configure Environment\nCopy the example env file:\n```bash\ncp .env.example .env\n```\nEdit `.env` and add your API keys (Groq, Pinecone, Google OAuth).\n\n### 3. Run with Docker\n```bash\ndocker compose up -d --build\n```\n\n### 4. Access the App\n-   **Frontend**: [http://localhost:3000](http://localhost:3000)\n-   **Backend API**: [http://localhost:8000/docs](http://localhost:8000/docs)\n\n---\n\n## ☁️ Deployment (AWS EC2)\n\nThe application is successfully deployed on AWS EC2.\n\n*   **Infrastructure**: Docker Compose on Ubuntu `t2.micro`.\n*   **DNS Strategy**: `nip.io` for wildcard resolution (Google OAuth compliance).\n*   **Security**: Cloudflare Tunnel for secure HTTPS access.\n\n👉 **Read the full [Deployment Summary \u0026 Technical Notes](DEPLOYMENT_SUMMARY.md)** for architecture details, performance benchmarks, and design decisions.\n\n### Brief Overview:\n1.  Launch an Ubuntu EC2 instance.\n2.  Install Docker \u0026 Git.\n3.  Clone repo and set production `.env`.\n4.  Run `docker compose up -d --build`.\n\n---\n\n## 📂 Project Structure\n\n```\ngenai-rag-chatbot/\n├── backend/            # FastAPI Application\n│   ├── api/           # API Routes (Chat, Auth, Files)\n│   ├── database/      # DB Models \u0026 Connection\n│   ├── llm/           # Llama 3 \u0026 Groq Logic\n│   └── vectorstore/   # Pinecone Integration\n├── frontend/           # Next.js Application\n│   ├── app/           # React Pages \u0026 Components\n│   └── public/        # Static Assets\n└── docker-compose.yml  # Container Orchestration\n```\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## ⚖️ Trade-offs \u0026 Design Decisions\n\nEvery architecture has trade-offs. Here is how we addressed common RAG challenges:\n\n| Challenge | Our Solution | Why? |\n| :--- | :--- | :--- |\n| **Latency** | **Groq LPU** | Traditional LLM inference is slow. Groq provides near-instant tokens/sec, essential for a \"chat\" feel. |\n| **Scalability** | **Next.js + Docker** | Unlike Streamlit (prototyping), Next.js is production-ready. Docker ensures consistent deployment. |\n| **Security** | **OAuth2 + RLS** | We implemented strict **Row-Level Security** logic. Users can *only* query their own vectors in Pinecone. |\n| **Cost** | **Serverless / Free Tier** | Designed to run on AWS Free Tier (EC2 t2.micro) + Pinecone Starter + Groq Free Beta. |\n\n### 🚧 Current Limitations\n-   **Context Window**: Limited by Llama 3's context (8k tokens). Very large documents may lose detail in retrieval.\n-   **File Types**: Currently supports PDF and TXT. OCR for scanned docs is planned for v2.\n-   **Memory**: The t2.micro instance (1GB RAM) requires swap memory for build processes.\n\n---\n\n## 📄 License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiashraf1818%2Fgenai-rag-chatbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiashraf1818%2Fgenai-rag-chatbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiashraf1818%2Fgenai-rag-chatbot/lists"}