Skip to content

Repository files navigation

📰 NewsHub AI TruthLens

A full-stack news platform with live news feeds, a role-based editorial system, and a multi-layer AI fact-checking engine that verifies the authenticity of any news article or text.

Node.js Express PostgreSQL Gemini


✨ Features

🔐 Authentication

  • Register with OTP email verification
  • Login with email & password
  • Google OAuth login
  • Forgot password / reset password via email
  • Role-based access — Reader, Editor, Admin

📡 News Main Site

  • Live breaking news ticker
  • Hero section with featured article
  • Editor's Picks section
  • Latest news grid
  • Category navbar — National, Global, Technology, Education, Sports, Business, Entertainment, Health, Science, Politics
  • Single article pages with comments
  • Dark / Light theme toggle
  • AI Fact Check button in navbar
  • Mobile responsive with hamburger menu

👤 User Profile

  • Edit personal info (name, email, role)
  • Change password
  • Notification preferences — breaking news, digest, recommendations, newsletter
  • Editor profile — handle, bio, avatar URL

✍️ Editor Dashboard

  • Article stats overview
  • Write new articles with draft / submit workflow
  • Edit draft and rejected articles
  • Comments on own articles
  • Delete request system (request admin approval)

🛡️ Admin Panel

  • Dashboard with platform-wide stats
  • Full article management — approve, reject (with note), delete, toggle breaking/featured flags
  • User management — activate/deactivate, change roles, delete
  • Editor profiles with stats
  • Comment moderation — hide, unflag, delete
  • Delete request management — approve or deny
  • OTP log viewer with clear-expired option

🔍 AI Truth Lens (Fact Checker)

  • Paste text or enter a URL to analyze
  • Multi-layer AI chain with fallback:
    • Google Gemini 2.5 → Gemini 1.5 → Groq → Cohere → HuggingFace → Local ML model
  • Confidence score with animated ring
  • Credibility score & red flag detection
  • Credibility signals breakdown
  • Claims to verify with Google search links
  • Text statistics — word count, caps ratio, exclamation density
  • AI-verified source suggestions
  • Related articles from NewsAPI, GNews, NewsData, MediaStack, Wikipedia, RSS
  • Analysis history per session
  • Feedback system that incrementally trains the local ML model
  • Rate limiting — 20 requests per 15 minutes

🤖 Local ML Model

  • HashingVectorizer + PassiveAggressiveClassifier
  • predict.py — inference
  • hashing_train.py — incremental learning from user feedback
  • auto_updater.py — fetches live headlines, generates fake variants, retrains on schedule
  • Training data across all news categories

🛠️ Tech Stack

Layer Technology
Backend Node.js, Express.js
Templating EJS, express-ejs-layouts
Styling CSS
Database PostgreSQL
Auth Passport.js (Local + Google OAuth), express-sessions
Email Nodemailer SMTP
AI Services Google Gemini 2.5/1.5, Groq, Cohere, HuggingFace
Local ML Python (scikit-learn)
News APIs NewsAPI, GNews, NewsData, MediaStack
Push Notifications VAPID Web Push
Caching node-cache

📁 Project Structure

newshub-ai-truthlens/
├── routes/              # Express route handlers
├── views/               # EJS templates (auth, news, admin layouts)
├── public/              # Static assets (CSS, JS, images)
├── ml/
│   ├── predict.py       # ML inference
│   ├── hashing_train.py # Incremental training
│   └── auto_updater.py  # Scheduled retraining
├── .env.example         # Environment variable template
├── app.js               # Main app entry point
└── README.md

⚙️ Getting Started

Prerequisites

  • Node.js v18+
  • PostgreSQL
  • Python 3.x with scikit-learn (pip install scikit-learn)

1. Clone the repository

git clone https://github.com/your-username/newshub-ai-truthlens.git
cd newshub-ai-truthlens

2. Install Node dependencies

npm install

3. Install Python dependencies

pip install scikit-learn requests

4. Set up environment variables

cp .env.example .env

Open .env and fill in all your API keys and config values.

5. Set up the PostgreSQL database

  • Create a database in PostgreSQL
  • Update DATABASE_URL in your .env
  • Run any SQL migration files if included

6. Start the server

node app.js

Or with auto-reload:

npx nodemon app.js

Visit http://localhost:3000


🔐 Environment Variables

See .env.example for all required variables. Never commit your .env file.


🌐 APIs Used

Service Purpose
NewsAPI Main news feed
GNews Additional news source
NewsData.io News data
MediaStack Live news stream
Google Gemini Primary AI fact checking
Groq AI fallback
Cohere AI fallback
HuggingFace AI fallback
Google OAuth Social login

🤝 Contributing

Pull requests are welcome! Please open an issue first to discuss major changes.


📄 License

MIT

About

Full-stack news platform with AI fact checking

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages