Skip to content

Latest commit

ย 

History

24 Commits

Folders and files

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

Repository files navigation

PhishGuard AI Logo

๐Ÿ›ก๏ธ PhishGuard AI

Next-Gen AI Phishing Detection System

License: MIT Python React FastAPI PRs Welcome

๐Ÿš€ Launch Live Demo ๐Ÿš€

Features โ€ข Architecture โ€ข Installation โ€ข API โ€ข Contributing


๐Ÿ’ก The Problem

Phishing attacks account for 90% of all data breaches, with AI-generated scams becoming increasingly difficult to detect. Traditional rule-based filters struggle to keep up with these sophisticated threats.

๐Ÿ›ก๏ธ The Solution

PhishGuard AI is an intelligent defense layer that leverages Machine Learning (Logistic Regression) and Natural Language Processing (NLP) to analyze email intent, context, and linguistic patterns in real-time.

"Don't just block. Understand."


โœจ Key Features

๐Ÿง  Intelligent Detection

  • 98.3% Accuracy: Trained on the SMS Spam Collection dataset.
  • High Recall (91.3%): Prioritizes catching threats to minimize missed attacks.
  • Real-Time Analysis: Sub-100ms inference time.

๐ŸŽจ Next-Gen UI/UX

  • Cyberpunk Aesthetic: Glassmorphism, neon accents, and Digital Rain effects.
  • Live Threat Feed: Real-time visualization of scanned emails.
  • Forensic Breakdown: Detailed confidence scores and probability analysis.

๐ŸŽฌ Demo

Dashboard Interface

PhishGuard AI Dashboard

Key Capabilities

  1. Email Analysis: Paste suspicious email content for instant classification
  2. Threat Visualization: Color-coded results (Red = Phishing, Green = Safe)
  3. Forensic Details: Expandable technical analysis with raw model output
  4. Scan History: Chronological feed of all analyzed emails
  5. System Status: Real-time engine health monitoring

๐ŸŽฅ Live Demo

Watch PhishGuard AI in action:

Live Demo Recording

Try it yourself:

  1. Clone the repository
  2. Run ./run_system.sh
  3. Open http://localhost:5173
  4. Paste a suspicious email and click "SCAN FOR THREATS"

๐Ÿ› ๏ธ Tech Stack

Frontend

  • Framework: React 18 with Vite
  • Styling: Vanilla CSS with custom animations
  • Fonts: Google Fonts (Outfit, Orbitron)
  • Effects: Glassmorphism, Digital Rain, Custom Cursors

Backend

  • Framework: FastAPI
  • Server: Uvicorn (ASGI)
  • CORS: Enabled for cross-origin requests

Machine Learning

  • Algorithm: Logistic Regression
  • Feature Engineering: TF-IDF Vectorization
  • Text Processing: NLTK (stopwords, stemming)
  • Model Persistence: Joblib
  • Evaluation: scikit-learn metrics

Data

  • Dataset: SMS Spam Collection (UCI ML Repository)
  • Size: 5,574 messages
  • Split: 80% training, 20% testing

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • npm or yarn
  • Git

Clone Repository

git clone https://github.com/sr-857/phishguard-ai.git
cd phishguard-ai

Backend Setup

# Install Python dependencies
pip install -r requirements.txt

# Download NLTK data (automatic on first run)
python -c "import nltk; nltk.download('stopwords')"

# Train models (if not already trained)
python src/model_trainer.py

Frontend Setup

# Navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Return to root
cd ..

๐Ÿš€ Usage

Quick Start (Recommended)

# Launch both frontend and backend with one command
./run_system.sh

This will start:

Manual Start

Backend Only

uvicorn src.api:app --reload --port 8000

Frontend Only

cd frontend
npm run dev

๐Ÿ—๏ธ Architecture

graph TD
    User[๐Ÿ‘ค User] -->|Access Dashboard| Frontend["โš›๏ธ React Frontend<br>(GitHub Pages)"]
    Frontend -->|POST /predict| Backend["๐Ÿš€ FastAPI Backend<br>(Railway)"]
    
    subgraph "Backend Services"
        Backend -->|Text Processing| NLP[๐Ÿ“ NLTK Preprocessing]
        NLP -->|Vectorization| TFIDF[๐Ÿงฎ TF-IDF Vectorizer]
        TFIDF -->|Inference| Model[๐Ÿค– Logistic Regression Model]
    end
    
    Model -->|Prediction & Score| Backend
    Backend -->|JSON Response| Frontend
    Frontend -->|Visual Feedback| User
    
    style Frontend fill:#61DAFB,stroke:#333,stroke-width:2px,color:black
    style Backend fill:#009688,stroke:#333,stroke-width:2px,color:white
    style Model fill:#FF9800,stroke:#333,stroke-width:2px,color:black
Loading

Data Flow

  1. Input: User pastes email content into the React dashboard.
  2. Request: Frontend sends a secure API request to the FastAPI backend.
  3. Processing: Backend cleans text (stopwords, stemming) and vectorizes it.
  4. Inference: ML model predicts probability of phishing.
  5. Response: Result is returned and visualized with confidence scores.

Testing the System

  1. Open http://localhost:5173 in your browser
  2. Paste a suspicious email in the text area
  3. Click "๐Ÿ›ก๏ธ SCAN FOR THREATS"
  4. View results and confidence score
  5. Check the Live Threat Feed for history

Example Phishing Email

URGENT! You have won a ยฃ100,000 Prize Jackpot! 
Click here to claim: http://suspicious-link.com
Reply with your bank details to: scammer@fake.com

๐Ÿ“š API Documentation

Base URL

http://localhost:8000

Endpoints

Health Check

GET /

Response

{
  "status": "online",
  "model": "Logistic Regression"
}

Predict Email

POST /predict
Content-Type: application/json

Request Body

{
  "text": "Your email content here"
}

Response

{
  "label": "Phishing/Spam",
  "probability": "0.9234",
  "raw_text": "Your email content here"
}

Interactive API Docs

Visit http://localhost:8000/docs for Swagger UI documentation.


๐Ÿ“Š Model Performance

Metrics (Logistic Regression)

Metric Score
Accuracy 98.3%
Precision 98.5%
Recall 91.3%
F1-Score 94.8%

Why Logistic Regression?

We chose Logistic Regression over Naive Bayes and Random Forest because:

  1. High Recall: 91.3% recall minimizes false negatives (missed phishing emails)
  2. Fast Inference: Real-time predictions with minimal latency
  3. Interpretability: Clear feature importance for transparency
  4. Efficiency: Low memory footprint and quick training

๐Ÿ“ Project Structure

phishguard-ai/
โ”œโ”€โ”€ .github/                    # GitHub assets
โ”‚   โ”œโ”€โ”€ logo.png               # Repository logo
โ”‚   โ””โ”€โ”€ dashboard-demo.png     # Demo screenshot
โ”œโ”€โ”€ frontend/                   # React application
โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ”‚   โ””โ”€โ”€ cyber_background.png
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ DigitalRain.jsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Testimonials.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ App.css
โ”‚   โ”‚   โ””โ”€โ”€ main.jsx
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ vite.config.js
โ”œโ”€โ”€ src/                        # Backend & ML
โ”‚   โ”œโ”€โ”€ api.py                 # FastAPI server
โ”‚   โ”œโ”€โ”€ data_loader.py         # Dataset handling
โ”‚   โ”œโ”€โ”€ features.py            # Feature engineering
โ”‚   โ”œโ”€โ”€ model_trainer.py       # Model training
โ”‚   โ”œโ”€โ”€ evaluation.py          # Performance metrics
โ”‚   โ””โ”€โ”€ inference.py           # Prediction engine
โ”œโ”€โ”€ models/                     # Trained models
โ”‚   โ”œโ”€โ”€ Logistic_Regression.pkl
โ”‚   โ”œโ”€โ”€ tfidf_vectorizer.pkl
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ run_system.sh              # Launch script
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ CODE_OF_CONDUCT.md
โ”œโ”€โ”€ SECURITY.md
โ””โ”€โ”€ README.md

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Quick Start

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ‘จโ€๐Ÿ’ป Contact

Developer: Subhajit Roy


๐Ÿ™ Acknowledgments

  • Dataset: SMS Spam Collection from UCI ML Repository
  • Inspiration: Modern cybersecurity dashboards and threat intelligence platforms
  • Libraries: React, FastAPI, scikit-learn, NLTK, and the amazing open-source community

โญ Star this repository if you found it helpful!

Made with โค๏ธ and โ˜• by Subhajit Roy

About

๐Ÿ›ก๏ธ Next-Gen AI Phishing Detection System. Real-time email analysis with 98.3% accuracy, powered by ML & NLP. Features a futuristic React dashboard, FastAPI backend, and live threat intelligence.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages