Skip to content

MOHD-OMER/TruthLens

Repository files navigation

TruthLens — AI Fake News Detection System

A production-grade web application for fake news detection using a CNN-LSTM hybrid deep learning model.

Features

  • ML Detection — CNN-LSTM hybrid model with ~94% accuracy
  • Analytics Dashboard — Real-time charts: detection split, 7-day trend
  • Detection History — Paginated log of all predictions with IP, confidence, timestamp
  • REST APIPOST /api/predict JSON endpoint for programmatic access
  • SQLite Database — Persistent storage of all predictions via SQLAlchemy ORM
  • Admin Auth — Session-based login for dashboard access
  • Professional UI — Dark editorial design, animated confidence meter

Setup

# 1. Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# 2. Install dependencies
pip install -r requirements.txt

# 3. Place model files in ./models/
#    - CNN_LSTM_Hybrid_model.h5
#    - tokenizer.pkl

# 4. Run
python app.py

Open http://localhost:5000

API Usage

curl -X POST http://localhost:5000/api/predict \
  -H "Content-Type: application/json" \
  -d '{"text": "Scientists discover breakthrough cancer treatment..."}'

Response:

{
  "prediction": "Real News",
  "confidence": 91.3,
  "raw_score": 0.913,
  "id": 42
}

Admin Login

Default credentials: admin / admin123
Change in app.py before deployment.

Project Structure

FakeNewsDetection/
├── app.py              # Main Flask app, routes, DB models
├── requirements.txt
├── models/
│   ├── CNN_LSTM_Hybrid_model.h5
│   └── tokenizer.pkl
├── templates/
│   ├── base.html       # Shared layout, nav, footer
│   ├── home.html       # Landing + prediction form
│   ├── result.html     # Animated result with confidence meter
│   ├── dashboard.html  # Analytics with Chart.js
│   ├── history.html    # Paginated prediction log
│   ├── about.html      # Model architecture details
│   └── login.html
└── static/             # CSS/JS if externalized

Tech Stack

Layer Technology
Backend Flask, SQLAlchemy
Database SQLite
ML TensorFlow/Keras
NLP NLTK
Frontend Jinja2, Chart.js
Auth Flask sessions

About

TruthLens is a college mini-project prototype built to explore deep learning for misinformation detection. It uses a CNN-LSTM Hybrid-NN trained on 40,000+ real and fake news articles to classify text as real or fake news.Deployed live on Render. Note: This is a prototype developed as an academic mini-project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors