Skip to content

iDheer/TruthLens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” TruthLens

AI-Powered Fake News Detection with Multi-Source Verification

Cut through the noise. Verify the truth. TruthLens uses advanced AI and multi-source cross-referencing to help you identify misinformation in real-time.

Python 3.10+ FastAPI Streamlit License: MIT


✨ Features

πŸ€– AI-Powered Analysis - Leverages GPT-4/Gemini with RAG (Retrieval Augmented Generation) for intelligent fact-checking

πŸ“Š Multi-Source Verification - Cross-references claims against Reddit discussions, Wikipedia, and multiple news APIs

🎯 Credibility Scoring - Provides transparent scoring breakdown: source credibility, content consistency, and fact verification

πŸ“ˆ Interactive Dashboard - Beautiful Streamlit interface with real-time visualizations and detailed breakdowns

πŸ’Ύ Persistent History - SQLite database tracks all analyzed articles and user feedback

🐳 Docker Ready - Full containerization support for easy deployment


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Streamlit     │────▢│    FastAPI      │────▢│  Fake News      β”‚
β”‚   Frontend      β”‚     β”‚    Backend      β”‚     β”‚  Agent          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                         β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                                    β”‚                                    β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”                   β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”                   β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
            β”‚  AI Service   β”‚                   β”‚ Reddit Serviceβ”‚                   β”‚ News Service  β”‚
            β”‚  (LLM + RAG)  β”‚                   β”‚               β”‚                   β”‚               β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                                                                        β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”                                                       β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
            β”‚  Wikipedia    β”‚                                                       β”‚   Database    β”‚
            β”‚  Service      β”‚                                                       β”‚   (SQLite)    β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • API Keys (at least one AI provider required):
    • OpenAI API Key or Google Gemini API Key
    • Reddit API credentials (optional, for Reddit analysis)
    • NewsAPI / GNews / NewsData API keys (optional, for news verification)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/truthlens.git
    cd truthlens
  2. Set up environment (Windows PowerShell)

    ./quick_setup.ps1

    Or manually:

    python -m venv venv
    source venv/bin/activate  # Windows: .\venv\Scripts\Activate
    pip install -r requirements.txt
    python -m spacy download en_core_web_sm
  3. Configure API keys

    Create a .env file in the root directory:

    # AI Provider (choose one: "openai" or "gemini")
    AI_PROVIDER=gemini
    
    # API Keys
    GOOGLE_API_KEY=your_gemini_api_key
    OPENAI_API_KEY=your_openai_api_key
    
    # Reddit API (optional)
    REDDIT_CLIENT_ID=your_reddit_client_id
    REDDIT_CLIENT_SECRET=your_reddit_secret
    REDDIT_USERNAME=your_reddit_username
    REDDIT_USER_AGENT=TruthLens/1.0
    
    # News APIs (optional - at least one recommended)
    NEWSAPI_KEY=your_newsapi_key
    GNEWS_API_KEY=your_gnews_key
    NEWS_DATA_API_KEY=your_newsdata_key
    
    # Database
    DATABASE_URL=sqlite:///./app/data/truthlens.db
  4. Run the application

    python run.py

    Access the application:


🐳 Docker Deployment

# Build and run with Docker Compose
docker-compose up --build

# Or build manually
docker build -t truthlens .
docker run -p 8000:8000 -p 8501:8501 --env-file .env truthlens

πŸ“‘ API Reference

Verify News Article

POST /verify
Content-Type: application/json

{
  "title": "Breaking News Headline",
  "content": "Full article content here..."
}

Response:

{
  "verdict": "REAL",
  "is_fake": false,
  "score": 78,
  "confidence": 85,
  "processing_time": 3.42,
  "details": {
    "source_credibility": 25,
    "content_consistency": 28,
    "fact_verification": 25
  }
}

Submit Feedback

POST /feedback
Content-Type: application/json

{
  "article_id": 1,
  "is_correct": true,
  "feedback_text": "Accurate analysis"
}

πŸ”§ Configuration

Variable Description Default
AI_PROVIDER AI backend: openai or gemini gemini
USE_GPU Enable GPU acceleration False
WIKIPEDIA_LANGUAGE Wikipedia language code en
MAX_WIKIPEDIA_RETRIES Retry attempts for Wikipedia 3

πŸ“ Project Structure

truthlens/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   └── fake_news_agent.py    # Orchestration logic
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── app.py                # FastAPI endpoints
β”‚   β”œβ”€β”€ frontend/
β”‚   β”‚   └── streamlit_app.py      # Streamlit UI
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── database.py           # SQLAlchemy models
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ ai_service.py         # LLM & RAG analysis
β”‚   β”‚   β”œβ”€β”€ news_service.py       # News API integration
β”‚   β”‚   β”œβ”€β”€ reddit_service.py     # Reddit analysis
β”‚   β”‚   └── wikipedia_service.py  # Wikipedia lookup
β”‚   └── utils/
β”‚       └── config.py             # Environment configuration
β”œβ”€β”€ docs/                         # Documentation
β”œβ”€β”€ tests/                        # Test suite
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.txt
└── run.py                        # Application launcher

πŸ§ͺ Testing

# Run all tests
pytest tests/

# Run with coverage
pytest tests/ --cov=app --cov-report=html

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • LangChain for the powerful LLM orchestration framework
  • Hugging Face for transformer models
  • Streamlit for the elegant frontend framework
  • FastAPI for the blazing-fast API framework

Built with ❀️ to fight misinformation

About

AI-Powered Fake News Detection with Multi-Source Verification

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors