Skip to content

kumar-veerendra/TrapShield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ TrapShield

AI-powered phishing detection for URLs, SMS, and Emails

License Python Node.js React

"Protecting users from phishing attacks using AI and Machine Learning."


๐Ÿ“– Table of Contents


โœจ Features

  • ๐Ÿ”— URL Phishing Detection โ€” Identify malicious links in real-time
  • ๐Ÿ’ฌ SMS Scam Detection โ€” Flag suspicious text messages
  • ๐Ÿ“ง Email Phishing Detection โ€” Analyze email content for threats
  • ๐Ÿค– ML-Based Detection โ€” Powered by trained Scikit-learn models
  • ๐Ÿ“Š Confidence Scoring โ€” Get prediction confidence percentages
  • ๐Ÿง  Reason Explanation โ€” Understand why content was flagged
  • โšก Modern Stack โ€” React frontend + Node.js backend + Flask ML service

๐Ÿ› ๏ธ Tech Stack

Layer Technology
Frontend React.js, Vite, Tailwind CSS
Backend Node.js, Express.js
ML Service Python, Flask, Scikit-learn, NLTK, Pandas, NumPy
Database MongoDB (optional)

๐Ÿ“ Project Structure

TrapShield/                                 # Main Project Folder
โ”‚
โ”œโ”€โ”€ frontend/                               # React Frontend
โ”‚   โ”œโ”€โ”€ public/                             # Static files
โ”‚   โ””โ”€โ”€ src/                               # Main React source code
โ”‚       โ”œโ”€โ”€ assets/                         # Images, icons, logos
โ”‚       โ”œโ”€โ”€ components/                     # Reusable UI components
โ”‚       โ”‚   โ”œโ”€โ”€ Navbar.jsx
โ”‚       โ”‚   โ”œโ”€โ”€ ResultCard.jsx
โ”‚       โ”‚   โ””โ”€โ”€ Loader.jsx
โ”‚       โ”œโ”€โ”€ pages/                          # Main pages
โ”‚       โ”‚   โ”œโ”€โ”€ Home.jsx
โ”‚       โ”‚   โ”œโ”€โ”€ UrlCheck.jsx
โ”‚       โ”‚   โ”œโ”€โ”€ SmsCheck.jsx
โ”‚       โ”‚   โ””โ”€โ”€ EmailCheck.jsx
โ”‚       โ”œโ”€โ”€ services/                       # API calling functions
โ”‚       โ”‚   โ””โ”€โ”€ api.js
โ”‚       โ”œโ”€โ”€ utils/                          # Helper functions
โ”‚       โ”œโ”€โ”€ App.jsx                         # Main App component
โ”‚       โ””โ”€โ”€ main.jsx                        # React entry point
โ”‚   โ”œโ”€โ”€ .env                                # Frontend environment variables
โ”‚   โ”œโ”€โ”€ package.json                        # Frontend dependencies
โ”‚   โ””โ”€โ”€ vite.config.js                      # Vite configuration
โ”‚
โ”œโ”€โ”€ backend/                                # Node.js Backend
โ”‚   โ”œโ”€โ”€ controllers/                        # Request handling logic
โ”‚   โ”‚   โ”œโ”€โ”€ urlController.js
โ”‚   โ”‚   โ”œโ”€โ”€ smsController.js
โ”‚   โ”‚   โ””โ”€โ”€ emailController.js
โ”‚   โ”œโ”€โ”€ routes/                             # API routes
โ”‚   โ”‚   โ”œโ”€โ”€ urlRoutes.js
โ”‚   โ”‚   โ”œโ”€โ”€ smsRoutes.js
โ”‚   โ”‚   โ””โ”€โ”€ emailRoutes.js
โ”‚   โ”œโ”€โ”€ services/                           # External service communication
โ”‚   โ”‚   โ””โ”€โ”€ mlService.js                    # Calls ML Flask API
โ”‚   โ”œโ”€โ”€ middlewares/                        # Custom middleware
โ”‚   โ”œโ”€โ”€ utils/                              # Helper utilities
โ”‚   โ”œโ”€โ”€ uploads/                            # Uploaded files (if needed)
โ”‚   โ”œโ”€โ”€ .env                                # Backend environment variables
โ”‚   โ”œโ”€โ”€ app.js                              # Express app config
โ”‚   โ”œโ”€โ”€ server.js                           # Backend entry point
โ”‚   โ””โ”€โ”€ package.json                        # Backend dependencies
โ”‚
โ”œโ”€โ”€ ml-service/                             # Python ML Service
โ”‚   โ”œโ”€โ”€ venv/                               # Shared virtual environment
โ”‚   โ”œโ”€โ”€ api/                                # Flask API
โ”‚   โ”‚   โ””โ”€โ”€ app.py                          # Main Flask server
โ”‚   โ”œโ”€โ”€ url-model/                          # URL phishing model
โ”‚   โ”‚   โ”œโ”€โ”€ features.py                     # URL feature extraction
โ”‚   โ”‚   โ”œโ”€โ”€ train.py                        # Train URL model
โ”‚   โ”‚   โ”œโ”€โ”€ predict.py                      # Prediction logic
โ”‚   โ”‚   โ”œโ”€โ”€ model.pkl                       # Trained model
โ”‚   โ”‚   โ””โ”€โ”€ vectorizer.pkl                  # Saved vectorizer
โ”‚   โ”œโ”€โ”€ sms-model/                          # SMS phishing model
โ”‚   โ”‚   โ”œโ”€โ”€ features.py
โ”‚   โ”‚   โ”œโ”€โ”€ train.py
โ”‚   โ”‚   โ”œโ”€โ”€ predict.py
โ”‚   โ”‚   โ”œโ”€โ”€ model.pkl
โ”‚   โ”‚   โ””โ”€โ”€ vectorizer.pkl
โ”‚   โ”œโ”€โ”€ email-model/                        # Email phishing model
โ”‚   โ”‚   โ”œโ”€โ”€ features.py
โ”‚   โ”‚   โ”œโ”€โ”€ train.py
โ”‚   โ”‚   โ”œโ”€โ”€ predict.py
โ”‚   โ”‚   โ”œโ”€โ”€ model.pkl
โ”‚   โ”‚   โ””โ”€โ”€ vectorizer.pkl
โ”‚   โ”œโ”€โ”€ requirements.txt                    # Python dependencies
โ”‚   โ”œโ”€โ”€ .env                                # ML environment variables
โ”‚   โ””โ”€โ”€ README.md                           # ML documentation
โ”‚
โ”œโ”€โ”€ datasets/                               # Central datasets
โ”‚   โ”œโ”€โ”€ url/                                # URL datasets
โ”‚   โ”œโ”€โ”€ sms/                                # SMS datasets
โ”‚   โ””โ”€โ”€ email/                              # Email datasets
โ”‚
โ”œโ”€โ”€ docs/                                   # Project documentation
โ”‚   โ”œโ”€โ”€ architecture/                       # Architecture diagrams
โ”‚   โ”œโ”€โ”€ screenshots/                        # UI screenshots
โ”‚   โ”œโ”€โ”€ report/                             # Project report
โ”‚   โ””โ”€โ”€ ppt/                                # Presentation
โ”‚
โ”œโ”€โ”€ .gitignore                              # Ignore unnecessary files
โ”œโ”€โ”€ README.md                               # Main project documentation
โ””โ”€โ”€ package.json                            # Optional root package file

โš™๏ธ Prerequisites

Make sure the following are installed on your machine:


๐Ÿ“ฅ Installation

Clone the Repository

git clone <your-github-repo-link>
cd TrapShield

๐ŸŽจ Frontend Setup

cd frontend

# Install dependencies
npm install

# Install Tailwind CSS
npm install tailwindcss @tailwindcss/vite

# Start development server
npm run dev

Frontend runs on http://localhost:5173


โš™๏ธ Backend Setup

cd backend

# Install dependencies
npm install

# Install required packages
npm install express cors dotenv axios multer

# Install nodemon (dev only)
npm install -D nodemon

# Start development server
npm run dev
# OR
node server.js

Backend runs on http://localhost:5000


๐Ÿค– ML Service Setup

cd ml-service

Create a virtual environment:

# Windows
python -m venv venv

# Mac/Linux
python3 -m venv venv

Activate the virtual environment:

# Windows
venv\Scripts\activate

# Mac/Linux
source venv/bin/activate

Install Python dependencies:

pip install flask pandas numpy scikit-learn nltk joblib

# Save dependencies
pip freeze > requirements.txt

Start the Flask server:

cd api
python app.py

ML Service runs on http://localhost:8000


๐Ÿ“ก API Reference

Endpoints

Method Endpoint Description
POST /predict/url Detect phishing in a URL
POST /predict/sms Detect scam in an SMS message
POST /predict/email Detect phishing in an email

Example Request

{
  "text": "Congratulations! You won a free iPhone. Click here to claim."
}

Example Response

{
  "prediction": "Phishing",
  "confidence": 96.4,
  "reasons": [
    "Suspicious keywords detected",
    "Urgent language found"
  ]
}

๐Ÿ”’ Environment Variables

Frontend โ€” frontend/.env

VITE_BACKEND_URL=http://localhost:5000

Backend โ€” backend/.env

PORT=5000
ML_SERVICE_URL=http://localhost:8000

ML Service โ€” ml-service/.env

PORT=8000

๐Ÿš€ Deployment

Service Platform
Frontend Vercel
Backend Render
ML Service Render / Railway

๐Ÿง  Model Workflow

Dataset
   โ†“
Feature Extraction
   โ†“
Model Training
   โ†“
Save Model (.pkl)
   โ†“
Prediction API

๐Ÿšซ .gitignore

# Node
node_modules/

# Python
venv/
__pycache__/
*.pyc

# Environment
.env

# Build
dist/
build/

# OS
.DS_Store

๐Ÿ”ฎ Future Improvements

  • Browser Extension for real-time detection
  • Deep Learning models (BERT, LSTM)
  • AI explanation system (explainable AI)
  • User authentication & detection history
  • Dashboard analytics & threat reports
  • Real-time threat intelligence feeds

๐Ÿ‘ฅ Team

Member
Veerendra Kumar
Nayan Kumar
Ujjwal Kumar Singh
Om Shankar Madhwan
Shreysi Bharati

๐Ÿ“„ License

This project is for educational purposes only.


Made with โค๏ธ by the TrapShield Team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors