Skip to content

Latest commit

ย 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ TrustGuard โ€“ AI-Powered Scam & Fraud Risk Manager

AI-assisted risk assessment tool for detecting potential scams, phishing, and fraud in digital content. This system provides decision support only and is not a guaranteed scam detector. Always verify suspicious content through official channels.


๐Ÿš€ Live Demo

The application runs in Demo Mode by default โ€” no API key required.

Service URL
Backend API http://localhost:5000
Web Dashboard http://localhost:5174 (or 5173)
API Health http://localhost:5000/api/health

๐Ÿ“‹ Problem Statement

Millions of people worldwide fall victim to scams, phishing, and digital fraud every year. Fraudsters exploit human psychology with urgency, fear, and impersonation to steal money and personal information. Most victims don't have the technical expertise to identify suspicious content before it's too late.

TrustGuard addresses this gap by providing an AI-powered decision support tool that:

  • Analyzes suspicious content for risk indicators
  • Explains WHY content is considered risky
  • Provides evidence-backed guidance from a cybersecurity knowledge base
  • Recommends specific safety actions

๐ŸŽฏ Objectives

  1. Detect scam/phishing/fraud risk in text, URLs, webpages, and screenshots
  2. Generate transparent 0โ€“100 risk scores with factor breakdown
  3. Classify content into 12 scam categories
  4. Provide explainable AI reasons for every risk assessment
  5. Back explanations with RAG-retrieved cybersecurity knowledge
  6. Deliver results via browser extension (real-time) and web dashboard

โœจ Features

Feature Description
๐Ÿ“ Text Analysis Analyze SMS, email, WhatsApp messages, or any text
๐Ÿ”— URL Analysis Check URLs for phishing patterns and suspicious characteristics
๐ŸŒ Page Scanner Analyze full webpage content via browser extension
๐Ÿ“ธ Screenshot OCR Upload screenshots โ†’ OCR extracts text โ†’ AI analyzes
๐Ÿง  Explainable AI Every score comes with specific reasons and supporting evidence
๐Ÿ“š RAG Pipeline 22+ cybersecurity knowledge documents back every analysis
๐Ÿ’ฌ AI Chat Conversational assistant to explain results in plain language
๐Ÿ“Š Dashboard Charts showing risk distribution, trends, and categories
๐Ÿ“‹ History Search, filter, and manage all previous analyses
๐Ÿ”Œ Extension Chrome/Edge MV3 extension with popup and context menus
๐ŸŽญ Demo Mode Fully functional without any API key
โš™๏ธ Admin View System status, memory usage, API endpoint reference

๐Ÿ—๏ธ Architecture

Browser Extension (Manifest V3)
        โ”‚
        โ”œโ”€โ”€ Popup UI (popup.html/js/css)
        โ”œโ”€โ”€ Content Script (content.js)
        โ””โ”€โ”€ Background Worker (background.js)
                โ”‚
                โ–ผ
        Backend REST API (Express.js :5000)
                โ”‚
                โ”œโ”€โ”€ Input Validation & Rate Limiting
                โ”‚
                โ”œโ”€โ”€ Risk Scoring Engine (Heuristic, 0-100)
                โ”‚        โ””โ”€โ”€ Keyword detection, URL analysis
                โ”‚
                โ”œโ”€โ”€ RAG Knowledge Retrieval
                โ”‚        โ””โ”€โ”€ 22 cybersecurity knowledge docs
                โ”‚        โ””โ”€โ”€ Keyword-based semantic matching
                โ”‚
                โ”œโ”€โ”€ AI Analysis (Google Gemini API)
                โ”‚        โ””โ”€โ”€ Structured JSON response
                โ”‚        โ””โ”€โ”€ Demo Mode fallback
                โ”‚
                โ””โ”€โ”€ MongoDB (Analysis, ChatSession models)
                        โ”‚
                        โ–ผ
        Web Dashboard (React + Vite :5173)
                โ”‚
                โ”œโ”€โ”€ Landing Page
                โ”œโ”€โ”€ Dashboard (Chart.js)
                โ”œโ”€โ”€ Analyze Page (4 input types)
                โ”œโ”€โ”€ History Page (search/filter/paginate)
                โ”œโ”€โ”€ Report Page (full detail)
                โ””โ”€โ”€ Admin Page

๐Ÿ› ๏ธ Technology Stack

Layer Technology
Browser Extension Chrome Manifest V3, Vanilla JS/CSS
Frontend React 19, Vite, React Router, Chart.js, Axios
Backend Node.js, Express.js
Database MongoDB + Mongoose
AI Integration Google Gemini API (gemini-1.5-flash)
RAG Keyword-based knowledge retrieval (22 docs)
OCR Tesseract.js
File Upload Multer
Security Helmet, CORS, express-rate-limit, express-validator

๐Ÿ“ Project Structure

trustguard/
โ”œโ”€โ”€ extension/              # Chrome/Edge MV3 Extension
โ”‚   โ”œโ”€โ”€ manifest.json
โ”‚   โ”œโ”€โ”€ popup/              # Popup UI (HTML/JS/CSS)
โ”‚   โ”œโ”€โ”€ content/            # Content script (page extraction)
โ”‚   โ”œโ”€โ”€ background/         # Service worker (context menus, notifications)
โ”‚   โ”œโ”€โ”€ options/            # Settings page
โ”‚   โ””โ”€โ”€ assets/icons/       # Extension icons
โ”‚
โ”œโ”€โ”€ frontend/               # React + Vite Dashboard
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/     # Reusable UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ RiskComponents.jsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ChatPanel.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ pages/          # Route pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LandingPage.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Dashboard.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ AnalyzePage.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ HistoryPage.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ReportPage.jsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ AdminPage.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ services/api.js # API service layer
โ”‚   โ”‚   โ””โ”€โ”€ index.css       # Design system
โ”‚   โ””โ”€โ”€ vite.config.js
โ”‚
โ”œโ”€โ”€ backend/                # Node.js/Express API
โ”‚   โ”œโ”€โ”€ server.js           # App entry point
โ”‚   โ”œโ”€โ”€ controllers/        # Route handlers
โ”‚   โ”œโ”€โ”€ routes/             # Express routes
โ”‚   โ”œโ”€โ”€ models/             # MongoDB schemas
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ””โ”€โ”€ riskScoring.js  # Heuristic scoring engine
โ”‚   โ”œโ”€โ”€ ai/
โ”‚   โ”‚   โ”œโ”€โ”€ aiService.js    # Gemini API abstraction
โ”‚   โ”‚   โ”œโ”€โ”€ prompts.js      # Prompt templates
โ”‚   โ”‚   โ””โ”€โ”€ demoMode.js     # Demo scenarios
โ”‚   โ”œโ”€โ”€ rag/
โ”‚   โ”‚   โ””โ”€โ”€ knowledgeBase.js # 22 cybersecurity docs + retrieval
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ””โ”€โ”€ database.js     # MongoDB connection
โ”‚
โ”œโ”€โ”€ dataset/
โ”‚   โ””โ”€โ”€ sample_data.json    # 12 labeled development samples
โ”‚
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ api.test.js         # 24-test suite
โ”‚
โ”œโ”€โ”€ .env.example            # Environment variable template
โ””โ”€โ”€ README.md

โš™๏ธ Environment Variables

# Copy to backend/.env
PORT=5000
NODE_ENV=development
MONGODB_URI=mongodb://localhost:27017/trustguard
GEMINI_API_KEY=your_gemini_api_key_here   # Get from aistudio.google.com
AI_MODEL=gemini-1.5-flash
DEMO_MODE=true                            # Set false when API key is ready
API_SECRET_KEY=trustguard_local_secret
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100
MAX_FILE_SIZE_MB=5

๐Ÿš€ Installation & Setup

Prerequisites

  • Node.js 18+
  • MongoDB (optional โ€” app works without it in demo mode)
  • Chrome or Edge browser

1. Clone / Download

# The project is already in: C:\Users\veeno\OneDrive\Desktop\TRUSTGUARD AI

2. Backend Setup

cd backend
npm install
# Copy .env.example to .env and configure
cp ../.env.example .env
# Start backend
npm run dev
# Server runs on http://localhost:5000

3. Frontend Setup

cd frontend
npm install
npm run dev
# Dashboard runs on http://localhost:5173

4. Run Tests

# From project root
node tests/api.test.js
# Expected: 24 passed, 0 failed

5. Load Chrome Extension

  1. Open Chrome/Edge โ†’ chrome://extensions
  2. Enable Developer Mode (toggle top-right)
  3. Click "Load unpacked"
  4. Select the extension/ folder
  5. Extension appears in toolbar โ€” click ๐Ÿ›ก๏ธ TrustGuard

Note: For the extension to work, the backend must be running on http://localhost:5000. You can change the backend URL in the extension's Settings (right-click extension โ†’ Options).

