TruthTracer is a comprehensive misinformation detection platform that leverages Perplexity’s Sonar API to provide multi-layered claim analysis. The platform combines fact-checking, trust chain tracing, and Socratic reasoning to deliver accurate, evidence-based verification results with confidence scores and detailed sourcing.

Demo

Features

  • Multi-method Analysis combining fact-checking, trust chain analysis, and Socratic reasoning
  • AI-Powered Verification using Perplexity’s Sonar, Sonar Deep Research, and Sonar Reasoning models
  • Real-time Processing with parallel execution of multiple analysis methods
  • Evidence-based Results providing sources, confidence scores, and detailed reasoning
  • Clean Architecture with NestJS backend and React frontend
  • Production-Ready with Docker deployment, comprehensive testing, and API documentation
  • Configurable Confidence Scoring with customizable weights and thresholds

Prerequisites

  • Node.js 18+ and npm
  • Perplexity API key (Sonar models access)
  • Docker (optional for deployment)
  • Git for repository cloning

Installation

# Clone the backend repository
git clone https://github.com/anthony-okoye/truth-tracer-backend.git
cd truth-tracer-backend

# Install dependencies
npm install

# Clone the frontend repository
git clone https://github.com/anthony-okoye/truth-tracer-front.git
cd truth-tracer-front

# Install frontend dependencies
npm install

Configuration

Create .env file in the backend directory:
# Required
SONAR_API_KEY=your_perplexity_api_key
SONAR_API_URL=https://api.perplexity.ai

# Optional configuration
SONAR_TIMEOUT=30000
SONAR_MAX_RETRIES=3
CONFIDENCE_WEIGHT_FACT_CHECK=0.35
CONFIDENCE_WEIGHT_TRUST_CHAIN=0.25
CONFIDENCE_WEIGHT_SOCRATIC=0.20

Usage

  1. Start Backend:
   cd truth-tracer-backend
   npm run start:dev
  1. Start Frontend:
   cd truth-tracer-front
   npm start
  1. Access Application: Open http://localhost:3000 in your browser
  2. Analyze Claims:
    • Enter a claim in the text area
    • Click “Analyze Claim” to run fact-checking, trust chain analysis, and Socratic reasoning
    • View results with confidence scores, sources, and detailed explanations

Code Explanation

  • Backend: NestJS application with clean architecture following TypeScript best practices
  • AI Integration: Perplexity Sonar API with three specialized models - Sonar for fact-checking, Sonar Deep Research for trust chain analysis, and Sonar Reasoning for logical evaluation
  • Parallel Processing: Simultaneous execution of all three analysis methods for efficient claim verification
  • Response Sanitization: Custom JSON parsing and validation to handle various API response formats
  • Confidence Scoring: Weighted scoring system combining results from all three analysis methods
  • Frontend: React application with intuitive claim submission interface and detailed results visualization
  • Testing: Comprehensive test suite including unit tests, end-to-end tests, and claim analysis testing

How the Sonar API is Used

TruthTracer leverages Perplexity’s Sonar API through three distinct analysis approaches:
// Parallel execution of multiple Sonar models
const [factCheckResult, trustChainResult, socraticResult] = await Promise.all([
  sonarClient.chat.completions.create({
    model: "sonar",
    messages: [{ role: "user", content: factCheckPrompt }],
    max_tokens: 500
  }),
  sonarClient.chat.completions.create({
    model: "sonar-deep-research", 
    messages: [{ role: "user", content: trustChainPrompt }],
    max_tokens: 2500
  }),
  sonarClient.chat.completions.create({
    model: "sonar-reasoning",
    messages: [{ role: "user", content: socraticPrompt }],
    max_tokens: 4000
  })
]);