$git clone https://github.com/mirzayasirabdullahbaig07/PromptGuard-AI> Real-time AI prompt threat detection powered by RAG, Groq, and llama-3.3-70b-versatile.
| 1 | # 🛡️ PromptGuard — AI Prompt Security Platform |
| 2 | |
| 3 | > Real-time AI prompt threat detection powered by RAG, Groq, and llama-3.3-70b-versatile. |
| 4 | |
| 5 |  |
| 6 |  |
| 7 |  |
| 8 |  |
| 9 |  |
| 10 | |
| 11 | --- |
| 12 | |
| 13 | ## 📌 Overview |
| 14 | |
| 15 | **PromptGuard** is a single-file AI security platform that scans user prompts in real-time and classifies them as **SAFE**, **SUSPICIOUS**, or **DANGEROUS**. It uses Retrieval-Augmented Generation (RAG) to ground every verdict in your own security policy — uploading your rules once lets the system cite the exact policy clause violated in each scan. |
| 16 | |
| 17 | Built entirely in vanilla HTML/CSS/JS with zero dependencies, it deploys to Netlify in under 60 seconds. |
| 18 | |
| 19 | --- |
| 20 | |
| 21 | ## ✨ Features |
| 22 | |
| 23 | | Feature | Description | |
| 24 | |---|---| |
| 25 | | 🔍 **Real-time Prompt Scanning** | Classifies any prompt instantly with threat type, severity, and confidence | |
| 26 | | 📚 **RAG-powered Policy Grounding** | Embeds your security policy and retrieves relevant chunks via cosine similarity | |
| 27 | | 🤖 **llama-3.3-70b-versatile** | State-of-the-art LLM analysis running on Groq's ultra-fast inference API | |
| 28 | | 🧮 **768-dim Vector Embeddings** | Uses `nomic-embed-text-v1_5` for high-quality semantic search | |
| 29 | | 💬 **Policy Q&A Chatbot** | Ask natural language questions about your AI governance rules | |
| 30 | | 📊 **Scan History & Stats** | Tracks all scans with verdicts, timestamps, and RAG grounding status | |
| 31 | | ⚡ **Zero Dependencies** | Pure HTML/CSS/JS — no build step, no framework, no npm install | |
| 32 | |
| 33 | --- |
| 34 | |
| 35 | ## 🚨 Threat Detection Categories |
| 36 | |
| 37 | - **Prompt Injection** — Hidden instructions that attempt to override system rules |
| 38 | - **Jailbreak** — Role-play or fictional framing used to bypass safety guidelines |
| 39 | - **Data Exfiltration** — Requests to extract API keys, credentials, or context data |
| 40 | - **Social Engineering** — Emotional manipulation to extract sensitive information |
| 41 | - **Policy Bypass** — Attempts to circumvent your organization's AI usage policy |
| 42 | - **PII Exposure** — Prompts containing or requesting personally identifiable information |
| 43 | |
| 44 | --- |
| 45 | |
| 46 | ## 🏗️ Architecture |
| 47 | |
| 48 | ``` |
| 49 | User Prompt |
| 50 | │ |
| 51 | ▼ |
| 52 | ┌─────────────────────────────────────┐ |
| 53 | │ RAG Retrieval Layer │ |
| 54 | │ Query → nomic-embed-text (768-dim) │ |
| 55 | │ → Cosine Similarity → Top-K Chunks │ |
| 56 | └─────────────────────────────────────┘ |
| 57 | │ Relevant Policy Context |
| 58 | ▼ |
| 59 | ┌─────────────────────────────────────┐ |
| 60 | │ llama-3.3-70b-versatile │ |
| 61 | │ (via Groq API) │ |
| 62 | │ Structured JSON verdict output │ |
| 63 | └─────────────────────────────────────┘ |
| 64 | │ |
| 65 | ▼ |
| 66 | SAFE / SUSPICIOUS / DANGEROUS |
| 67 | + Threat Type + Severity + Policy Citation |
| 68 | ``` |
| 69 | |
| 70 | --- |
| 71 | |
| 72 | ## 🚀 Getting Started |
| 73 | |
| 74 | ### Prerequisites |
| 75 | |
| 76 | - A free [Groq API key](https://console.groq.com) — takes ~30 seconds to create |
| 77 | |
| 78 | ### Setup |
| 79 | |
| 80 | **1. Clone the repository** |
| 81 | ```bash |
| 82 | git clone https://github.com/your-username/promptguard.git |
| 83 | cd promptguard |
| 84 | ``` |
| 85 | |
| 86 | **2. Add your Groq API key** |
| 87 | |
| 88 | Open `index.html` and replace the placeholder on this line: |
| 89 | ```javascript |
| 90 | const GROQ_KEY = "YOUR_GROQ_API_KEY_HERE"; |
| 91 | ``` |
| 92 | |
| 93 | **3. Open in browser** |
| 94 | ```bash |
| 95 | # Just open the file — no server needed |
| 96 | open index.html |
| 97 | ``` |
| 98 | |
| 99 | That's it. No `npm install`, no build step. |
| 100 | |
| 101 | --- |
| 102 | |
| 103 | ## ☁️ Deploy to Netlify |
| 104 | |
| 105 | ``` |
| 106 | 1. Push the repository to GitHub |
| 107 | 2. Go to netlify.com → "Add new site" → "Import from Git" |
| 108 | 3. Select your repo — Netlify auto-detects the HTML file |
| 109 | 4. Click Deploy |
| 110 | ``` |
| 111 | |
| 112 | Your site is live in under 60 seconds. Set the `GROQ_KEY` as a Netlify environment variable if you want to avoid committing it. |
| 113 | |
| 114 | --- |
| 115 | |
| 116 | ## 🗂️ Project Structure |
| 117 | |
| 118 | ``` |
| 119 | promptguard/ |
| 120 | │ |
| 121 | ├── index.html # Entire application — UI, logic, RAG pipeline |
| 122 | └── README. |