Detect AI-generated images • Identify AI-written text • Fact-check claims
Built with Next.js 16, powered by Reality Defender, Sapling AI, Groq & OpenRouter.
TruthLens is a full-stack web application that verifies content authenticity using multiple AI models running in parallel. Upload an image, paste text, or enter a news headline — TruthLens will analyze it through specialized AI pipelines and return a credibility score with a detailed explanation and source citations.
No single model is trusted alone. Every verification runs through a multi-model pipeline with weighted score fusion to minimize false positives and maximize detection accuracy.
| Feature | Description |
|---|---|
| 🖼️ AI Image Detection | Detects AI-generated images (Midjourney, DALL·E, Stable Diffusion, etc.) using Reality Defender's deep-learning models. Large images (>5 MB) automatically fallback to Gemini 2.0 Flash vision via OpenRouter. |
| 📝 AI Text Detection | Identifies AI-generated text using Sapling AI's sentence-level detector. Includes a dual-Groq fallback (forensic + pattern analysis) when the primary detector is unavailable. |
| 📰 Fact-Checking | Cross-references news claims and headlines against trusted journalism sources using Groq's LLaMA 3.3 70B. Returns credibility ratings (LOW / MEDIUM / HIGH) with source links. |
| 📊 Visual Results Dashboard | Animated circular credibility meters, color-coded status banners, horizontal bar indicators, and detailed AI-generated explanations. |
| 🔬 Live Analysis Pipeline | Real-time stage-by-stage progress visualization with ETA countdown, elapsed timer, and image scan overlay with animated beam. |
| 📜 Verification History | All past verifications stored locally in the browser (localStorage). Browse, review, or delete individual entries. |
| 🔒 Privacy-First | Content is analyzed and discarded immediately. No user data is stored on the server. |
| 📱 Fully Responsive | Mobile-first design with hamburger navigation and adaptive layouts. |
┌─────────────────────────────────────────────────────────────┐
│ Frontend (Next.js) │
│ │
│ VerificationPanel ──→ AnalysisLoader ──→ ResultDashboard │
│ (Image/Text/News) (Pipeline UI) (Scores + Report) │
└─────────────────┬───────────────────────────────────────────┘
│ POST /api/verify/{image,text,news}
▼
┌─────────────────────────────────────────────────────────────┐
│ API Routes (Server) │
│ │
│ ┌─── Image ──────────────────────────────────────────────┐ │
│ │ Normal: Reality Defender SDK → Groq (explanation) │ │
│ │ Large: OpenRouter Gemini 2.0 Flash → Groq (explain.) │ │
│ └────────────────────────────────────────────────────────┘ │
│ ┌─── Text ───────────────────────────────────────────────┐ │
│ │ Primary: Sapling AI → Groq (explanation) │ │
│ │ Fallback: Dual-Groq scoring (forensic + pattern) │ │
│ └────────────────────────────────────────────────────────┘ │
│ ┌─── News ───────────────────────────────────────────────┐ │
│ │ Groq fact-check + AI text detection + Source citations │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
- Next.js 16.1.6 — React framework with App Router & Turbopack
- TypeScript 5 — Full type safety
- TailwindCSS 4 — Utility-first styling with custom design tokens
- Framer Motion — Smooth animations & page transitions
- Lucide React — Consistent icon system
- Google Fonts — Inter (body) + Space Grotesk (headings)
- Reality Defender SDK — Deep-learning image authenticity detection
- Sapling AI — Sentence-level AI text detection
- Groq (LLaMA 3.3 70B Versatile) — Explanations, fact-checking, fallback text analysis
- OpenRouter (Gemini 2.0 Flash) — Large image analysis fallback
truthlens/
├── src/
│ ├── app/
│ │ ├── api/verify/
│ │ │ ├── image/route.ts # Image verification endpoint
│ │ │ ├── text/route.ts # Text AI detection endpoint
│ │ │ └── news/route.ts # Fact-checking endpoint
│ │ ├── history/page.tsx # Verification history page
│ │ ├── transparency/page.tsx # How It Works page
│ │ ├── layout.tsx # Root layout (fonts, metadata)
│ │ ├── page.tsx # Homepage (hero, panel, results)
│ │ └── globals.css # Design system & theme tokens
│ └── components/
│ ├── Navbar.tsx # Fixed navigation bar
│ ├── VerificationPanel.tsx # 3-tab input (Image/Text/News)
│ ├── AnalysisLoader.tsx # Pipeline progress visualization
│ ├── ResultDashboard.tsx # Results with meters & explanation
│ ├── CredibilityMeter.tsx # Animated SVG circular gauge
│ ├── SourcesPanel.tsx # Verified source links
│ ├── HowItWorks.tsx # Feature explanation cards
│ └── Footer.tsx # Site footer
├── .env.local # API keys (not committed)
├── next.config.ts # Next.js config (20MB body limit)
├── package.json
└── tsconfig.json
- Node.js ≥ 20
- npm (comes with Node.js)
git clone https://github.com/gsaianimesh/TruthLens.git
cd TruthLensnpm installCreate a .env.local file in the project root:
REALITY_DEFENDER_API_KEY=your_reality_defender_api_key
SAPLING_API_KEY=your_sapling_api_key
GROQ_API_KEY=your_groq_api_key
OPENROUTER_API_KEY=your_openrouter_api_keyWhere to get API keys
| Service | Sign Up | Free Tier |
|---|---|---|
| Reality Defender | Request access | Limited |
| Sapling AI | Sign up | Yes |
| Groq | Sign up | Generous free tier |
| OpenRouter | Sign up | Pay-per-use |
npm run devOpen http://localhost:3000 in your browser.
npm run build
npm startDetect if an image is AI-generated.
Request body:
{
"image": "data:image/png;base64,...",
"largeImage": false
}Response:
{
"type": "image",
"ai_probability": 87,
"credibility_score": 13,
"explanation": "This image shows multiple indicators of AI generation...",
"verified_sources": [],
"detection_method": "reality_defender"
}Detect if text is AI-written.
Request body:
{
"text": "The quick brown fox jumps over the lazy dog..."
}Response:
{
"type": "text",
"ai_probability": 94,
"credibility_score": 6,
"explanation": "The text exhibits strong AI-generation patterns...",
"verified_sources": [],
"detection_method": "sapling"
}Fact-check a claim or headline.
Request body:
{
"text": "NASA confirms the moon is shrinking by 50 meters per year"
}Response:
{
"type": "news",
"ai_probability": 72,
"credibility_score": 28,
"claim_credibility": "LOW",
"explanation": "While NASA has confirmed lunar shrinkage, the actual rate is...",
"verified_sources": [
{ "title": "NASA - Shrinking Moon", "url": "https://..." }
]
}The UI follows a clean, dark-mode-first aesthetic inspired by Linear and Vercel:
- Color palette: Deep black (
#09090b), muted violet primary (#7c5cfc), sky accent (#38bdf8) - Typography: Inter for body text, Space Grotesk for headings
- Surfaces: Subtle bordered cards with soft box shadows — no glass-morphism
- Animations: Purposeful Framer Motion transitions, no decorative glow effects
- Background: Minimal dot-grid pattern
- Image Upload — User drags/drops or selects an image (up to 20 MB)
- Size Check — If >5 MB, user sees a warning and can choose to continue (uses lighter OpenRouter model) or pick a smaller image
- Analysis
- Normal path: Image saved to temp file → Reality Defender SDK
detect()with 60-second timeout → AI probability score - Large image path: Base64 sent to OpenRouter (Gemini 2.0 Flash vision model) → AI probability score
- Normal path: Image saved to temp file → Reality Defender SDK
- Explanation — Groq LLaMA 3.3 generates a human-readable explanation from the raw detection data
- Cleanup — Temp file deleted immediately after analysis
- Text Input — User pastes text into the editor
- Primary Detection — Sapling AI API analyzes the text at sentence level, returning per-sentence AI probability scores
- Fallback — If Sapling fails, two independent Groq analyses run in parallel:
- Forensic analysis (60% weight): Linguistic entropy, vocabulary diversity, burstiness
- Pattern analysis (40% weight): Structural patterns, stylistic markers, coherence
- Explanation — Groq generates a detailed explanation citing specific indicators found
- Input — User enters a URL, headline, or claim
- Parallel Analysis — Three engines run simultaneously:
- Groq fact-check (claim credibility against known sources)
- AI text detection (is the article itself AI-generated?)
- Linguistic authenticity analysis
- Score Fusion — Results weighted 70% fact-check, 30% AI-text detection
- Output — Credibility rating (LOW/MEDIUM/HIGH), explanation, and source citations
- API keys stored in
.env.local(gitignored — never committed) - Image data processed in-memory; temp files deleted immediately after analysis
- No user data or submissions persisted server-side
- Input validation on all API endpoints
- Content-type checking for uploaded images
- Request body size limited to 20 MB
Contributions are welcome! Feel free to open issues or submit pull requests.
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m 'Add my feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
This project is open source under the MIT License.
Built by Animesh
Fighting misinformation with AI.