6. Enable Real AI (Optional)

  1. Get a free Gemini API key from aistudio.google.com
  2. Edit backend/.env
  3. Set GEMINI_API_KEY=your_actual_key
  4. Set DEMO_MODE=false
  5. Restart backend

๐Ÿ”Œ API Reference

Method Endpoint Description
GET /api/health Backend health check
POST /api/analyze/text Analyze text content
POST /api/analyze/url Analyze URL
POST /api/analyze/page Analyze webpage
POST /api/analyze/screenshot Upload image for OCR + analysis
POST /api/chat AI chat with analysis context
POST /api/rag/search Search knowledge base
GET /api/analysis/history Get analysis history
GET /api/analysis/:id Get specific analysis
DELETE /api/analysis/:id Delete analysis
GET /api/dashboard/statistics Dashboard stats
GET /api/dashboard/admin Admin/developer stats

Example: Text Analysis

POST /api/analyze/text
Content-Type: application/json

{
  "text": "URGENT: Your bank account has been suspended..."
}

Response:
{
  "analysisId": "uuid",
  "riskScore": 87,
  "riskLevel": "CRITICAL",
  "categories": ["Phishing Risk", "Account Takeover Risk"],
  "indicators": [...],
  "summary": "...",
  "recommendations": [...],
  "uncertainty": "...",
  "ragEvidence": [...]
}

๐ŸŽญ Demo Mode

Demo Mode provides realistic pre-configured analysis scenarios without requiring a Gemini API key.

Demo Scenarios:

  1. ๐Ÿฆ Fake Bank Alert SMS โ†’ CRITICAL (91/100)
  2. ๐ŸŽ Prize/Reward Scam โ†’ CRITICAL (87/100)
  3. ๐Ÿ“ˆ Investment Scam โ†’ CRITICAL (84/100)
  4. ๐Ÿ›’ Suspicious Shopping Website โ†’ HIGH (62/100)
  5. โœ… Legitimate Website โ†’ LOW (8/100)

All demo results are clearly labeled with โšก DEMO DATA.


๐Ÿ“Š Risk Scoring

Score Range Level Meaning
0 โ€“ 20 โœ… LOW No significant indicators detected
21 โ€“ 50 โš ๏ธ MODERATE Some suspicious characteristics
51 โ€“ 75 ๐Ÿ”ด HIGH Multiple risk indicators detected
76 โ€“ 100 ๐Ÿšจ CRITICAL Strong scam/fraud indicators

Score = 0.7 ร— AI Score + 0.3 ร— Heuristic Score


๐Ÿ”’ Security

  • โœ… API keys stored server-side only (never in extension or frontend)
  • โœ… Rate limiting (100 req/15 min by default)
  • โœ… Input validation on all endpoints
  • โœ… File type and size validation for uploads
  • โœ… CORS configured for extension and frontend origins only
  • โœ… Helmet security headers
  • โœ… No silent browsing history collection
  • โœ… Extension only activates when user explicitly requests analysis

๐Ÿšง Limitations

  1. Not a guaranteed detector โ€” AI pattern detection can have false positives/negatives
  2. No real-time blocklist โ€” Does not check URLs against live threat intelligence feeds
  3. OCR accuracy โ€” Image quality affects text extraction
  4. Demo Mode โ€” Pre-configured results are illustrative, not from actual AI analysis
  5. No authentication โ€” Backend should be deployed with proper auth in production
  6. RAG โ€” Uses keyword-based matching; production system would benefit from vector search

๐Ÿ”ฎ Future Enhancements

  • Vector database (Pinecone/ChromaDB) for semantic RAG
  • Real-time URL reputation checking (VirusTotal API)
  • User authentication and multi-user support
  • Email header analysis
  • Browser history analysis (opt-in only)
  • Evaluation metrics dashboard (F1, AUC-ROC)
  • Fine-tuned model on labeled scam dataset
  • Multi-language support
  • Mobile app

โš ๏ธ Important Disclaimer

TrustGuard provides AI-assisted risk assessment and is not a guaranteed scam detector. Results should not be treated as definitive legal or financial conclusions. Users should independently verify suspicious content through trusted official channels. This system assists human judgment โ€” it does not replace it.


Built with โค๏ธ for cybersecurity awareness and digital safety.

About

AI-powered scam, phishing, and fraud risk detection platform featuring explainable AI, RAG cybersecurity knowledge base, OCR screenshot scanner, and Chrome extension.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages