AI-Powered Phishing URL Detection System
97% Accuracy | Real-Time Detection | Production Ready
Features β’ Quick Start β’ API Docs β’ Contributing
PhishGuard AI is a robust, production-ready phishing detection system that combines machine learning with modern web technologies to identify malicious URLs in real-time. Built with enterprise-grade architecture, it delivers high-accuracy threat detection while maintaining exceptional performance.
- π Machine Learning Excellence: Random Forest classifier achieving 97% accuracy with optimized hyperparameters
- β‘ Lightning Fast: Sub-second response times via FastAPI's asynchronous architecture
- π Modern Stack: Full-stack solution with Next.js frontend and Python ML backend
- π Security Focused: Designed for integration into email filters, browser extensions, and security platforms
- π Comprehensive Analysis: Multiple model comparisons (Random Forest, Decision Tree, Logistic Regression, KNN)
- Real-Time URL Analysis - Instant classification with RESTful API endpoint
- High-Precision Detection - 97% accuracy, 96% precision, 98% recall
- Scalable Architecture - Microservices design for horizontal scaling
- Interactive Dashboard - User-friendly Next.js interface for URL submission and result visualization
- Model Persistence - Trained models saved with joblib for fast loading
- Comprehensive Logging - Full request/response logging for monitoring and debugging
- π Email security gateways
- π Browser extension development
- π’ Enterprise security platforms
- π± Mobile app integration
- π Educational cybersecurity projects
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Next.js UI β ββββββ> β FastAPI Server β ββββββ> β ML Pipeline β
β (Frontend) β <ββββββ β (REST API) β <ββββββ β (scikit-learn) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
Port 3000 Port 8000 Random Forest
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 14, React, TailwindCSS | Responsive UI with modern design patterns |
| Backend | FastAPI, Pydantic, Uvicorn | High-performance async API server |
| ML Engine | scikit-learn, pandas, numpy | Model training and inference |
Evaluated on 20% held-out test set from 11,000+ phishing URLs dataset:
| Metric | Score |
|---|---|
| Accuracy | 97.0% |
| Precision | 96.0% |
| Recall | 98.0% |
| F1-Score | 97.0% |
| Algorithm | Accuracy | Training Time |
|---|---|---|
| Random Forest | 97.0% | ~2.5s |
| Decision Tree | 94.5% | ~0.8s |
| Logistic Regression | 92.3% | ~1.2s |
| K-Nearest Neighbors | 93.8% | ~1.5s |
Ensure you have the following installed:
git clone https://github.com/HassanNetSec/phishguard-ai.git
cd phishguard-aicd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
.\venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Start FastAPI server
uvicorn server:app --reload --host 0.0.0.0 --port 8000β
Backend API running at http://localhost:8000
Open a new terminal:
cd frontend
# Install dependencies
npm install
# Start development server
npm run devβ
Web application running at http://localhost:3000
Analyze a URL for phishing indicators.
Request Body:
{
"url": "https://example.com"
}Response (Safe URL):
{
"status": "safe",
"message": "β
SAFE: URL appears legitimate",
"details": [
"All security checks passed",
"Valid domain with proper DNS records",
"Model confidence: 94.2%",
"No suspicious patterns detected"
],
"prediction_score": 0.942
}Response (Dangerous URL):
{
"status": "dangerous",
"message": "π¨ DANGER: URL Likely Phishing Attempt",
"details": [
"Multiple strong indicators of a phishing attempt detected",
"Highly suspicious URL pattern",
"Model confidence: 96.8%",
"DO NOT enter credentials, payment info, or personal data",
"Close this page immediately",
"Report this URL to your IT department or relevant authorities"
],
"prediction_score": 0.968
}Once the backend is running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
phishguard-ai/
βββ backend/
β βββ server.py # FastAPI application
β βββ requirements.txt # Python dependencies
β βββ randomforestmodel.joblib # Trained Random Forest model
βββ frontend/
β βββ app/ # Next.js app directory
β βββ components/ # React components
β βββ styles/ # CSS/Tailwind styles
β βββ public/ # Static assets
β βββ package.json # Node dependencies
βββ PhishGuard_ML_Training_Analysis.ipynb # ML training notebook
βββ phishing_websites.xlsx # Training dataset
βββ .gitignore
βββ README.md
- Add support for bulk URL analysis
- Implement user authentication and API keys
- Deploy to AWS/GCP with CI/CD pipeline
- Add real-time monitoring dashboard
- Integrate additional ML models (deep learning)
- Create browser extension
- Add multilingual support
Contributions are welcome! Whether you're fixing bugs, improving documentation, or proposing new features, your help is appreciated.
- Fork the repository
- Clone your fork:
git clone https://github.com/HassanNetSec/phishguard-ai.git - Create a feature branch:
git checkout -b feature/YourFeature - Make your changes and test thoroughly
- Commit with clear messages:
git commit -m 'Add: New feature description' - Push to your fork:
git push origin feature/YourFeature - Open a Pull Request with a detailed description
- Write clean, readable code with comments
- Follow existing code style and conventions
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
- π Bug fixes and error handling improvements
- π Documentation enhancements
- β¨ New ML models or feature engineering
- π¨ UI/UX improvements
- π§ͺ Additional test coverage
- π Internationalization support
This project is licensed under the MIT License - see the LICENSE file for details.
- Hassan Khan - Initial work - HassanNetSec
See also the list of contributors who participated in this project.
- Dataset sourced from UCI Machine Learning Repository
- Inspired by modern phishing detection research
- Built with amazing open-source tools
Have questions or suggestions? Reach out:
- Email: hassankhancyber647@gmail.com
- LinkedIn: Hassan Khan
β Star this repo if you find it helpful!
Made with β€οΈ and β