AI-powered fake news detection with credibility scoring, truth probability, timeline evolution & region-based source comparison.
Flask + TF-IDF + RandomForest + heuristic pattern engine + Plotly visualizations
Demo • Features • Screenshots • Quick Start • API • How it Works

Gauges: Credibility / Truth Probability

24h credibility evolution (Plotly, date-axis, spline)

Sentiment, Bias, Fact-check, Manipulative, Source Reliability

Region-based 3-article generation (US/UK/EU/Asia)

Pattern matches, impossibilities, confidence & conclusion
Demo WorkFlow:
Paste → Analyze → Gauges + Timeline + Sources in < 1s
| Category | What it does |
|---|---|
| 🎨 Modern UI | Dark & darker mode, responsive grid, Plotly gauges + timeline, animated cards, loading overlay |
| 🧠 Hybrid AI Engine | TF-IDF (5000, 1-3 gram) + RandomForest (100 trees, balanced) + 140+ regex fake patterns + 50+ scientific impossibilities + credibility indicators |
| 📊 Credibility Score | 0–100 → truth_probability = credibility . Boost for policy/economic official sources, penalty for clickbait/conspiracy/extraordinary claims |
| ⏱️ Credibility Timeline | 24h realistic drift simulation (starts noisy → converges to final score), date-axis, dynamic Y-range, no duplicate labels |
| 🔍 Detailed Metrics | sentiment (-100→100), bias (0→100), fact_check_confidence, manipulative_language, source_reliability, linguistic_complexity |
| 🌍 Source Comparison | Auto region detection (US/UK/EU/Asia keywords) → 3 generated articles with bias-titles (center-left/center/center-right) + summaries |
| 🤖 AI Insights | Lists matched patterns, impossible claims, credibility indicators, model confidence & human-readable conclusion |
| 🔌 REST API | POST /analyze, POST /api/v1/analyze, GET /api/v1/sources + CORS |
[ User Text ] → [ Flask app.py ] → [ FakeNewsDetector (models/detector.py) ]
├─ FakeNewsAI (fake_news_ai.py) → TF-IDF + RF → credibility + patterns
├─ CredibilityMetrics (utils/metrics.py) → sentiment/bias/manipulative
└─ NewsSourceComparison (utils/news_sources.py) → region + 3 articles
↓
[ JSON ] → [ Plotly.js gauges + timeline + cards (static/js/script.js) ]
| Layer | Tools |
|---|---|
| Backend | Python 3.8+, Flask 3.x, Flask-CORS, scikit-learn, NLTK, NumPy, Pandas, Joblib |
| NLP | TF-IDF Vectorizer, WordNet Lemmatizer, stopwords, punkt, Regex heuristics |
| Frontend | HTML5, CSS3 (dark theme, grid), Vanilla JS, Plotly 2.14, Font Awesome 6 |
| Models | models/fake_news_model.joblib (RF), models/tfidf_vectorizer.joblib |
FakeNewsDetector System NLP/
├── app.py # Flask routes: /, /analyze, /api/v1/*
├── requirements.txt
├── models/
│ ├── detector.py # Orchestrator: score fusion + timeline + sources
│ ├── fake_news_ai.py # RF + TF-IDF + patterns/impossibilities
│ ├── fake_news_model.joblib
│ └── tfidf_vectorizer.joblib
├── utils/
│ ├── metrics.py # Sentiment/bias/manipulative/source-reliability
│ └── news_sources.py # Trusted sources by region + article generator
├── templates/
│ └── index.html # Dark/blue dashboard
├── static/
│ ├── css/style.css # 1200+ lines, responsive, card animations
│ └── js/script.js # Gauges, timeline (date-axis, purge), metrics, sources
└── Images/
├── hero.png
├── home.png
├── analysis.png
├── timeline.png
├── metrics.png
├── sources.png
├── insights.png
├── architecture.png
└── demo.gifgit clone https://github.com/Sword4234/FakeNewsDetector-System-NLP.git
cd FakeNewsDetector-System-NLPpython -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
pip install flask flask-cors nltk scikit-learn numpy pandas joblib
# or
pip install -r requirements.txtpython -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab'); nltk.download('stopwords'); nltk.download('wordnet')"If behind proxy:
set NLTK_ALLOW_PROXIED_URLOPEN=1(Windows) /export NLTK_ALLOW_PROXIED_URLOPEN=1
python app.py
# → * Running on http://127.0.0.1:5000
# → Debug + watchdog auto-reloadOpen http://127.0.0.1:5000 → paste news → Analyze. Try Try Sample News / Try Fake News Sample buttons.
Request:
{ "news_text": "NASA rover finds evidence of water on Mars, according to peer-reviewed research..." }Response 200:
{
"credibility_score": 81.9,
"truth_probability": 81.9,
"detailed_metrics": {
"sentiment_score": -3.7,
"bias_score": 4.9,
"fact_check_confidence": 53.9,
"manipulative_language": 1.7,
"source_reliability": 50.0,
"linguistic_complexity": 61.8
},
"timeline_data": [
{ "timestamp": "2026-08-31T20:47:14.508464", "score": 74.2 },
{ "timestamp": "2026-09-01T19:47:14.508464", "score": 82.6 }
],
"source_comparison": {
"region": "us",
"articles": [
{ "source": "Reuters", "title": "Fact Check: ...", "summary": "...", "date": "August 30, 2026", "url": "https://www.reuters.com/article/...", "bias": "center" }
]
},
"ai_insights": {
"pattern_matches": [],
"scientific_impossibilities": [],
"credibility_indicators": ["peer-reviewed", "research (published|conducted) (in|by)"],
"model_confidence": 66,
"conclusion": "This content appears to be credible with no suspicious patterns detected."
}
}Low credibility: source_comparison: [] → frontend shows warning “Source comparison not available for low credibility (<80%)”.
curl http://127.0.0.1:5000/api/v1/sources{
"us": [{"name":"The New York Times","url":"https://www.nytimes.com","bias":"center-left"}, ...],
"uk": [...], "eu": [...], "asia": [...]
}cURL examples:
# Credible
curl -X POST http://127.0.0.1:5000/api/v1/analyze -H "Content-Type: application/json" -d "{\"news_text\":\"Government announces fiscal policy and trade agreement according to official ministry sources.\"}"
# Fake
curl -X POST http://127.0.0.1:5000/api/v1/analyze -H "Content-Type: application/json" -d "{\"news_text\":\"NASA confirms moon made of cheese miracle cure shocking truth\"}"1. FakeNewsAI.analyze_text(text) (models/fake_news_ai.py:28)
- Preprocess:
word_tokenize→ lower → remove stopwords →WordNetLemmatizer - Vectorize
TfidfVectorizer(max_features=5000, ngram_range=(1,3))→RandomForest (100 trees, balanced)→fake_news_probability - Regex checks: 140+ fake patterns (
miracle cure,doctors hate,aliens landed,breaking.*died), 50+ impossibilities (moon made of cheese,human landed on sun), credibility indicators (peer-reviewed,official statement,ministry of) - Penalties/boosts: known fakes →
credibility 10, sun landing →≤8, pattern →-15each (cap 75), impossibility →-30(cap 90, max 25), extraordinary claims without 5 indicators → cap 35 - Stats: word/sentence counts,
linguistic_complexity
2. FakeNewsDetector.analyze_news (models/detector.py:14)
- Fuses
credibility_score == truth_probability, boosts policy/economic news if ≥2 terms + no patterns →≥85 - Generates
timeline_dataviagenerate_timeline_data(base)(24h drift toward base) - Region via keyword counts →
get_related_articlesifcredibility ≥80else[] - Merges
source_credibility,fact_density+CredibilityMetricsscores
3. CredibilityMetrics (utils/metrics.py:15)
- Sentiment via positive/negative lexicons, bias via opinion words + first-person pronouns, fact-check via numbers/quotes/citations/dates, manipulative via clickbait regex, source reliability via domain whitelist
| Input | Credibility | Pattern | Sources |
|---|---|---|---|
NASA Perseverance peer-reviewed... |
81.9 |
[] |
3 articles (us) |
Moon made of cheese miracle cure |
0 |
miracle cure, doctors hate |
[] (warning) |
Fiscal policy trade bilateral... official ministry |
100 |
[] |
3 articles |
Timeline: 24 pts, ISO timestamps, range ≈10-19 for high cred (visible spline, not flat), dynamic Y [min-8, max+8], purge fix removes double-line.
Production (no debug/watchdog):
# app.py:66
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=False)Use waitress/gunicorn:
pip install waitress
waitress-serve --host=0.0.0.0 --port=5000 app:appPRs welcome! Please:
- Fork →
git checkout -b feat/your-feature - Use
black/flake8for Python, keepscript.jsvanilla - Test both credible & fake samples
- PR description: what + why + screenshot
MIT © 2026 Sword4234 — see LICENSE. No paper/IPR/patent — free for open-source, commercial, academic use with attribution.
Sword4234 / YashD — GitHub
Built with ❤️ for media literacy. If this helps your research, please ⭐ star the repo!
