import React, { useState, useEffect } from 'react'; import { ShieldAlert, Newspaper, Info, Loader2, CheckCircle2, XCircle, BrainCircuit, Activity, Globe, Zap, Cpu, Sparkles, Terminal, ShieldCheck, Database, Layers, ArrowRight, TrendingUp } from 'lucide-react'; import { motion, AnimatePresence, useScroll, useSpring } from 'framer-motion'; import NeuralScene from './components/NeuralScene'; // Point frontend to our Hugging Face Space API as the default backend const API_BASE_URL = (import.meta.env.VITE_API_URL || 'https://pyroblizzed-truthlensai.hf.space').replace(/\/$/, ''); interface PredictionResult { fake_news: { prediction: 'Real' | 'Fake'; confidence: number; model: string; }; ai_detection: { prediction: 'Human' | 'AI Generated'; confidence: number; model: string; }; } const SplashScreen = () => (
TRUTHLENS AI
); const App: React.FC = () => { const [inputTitle, setInputTitle] = useState(''); const [inputContent, setInputContent] = useState(''); const [loading, setLoading] = useState(false); const [result, setResult] = useState(null); const [error, setError] = useState(null); const [isInitializing, setIsInitializing] = useState(true); const [scanHistory, setScanHistory] = useState([]); const { scrollYProgress } = useScroll(); const scaleX = useSpring(scrollYProgress, { stiffness: 100, damping: 30 }); const tiltProps = { whileHover: { rotateX: -5, rotateY: 5, scale: 1.02, transition: { type: "spring", stiffness: 400, damping: 20 } }, style: { perspective: 1000 } }; useEffect(() => { const timer = setTimeout(() => setIsInitializing(false), 2800); // Load scan history from local storage const saved = localStorage.getItem('scan_history'); if (saved) { try { setScanHistory(JSON.parse(saved)); } catch (e) { console.error("Failed to parse history:", e); } } return () => clearTimeout(timer); }, []); const handlePredict = async () => { if (!inputTitle.trim() || !inputContent.trim()) { setError("Please fill in both title and content for accurate analysis."); return; } console.log("Starting scan... Target URL:", API_BASE_URL); setLoading(true); setResult(null); setError(null); try { const res = await fetch(`${API_BASE_URL}/predict`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: inputTitle, text: inputContent, model: 'bilstm' // Updated default model from deberta to bilstm }), }); console.log("Response received. Status:", res.status); const data = await res.json(); console.log("Data parsed:", data); if (!res.ok) { throw new Error(data.detail || `Server error: ${res.status}`); } setResult(data); // Save item to scan history const newHistoryItem = { id: Math.random().toString(36).substring(2, 9), title: inputTitle, text: inputContent.substring(0, 100) + (inputContent.length > 100 ? '...' : ''), date: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }), fake_news: data.fake_news, ai_detection: data.ai_detection }; setScanHistory(prev => { const updated = [newHistoryItem, ...prev.slice(0, 9)]; localStorage.setItem('scan_history', JSON.stringify(updated)); return updated; }); setTimeout(() => { const target = document.getElementById('result-target'); if (target) target.scrollIntoView({ behavior: 'smooth', block: 'center' }); }, 500); } catch (e: any) { console.error("Scan failed error:", e); setError(e.message || 'An unexpected connection error occurred'); } finally { setLoading(false); } }; const clearHistory = () => { setScanHistory([]); localStorage.removeItem('scan_history'); }; const analysisCards = [ { title: "Bi-LSTM Neural Network", tag: "CORE MODEL", desc: "Our model uses a Bidirectional LSTM (Long Short-Term Memory) network paired with an attention pooling layer. It reads text forwards and backwards to capture full contextual relationships between words. It is highly optimized, fast, and does not require heavy GPU compute resources to run." }, { title: "Balanced Training Metrics", tag: "PERFORMANCE", desc: "We track Precision, Recall, and F1-Score to ensure our model doesn't just guess one class. By optimizing the model for a high F1-Score, we keep false alarms to a minimum, ensuring real news is protected while successfully filtering out fabrications." }, { title: "WELFake Dataset Foundation", tag: "DATASET", desc: "The classifier was trained on the public WELFake dataset, which contains over 72,000 verified real and fake news articles. This huge variety of data exposes the model to diverse writing styles, topics, and structures across global journalism." }, { title: "Sub-10ms Inference Time", tag: "LATENCY", desc: "Unlike heavy modern transformers that cause server bottlenecks and latency, the Bi-LSTM model is lightweight and executes in under 10 milliseconds. This makes it ideal for real-time applications and public deployments." }, { title: "Word Pattern Profiling", tag: "FEATURE EXTRACTION", desc: "Our model recognizes linguistic patterns typical of misinformation. While reliable news sources lean on neutral vocabulary and descriptive facts, fake articles often feature high-intensity emotional markers, clickbait wording, and aggressive formatting." }, { title: "Open Code & Transparency", tag: "OPEN SOURCE", desc: "Everything is open and verifiable. The data preprocessing scripts, pipeline notebooks, model architectures, and training weights are documented in our repository, making it easy for anyone to inspect, run, or audit the code." } ]; return ( <> {isInitializing && }
TRUTHLENS AI
SYSTEM ONLINE
Neural Verification Framework

Spot Fake News Instantly
with Machine Learning.

A simple, fast tool that uses a Bidirectional LSTM network to analyze news text and detect whether it is real or fake.

Get Started Research Data

Verification Engine

Analyze articles to verify veracity and content origin

Input Source
setInputTitle(e.target.value)} className="title-input-field" />