Skip to content

Adi-0202/fake-news-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

89 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Neural Sieve Cascade (NSC) β€” Core Engine

License: MIT Python: 3.12 Framework: FastAPI Frontend: React + Vite

Neural Sieve Cascade (NSC) is a decoupled, multi-channel misinformation detection and factual verification pipeline. The system cross-examines unstructured text, web URLs, digital documents, and visual media forwards against real-time search engine indices. By combining advanced coreference resolution via state-of-the-art LLMs, real-time algorithmic domain scoring, and structural heuristics, NSC isolates facts from hyper-partisan rhetoric and automated rumor tracking loops.


🎯 The Problem & Our Approach

Modern misinformation operations exploit structural gaps in standard NLP models by utilizing non-standard formatting, complex cross-sentence references (pronouns hiding target entities), and short-lived web networks. Standard binary classifiers cannot keep up with changing global news cycles.

NSC solves this using a two-pronged hybrid architecture:

  1. Real-time Open Web RAG Pipeline (Active Phase 1): Extracts factual assertions, cleans and normalizes source environments, checks domain integrity metrics to defeat typosquatting, and cross-references assertions against live public records.
  2. Local Machine Learning Cascade (Upcoming Phase 3): An asynchronous, localized sorting cascade utilizing a multi-stage classification network designed to flag malicious syntax patterns directly on the edge.

πŸ› οΈ Tech Stack & Ecosystem

Component Technology Purpose
Frontend UI React.js (v18), Vite, Tailwind CSS High-performance, reactive dual-panel dashboard interface.
Core API Engine FastAPI, Uvicorn (ASGI) Asynchronous networking, high-concurrency request routing.
Orchestration Layer Python 3.12, Asyncio Orchestrates parallel task pipelines and multi-threaded processing.
Extraction Tiers EasyOCR, PyTorch, PyPDF, Pillow Multi-channel extraction (Computer Vision OCR + Vector Document parsing).
Reasoning Tier Groq Client SDK (llama-3.3-70b-versatile) Coreference resolution mapping and ultimate factual adjudication.
Storage Layer SQLite 3, WAL Mode Lightweight transactional logging and structural audit metrics.

πŸ—οΈ System Architecture & Advanced Subsystems

       [ User Content Intake ] ── (Web Link, Text Block, PDF, Image File)
                  β”‚
                  β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚    Cross-Channel Services    β”‚ ── Clean, isolate text, and strip artifacts
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
                  β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  Groq Coreference Resolver   β”‚ ── Resolves ambiguous pronouns into explicit nouns
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
                  β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ Dynamic Search Evidence RAG  β”‚ ── Generates concurrent live-web search threads
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
                  β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ Multi-Tier Trust Matrix (SS) β”‚ ── Audits domain authority, flags typosquatting,
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    and runs Jaccard-based snippet consensus
                  β”‚
                  β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚     LLM Factual Adjudicator  β”‚ ── Compares resolved statements vs weighted evidence
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
                  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β–Ό                              β–Ό
     [ API Response Contract ]        [ Persistent SQLite Sync ]

Advanced Algorithmic Subsystems

Coreference Resolution: Converts vague statements (e.g., "The company delayed it because the minister was accused") into self-contained atomic assertions (e.g., "Tech Corp delayed its project release because Minister John Doe was accused of insider trading").

Multi-Tiered Domain Scorer (source_scorer.py):

  • Layer 1: Direct whitelist match and absolute cryptographic validation for .gov, .gov.in, and .edu top-level domains.
  • Layer 2 (Adversarial Security Shielding): Uses Gestalt pattern matching algorithms via SequenceMatcher to flag and drop adversarial typosquatting domains (e.g., rn-reuters.com) or combosquatting networks.
  • Layer 3 (Global Popularity Index): Integrates OpenPageRank backlink indexing metrics.
  • Layer 4 (Dynamic Consensus Loop): Programmatically audits snippet token overlap (Jaccard Similarity Index) across distinct domains to dynamically boost independent local news validation metrics.

πŸ“‚ Project Repository Structure

β”œβ”€β”€ backend/                  # FastAPI Application Environment
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ db.py             # Database initializes and handles connections
β”‚   β”‚   β”œβ”€β”€ main.py           # Thin core application bootstrap entrypoint
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ analyze.py    # Primary intake routing coordinator
β”‚   β”‚   β”‚   └── results.py    # Scan logs historical telemetry exporter
β”‚   β”‚   β”œβ”€β”€ schemas/
β”‚   β”‚   β”‚   └── api_schemas.py# Pydantic schema contracts & data validation models
β”‚   β”‚   └── services/
β”‚   β”‚       β”œβ”€β”€ claim_extractor.py # AI text breakdown and headline generation
β”‚   β”‚       β”œβ”€β”€ image_processor.py # Lazy-loaded EasyOCR Vision processing
β”‚   β”‚       β”œβ”€β”€ pdf_processor.py   # Multi-page binary layout extractor
β”‚   β”‚       β”œβ”€β”€ rag_verifier.py    # Concurrently checks live open-web RAG engines
β”‚   β”‚       β”œβ”€β”€ scraper.py         # Standard HTML web scraping utility
β”‚   β”‚       β”œβ”€β”€ text_processor.py  # Defensive whitespace/payload sanitation
β”‚   β”‚       └── source_scorer.py   # Multi-tiered domain trust scoring array
β”‚   └── requirements.txt       # Unified Python server dependencies manifest
└── frontend/                 # React UI Workspace Application Environment
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ config.js         # Centralized, environment-aware API URL manager
    β”‚   β”œβ”€β”€ App.jsx           # Master state manager and root UI shell container
    β”‚   β”œβ”€β”€ components/       # Reusable, atomic design interface presentation elements
    β”‚   β”‚   β”œβ”€β”€ ClaimCard.jsx
    β”‚   β”‚   β”œβ”€β”€ OverallScore.jsx
    β”‚   β”‚   β”œβ”€β”€ SourceBadge.jsx
    β”‚   β”‚   └── UrlInputForm.jsx
    β”‚   └── pages/            # View managers handling operational layouts
    β”‚       β”œβ”€β”€ Home.jsx
    β”‚       └── Results.jsx
    β”œβ”€β”€ .env.development      # Targets localhost parameters during debugging
    └── .env.production       # Points compilation streams to live cloud targets

πŸš€ Local Installation & Environment Setup

Prerequisites

  • Python 3.12 or higher installed locally.
  • Node.js (v18.x or higher) and npm installed locally.
  • A valid Groq API Key (Claim your key at the Groq Console).

1. Backend Service Configuration

Navigate into the backend directory, spin up your python isolation environment, and trigger dependency mapping:

cd backend

# Initialize your virtual environment isolation layer
python3 -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate

# Install all backend dependencies
pip install -r requirements.txt

Create a .env configuration file inside your backend/ root directory:

GROQ_API_KEY=your_groq_api_token_here
OPEN_PAGERANK_API_KEY=optional_pagerank_token_here

Launch the hot-reloading development server:

uvicorn app.main:app --reload --port 8000

The active Swagger API documentation interface can be inspected live at http://127.0.0.1:8000/docs.

2. Frontend Workspace Configuration

Open a secondary independent terminal shell configuration and initialize the node engine dependencies:

cd frontend
npm install

Verify that your .env.development variables point to your local backend port:

VITE_API_BASE_URL=http://127.0.0.1:8000

Start the local Vite preview server:

npm run dev

Open your browser and navigate to the reported local server address (typically http://localhost:5173).


πŸ› οΈ Current Production Deployment Blueprint

The production stack is currently deployed across a secure, split multi-cloud configuration to minimize costs while providing zero-downtime scalability:

  • Backend API Engine: Hosted on Render's Web Services connected directly to Python runtime configurations.
    • Memory Optimization Notice: Due to Render's free memory limit (512MB RAM), the EasyOCR computer vision pipeline uses a Lazy-Loading Pattern. It remains completely unloaded at system boot and only opens if an image validation is requested.
  • Frontend Web Application: Hosted on Vercel's Hobby Infrastructure, featuring automated edge compilation triggered on every git push command.

πŸ—ΊοΈ Engineering Development Roadmap

We are looking for core contributors to help expand the engine across the upcoming feature sprints:

πŸ”“ Phase 2: Multi-Tenancy & Decentralized User Key Architecture

  • Add database entities (users, user_settings) via core schema tables or SQLAlchemy migrations.
  • Transition from a single global environment token to a secure Runtime Client Initialization Model using OAuth2 and JWT bearer security guards.
  • Implement user profile settings views allowing individual developers to store and cycle through their custom Groq API tokens.

🧠 Phase 3: The Custom Neural Sieve Cascade (NSC) Local ML Tier

Integrate a local, high-speed machine learning model stack trained over a corpus of 651,191 malicious text records. The incoming text will pass through a local three-stage pipeline before escalating to the live web search tier:

  • Stage 1 (Logistic Regression): Ultra-fast syntactic checking to score statistical text layout vectors.
  • Stage 2 (CNN/LSTM Network Architecture): Evaluates sequential semantic flows to flag deep textual manipulation anomalies.
  • Stage 3 (TinyBERT Transformer Layer): Runs high-fidelity local entity classification checks.

🀝 Contributing & Issue Isolation

Contributions make the open-source community an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project Repository.
  2. Create your Feature Branch (git checkout -b feature/AmazingUpgrade).
  3. Commit your modifications cleanly (git commit -m 'Add some descriptive performance feature').
  4. Push to the remote branch (git push origin feature/AmazingUpgrade).
  5. Open a formal Pull Request detailing changes, performance metrics variations, and interface mutations.

Bug & Feature Tracking

If you encounter missing domain paths, edge-case HTML scraping limits, or unexpected payload parsing faults, please file an official log item inside the GitHub Issues tab. Provide your stack trace information, input sample strings, and clear replication logs.


πŸ“„ License

Distributed under the MIT License. See LICENSE for more information.

About

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors