Overview
What it is
Paste a URL and PhishGuard returns a 0–100 risk score, a risk level and a plain-language list of every warning sign it found. Four layers run on each link: reputation feeds (VirusTotal and the OpenPhish feed), about 35 address rules for brand impersonation and obfuscation tricks, domain records (WHOIS age, DNS, HTTPS and the real destination after redirects) and a gradient-boosted tree model that scores the shape of the hostname. Each finding is a weighted signal, and signals are combined with noisy-OR. A Next.js frontend and a FastAPI backend are deployed together on Vercel.
Context
The problem and my role
Phishing pages copy trusted brands to collect passwords, card numbers and OTPs, and new ones appear faster than blocklists can list them. A blocklist misses new links, a model alone gives no reason a person can understand, and simple rules flag real banks because their own pages say "login". PhishGuard cross-checks independent layers and explains each finding.
My role
Sole developer. I built the detection engine, the hostname model and its training pipeline, the FastAPI endpoints, the Next.js frontend, and the Supabase storage for API keys and scan analytics.
System
How it works
A client calls POST /api/check-url with a URL and, optionally, an API key. The address rules and the hostname model run instantly; VirusTotal, OpenPhish, WHOIS and DNS/redirect checks run in parallel within an 8-second budget, and any source that is down or not configured is reported as not checked instead of raising the score. If the link redirects, the destination is judged too. On well-known domains the rules and model are damped, because a bank's own login page legitimately says "login". The signal weights are combined with noisy-OR, a confirmed reputation listing sets a floor of 0.95, and the API returns the score, a level from safe to critical, advice and a per-layer breakdown.
Process
How I built it
- 01Built four independent detection layers that each emit weighted, explained signals instead of one opaque score.
- 02Combined signals with noisy-OR so independent evidence adds up without simple addition running away, with a 0.95 floor for confirmed reputation hits.
- 03Wrote about 35 address rules: brand names on unrelated domains or in subdomains, look-alike spellings by edit distance, IDN homoglyphs and mixed alphabets, text before @, disguised IP addresses, free hosting, shorteners, risky downloads and open-redirect parameters.
- 04Trained a gradient-boosted tree model on 20 hostname-shape features from the PhiUSIIL dataset, using only hostnames and a split by registrable domain to avoid dataset bias, and exported it to JSON so the API runs it in pure Python.
- 05Followed redirects server-side with SSRF protection: every hop is resolved and private, loopback and cloud-metadata addresses are refused.
- 06Stored API keys and scan analytics in Supabase, with keys shown once, guest limits per hashed IP and a daily limit per key.
Implementation
How the system is put together
Frontend
1 component
- Next.js 16, React 19 and Tailwind CSS v4
- Built the landing page, the interactive URL checker with a per-signal result card, and the API documentation section.
Backend
1 component
- FastAPI and Pydantic
- Served the URL check, API key signup and validation, analytics and health endpoints, with input validation and safe error messages.
Detection layers
4 components
- VirusTotal and OpenPhish (Layer 1: Reputation)
- Looked up the exact URL and, for ordinary domains, the domain. Results are cached to save quota; a confirmed listing sets the score to at least 0.95.
- Address rules (Layer 2: URL)
- About 35 rules for brand impersonation, look-alike and homoglyph domains, obfuscated IPs, free hosting, shorteners, credential wording and risky downloads.
- WHOIS, DNS, HTTPS and redirects (Layer 3: Domain)
- Flagged domains registered in the last 30 days or few months, non-resolving domains, missing HTTPS and cross-site redirects, following up to five hops with SSRF protection.
- Gradient-boosted trees (Layer 4: ML)
- Scored 20 hostname-shape features (lengths, digits, character runs, entropy, domain ending). Only confident predictions count, and well-known domains are never penalised.
Machine learning
1 component
- scikit-learn GradientBoostingClassifier, exported to JSON
- 250 trees, depth 4, trained on the PhiUSIIL dataset. ROC-AUC 0.879 and PR-AUC 0.867 on 42,884 rows from domains not seen in training.
Database
1 component
- Supabase (PostgreSQL)
- Stored API keys, request counts and scan analytics. Row-level security is on with no policies, so only the server can read or write.
Testing and deployment
1 component
- pytest and Vercel
- 76 offline tests cover the rules, scoring and API; the Python API and the frontend are deployed together on Vercel.
Results
What it achieved
- Built a four-layer detection pipeline that explains every finding in plain language.
- Trained a hostname model with ROC-AUC 0.879 on held-out domains and ran it without scikit-learn in production.
- Offline rules and model flagged 81% of 300 live OpenPhish URLs as medium or higher, while rating 0% of the Tranco top 2,000 sites high or critical.
- Shipped a public API with guest access, API keys, rate limits and interactive docs.
Reflection
Challenges and outcome
The hard part
The hardest balance was catching new phishing links without flagging legitimate sites. Real banks use words like "login", shorteners and redirects are common, and the training data had a bias (every legitimate URL was a bare homepage), so the model was limited to hostnames and the rules are damped on well-known domains.
Where it stands
The API and frontend run in production on Vercel. Measured offline (rules and model, without reputation lookups): 81% of 300 live OpenPhish phishing URLs flagged medium or higher; 0% of the Tranco top 2,000 sites and 0% of sites ranked 50,000–52,000 rated high or critical. The hostname model reached ROC-AUC 0.879 and PR-AUC 0.867 on held-out domains.