Skip to content

d-m-g/Coral-fact-checker

Repository files navigation

Coral

A modern fact-checking web application that analyzes claims using multiple sources to provide balanced, evidence-based assessments.

Features

  • Multi-source Analysis: Compare supporting and contradicting sources side-by-side
  • Confidence Scoring: Get a 0-100 confidence score with detailed rationale
  • Regional Context: Filter results by region (Global, EU, Finland, USA , Custom)
  • Clean UI: Modern, responsive design with a green theme
  • Example Claims: Quick-start with pre-loaded example claims

Setup

  1. Install dependencies:
npm install
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000 in your browser

How It Works (Stub)

Currently, Coral uses a deterministic stub provider that simulates fact-checking without making real API calls. This allows for:

  • Deterministic Results: The same claim always produces the same results (based on claim hash)
  • Realistic Latency: Simulates network delay (700-1200ms)
  • Diverse Sources: Uses a pool of 30+ realistic sources across various domains
  • Domain Diversity: Ensures no duplicate domains appear in results
  • Smart Confidence: Calculates confidence based on claim specificity (numbers, dates, locations)

Stub Behavior

The stub provider:

  1. Hashes the input claim + region to create a deterministic seed
  2. Selects 3 supporting and 3 contradicting sources from a curated pool
  3. Calculates confidence based on:
    • Claim specificity (presence of numbers, dates, locations)
    • Support/contradict ratio
    • Penalties for underspecified claims
  4. Generates rationale bullets explaining the confidence score
  5. Returns results with realistic structure matching the expected API format

Architecture

The app is built with a provider pattern that makes it easy to swap the stub with real API calls:

  • lib/provider.ts: Defines the ClaimCheckProvider interface
  • lib/stubProvider.ts: Implements the stub (current)
  • lib/types.ts: Zod schemas and TypeScript types
  • lib/utils.ts: Utility functions (hashing, formatting, etc.)

To integrate a real API, simply:

  1. Create a new provider class implementing ClaimCheckProvider
  2. Replace StubClaimCheckProvider with your real provider in app/page.tsx

Project Structure

├── app/
│   ├── layout.tsx          # Root layout
│   ├── page.tsx            # Main page component
│   └── globals.css         # Global styles
├── components/
│   ├── ClaimForm.tsx       # Input form component
│   ├── ResultsSummary.tsx  # Confidence score & rationale
│   ├── SourceColumn.tsx   # Column wrapper for sources
│   ├── SourceCard.tsx     # Individual source card
│   └── SkeletonResults.tsx # Loading skeleton
├── lib/
│   ├── types.ts           # Zod schemas & TypeScript types
│   ├── provider.ts        # Provider interface
│   ├── stubProvider.ts    # Stub implementation
│   └── utils.ts          # Utility functions
└── package.json

Tech Stack

  • Next.js 14 (App Router)
  • TypeScript
  • Tailwind CSS
  • Zod (validation)
  • Client-side only (no backend)

Future Enhancements

The codebase includes TODO comments for future improvements:

  • Replace stub provider with real retrieval (OWI / search API)
  • Add server route /api/check (optional)
  • Add citation extraction and quote highlighting
  • Add filters (date range, language)
  • Add export to JSON / shareable link

License

MIT

About

Fact-check from multiple sources, not a single authority.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors