- What is VeritasAI?
- Key Features
- Quick Start
- System Architecture
- How It Works
- Tech Stack
- Installation
- Configuration
- API Reference
- Project Structure
- Database & Authentication
- Development
- Performance
- Troubleshooting
- Contributing
VeritasAI is an explainable claim verification platform that analyzes misinformation through multi-agent debate and evidence-based reasoning. Instead of providing a black-box verdict, it:
- Retrieves evidence from multiple web sources using a hybrid RAG pipeline
- Generates arguments through competing AI agents (Prosecutor ๐จ and Defender ๐ก๏ธ)
- Synthesizes verdicts via a Judge agent that weighs both sides
- Scores disagreement to measure claim contentiousness
- Exports results as shareable links, PDFs, and historical records
Perfect for journalists, researchers, and fact-checkers who need transparency, not just accuracy.
- โ Agentic Multi-Agent Verification โ LangGraph-orchestrated Prosecutor/Defender/Judge debate system
- โ RAG-Powered Evidence Retrieval โ FAISS semantic ranking + multi-API fallback (SerpAPI, NewsAPI, DuckDuckGo)
- โ Disagreement Scoring โ Quantifies claim contentiousness and agent consensus
- โ
Batch Verification โ Process up to 5 claims concurrently with
/api/verify/batch - โ Confidence Scoring โ Normalized 0-100 confidence with reasoning
- โ Source Attribution โ Evidence cards with domain credibility scores
- โ Claim History โ Persistent SQLite-backed verification history
- โ
Shareable Links โ Short IDs for public claim sharing via
/api/share/{short_id} - โ PDF Export โ Professional verdict reports with evidence summaries
- โ JWT Authentication โ Secure user registration and login
- โ Real-Time Pipeline Visualization โ See each reasoning stage as it executes
- โ Responsive UI โ Modern React 19 + Vite frontend with animations
- โ Multi-LLM Fallback Chain โ Gemini โ Groq โ DeepSeek โ Ollama (local fallback)
- โ Semantic Caching โ Skip re-processing identical claims
- โ API Resilience โ Graceful degradation when external APIs fail
- โ
Health Checks โ Real-time service and LLM provider status at
/api/health
# Navigate to project root
cd fake-news-ai
# Backend: Setup and start (Terminal 1)
cd backend
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python3 -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload
# (In another terminal) Frontend: Setup and start (Terminal 2)
cd frontend/react-app
npm install
npm run dev
# (In third terminal) Optional: Start Ollama for local LLM fallback (Terminal 3)
ollama serveResult:
- Backend running on
http://localhost:8000 - Frontend running on
http://localhost:5173 - Database auto-initializes at
./backend/veritas.db
Verify setup:
curl http://localhost:8000/api/healthflowchart TD
User["๐ค User"]
UI["๐จ React UI"]
API["โ๏ธ FastAPI"]
Cache["๐พ SQLite Cache"]
Retrieval["๐ Evidence Retrieval"]
LLMs["๐ง LLM Fallback Chain"]
Graph["๐ LangGraph"]
PDF["๐ PDF Export"]
User -->|Enter Claim| UI
UI -->|POST /api/verify| API
API -->|Check cache| Cache
Cache -->|Cache Hit| API
Cache -->|Cache Miss| Retrieval
Retrieval -->|FAISS Rank| API
API -->|Run Pipeline| Graph
Graph -->|Prosecutor Argument| LLMs
Graph -->|Defender Argument| LLMs
Graph -->|Judge Synthesis| LLMs
LLMs -->|Verdict + Confidence| Graph
Graph -->|Result| API
API -->|Save History| Cache
API -->|Generate PDF| PDF
API -->|JSON Response| UI
UI -->|Display Results| User
User Input (Claim)
โ
[FastAPI Router] /api/verify
โ
[Cache Check] SQLite claim_hash lookup
โโโ CACHE HIT โ Return cached result
โโโ CACHE MISS โ Continue to:
โ
[Claim Analysis] โ Domain classification (Politics, Health, Science, etc.)
โ
[Retrieval] SerpAPI + NewsAPI + DuckDuckGo
โโโ Get 50-100 raw results
โโโ Filter by relevance (embedding similarity)
โโโ Filter by source credibility
โโโ Rank by FAISS + BM25 hybrid score
โ
[Context Building] Top 10-15 evidence sources
โ
[Prosecutor Agent] "What's wrong with this claim?" (Gemini โ Ollama fallback)
โ
[Defender Agent] "What's right about this claim?" (Gemini โ Ollama fallback)
โ
[Judge Agent] Final verdict (Gemini โ Ollama fallback)
โ
[Disagreement Scoring] Measure prosecutor-defender disagreement
โ
[PDF Export Prep] Generate shareable verdict
โ
[Database Save] Save to claim_history, create short_id
โ
API Response with:
- Verdict (TRUE/FALSE/MIXED/INSUFFICIENT_DATA)
- Confidence (0-100)
- Evidence cards
- Prosecutor/Defender arguments
- Reasoning
- Timing info
flowchart LR
Claim["๐ Claim"]
Decompose["Decompose into queries"]
Search["๐ Multi-API Search"]
Filter["Filter & Prioritize"]
FAISS["๐งฎ FAISS Semantic Rank"]
Context["๐ Build Context"]
Claim --> Decompose
Decompose --> Search
Search -->|SerpAPI| Filter
Search -->|NewsAPI| Filter
Search -->|DuckDuckGo| Filter
Filter --> FAISS
FAISS --> Context
stateDiagram-v2
[*] --> AnalyzeClaim: Extract key entities
AnalyzeClaim --> RetrieveEvidence: Gather supporting/opposing sources
RetrieveEvidence --> ProsecutorAnalysis: "Challenge the claim โ๏ธ"
RetrieveEvidence --> DefenderAnalysis: "Support the claim ๐ก๏ธ"
ProsecutorAnalysis --> JudgeAnalysis: Synthesize evidence
DefenderAnalysis --> JudgeAnalysis
JudgeAnalysis --> Score: Calculate disagreement
Score --> Verdict: "TRUE | FALSE | MISLEADING | UNVERIFIED"
Verdict --> Export: Generate shareable link + PDF
Export --> [*]
<App />
โโ <Routes>
โโ <Home /> # Main verification page
โ โโ <input> Claim entry
โ โโ <PipelineProgress /> # Shows processing stages
โ โโ <VerdictBadge /> # Verdict display
โ โโ <ConfidenceGauge /> # Confidence visualization
โ โโ <AgentCard /> # Prosecutor arguments
โ โโ <AgentCard /> # Defender arguments
โ โโ <EvidenceCard /> # Evidence sources (multiple)
โโ <History /> # Past claims
โ โโ Replay from cache
โโ <Login /> / <Register /> # Auth pages
โโ <Profile /> # User settings
โโ <Stats /> # Statistics dashboard
User enters a claim via the React UI. The claim is tokenized into searchable sub-queries.
System checks SQLite cache for identical claims (hash-based):
- Hit โ Return cached result immediately
- Miss โ Proceed to evidence retrieval
- Query Decomposition โ Break claim into sub-questions
- Multi-Source Retrieval โ Search SerpAPI, NewsAPI, DuckDuckGo in parallel
- Relevance Filtering โ Remove off-topic and low-quality sources using embeddings
- Credibility Scoring โ Rate domain reputation (100 = very trustworthy)
- FAISS Ranking โ Semantic ranking based on embedding similarity
- Result โ Top 10-15 high-quality evidence sources
The Prosecutor agent (powered by Gemini/Ollama):
- Identifies weaknesses in the claim
- Finds contradicting evidence
- Generates structured counter-arguments (3-5 points)
- Assigns strength score:
weak | medium | strong - Cites specific evidence sources
The Defender agent (powered by Gemini/Ollama):
- Identifies strengths in the claim
- Finds supporting evidence
- Generates structured pro-arguments (3-5 points)
- Assigns strength score:
weak | medium | strong - Cites specific evidence sources
The Judge agent (powered by Gemini/Ollama):
- Reviews both prosecutor and defender cases
- Weighs evidence credibility
- Produces final verdict:
TRUE | FALSE | MISLEADING | UNVERIFIED | INSUFFICIENT_DATA - Assigns confidence:
0-100(normalized) - Generates structured reasoning with citations
- Compares Prosecutor and Defender argument strengths
- Returns
disagreement_score: 0.0-1.00.0= Strong consensus (both sides agree)1.0= Maximum disagreement
- Labels as
Low | Medium | Highcontentiousness - Tracks support/contradict counts
- Save to SQLite cache (keyed by claim hash)
- Generate short ID for sharing
- Create verifiable history record
- (Optional) Store to Neo4j knowledge graph
- Generate PDF report
| Technology | Purpose | Version |
|---|---|---|
| React | Interactive component framework | 19.2.4 |
| Vite | Lightning-fast dev server & build | 8.0.1 |
| React Router | Client-side navigation | 7.13.1 |
| Axios | HTTP client for API calls | 1.13.6 |
| Framer Motion | Smooth animations & transitions | 12.38.0 |
| Chart.js | Analytics dashboard charts | 4.5.1 |
| Lucide React | Beautiful icon library | 1.0.0 |
| Tailwind CSS | Utility-first styling | via tailwind-merge |
| Technology | Purpose | Version |
|---|---|---|
| FastAPI | High-performance async REST API | 0.111.0 |
| Uvicorn | ASGI server with auto-reload | 0.29.0 |
| SQLAlchemy | ORM for database operations | 2.0.30 |
| SQLite | Local persistent database | built-in |
| LangGraph | Agent orchestration & state management | 0.2.66 |
| Pydantic | Data validation & serialization | via SQLAlchemy |
| JWT + bcrypt | Secure authentication | python-jose, passlib |
| Technology | Purpose | Version |
|---|---|---|
| LangChain | LLM and agent utilities | compatibility layer |
| FAISS | Vector similarity search & ranking | 1.8.0 (CPU) |
| Sentence-Transformers | Semantic embeddings | 2.7.0 |
| SerpAPI | Google Search integration | 2.4.2 |
| NewsAPI | News articles retrieval | 0.2.7 |
| DuckDuckGo Search | Privacy-respecting web search | 8.1.1 |
| Provider | Model | Purpose | Status |
|---|---|---|---|
| Google Gemini | 2.5-flash | Primary fast reasoning | โ Active |
| Groq | llama-3.3-70b | High-quality analysis | |
| DeepSeek | reasoner | Extended reasoning | |
| Ollama | llama3.2:1b | Local fallback inference | โ Recommended |
| Technology | Purpose | Version |
|---|---|---|
| ReportLab | PDF generation | 4.5.0 |
| Beautiful Soup 4 | HTML parsing | 4.12.3 |
| lxml | XML/HTML processing | 5.3.0 |
| FeedParser | RSS/feed parsing | 6.0.11 |
| Neo4j | Graph database (optional) | 5.19.0 |
- Python 3.10 or higher
- Node.js 18+ and npm 9+
- Optional: Ollama runtime for local LLM fallback
- Optional: Neo4j server for knowledge graph features
cd backend
python3 -m venv venvWhy venv?
- Isolates Python packages from system Python
- Prevents dependency conflicts with other projects
- Makes deployment reproducible
- Allows exact version pinning
# macOS/Linux
source venv/bin/activate
# Windows PowerShell
venv\Scripts\Activate.ps1
# Windows Command Prompt
venv\Scripts\activate.batYou'll see: (venv) prefix in terminal = activated
pip install --upgrade pip setuptools wheel
pip install -r requirements.txtInstallation time: ~2-5 minutes depending on internet speed
# Check key packages
python3 -c "import fastapi, sentence_transformers, faiss; print('โ All imports OK')"python3 -m uvicorn main:app --host 0.0.0.0 --port 8000 --reloadHealth check:
curl http://localhost:8000/api/healthcd frontend/react-app
npm install --legacy-peer-deps
# Or for reproducible install from lock file:
npm ciNote: npm ci is preferred in CI/production; npm install updates lock file
npm run lint # Check for syntax errors
npm run build # Test production buildBuild should complete in <30 seconds
npm run dev -- --host 0.0.0.0 --port 5173Open in browser: http://localhost:5173
For local LLM fallback (recommended for development):
# Download and start Ollama from https://ollama.ai
# In a separate terminal, ensure Ollama is running:
ollama serve
# Pull a model (default is llama3.2):
ollama pull llama3.2:1b
# Verify connection:
curl http://localhost:11434/api/version| Service | Port | Protocol | Purpose |
|---|---|---|---|
| Backend API | 8000 | HTTP | FastAPI endpoints |
| Frontend Dev | 5173 | HTTP | Vite dev server |
| Ollama LLM | 11434 | HTTP | Local LLM server |
| SQLite DB | - | File | ./veritas.db |
| Neo4j (optional) | 7687 | Bolt | Graph database |
Create backend/.env file:
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# SECURITY & CORE
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
SECRET_KEY=change_this_for_production_use_openssl_rand_hex_32
# Used for: JWT token signing, password hashing
# Generate with: openssl rand -hex 32
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
# For production: https://yourdomain.com
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# DATABASE
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
DATABASE_URL=sqlite:///./veritas.db
# Local SQLite: creates veritas.db in backend/ folder
# PostgreSQL: postgresql://user:password@localhost/veritas
# MySQL: mysql://user:password@localhost/veritas
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# SEARCH APIs (ACTIVE)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
NEWSAPI_KEY=your_newsapi_key_here
# https://newsapi.org - News aggregation (100 req/day free)
# Sign up: https://newsapi.org/register
SERPAPI_KEY=your_serpapi_key_here
# https://serpapi.com - Google Search results (100 req/month free)
# Sign up: https://serpapi.com
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# LLM PROVIDERS - PRIMARY
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
GEMINI_API_KEY=your_gemini_api_key
# https://ai.google.dev - Get key from Google AI Studio
# Model: gemini-2.5-flash (fast, free tier available)
GEMINI_MODEL=gemini-2.5-flash
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# LLM PROVIDERS - SECONDARY (Legacy, optional)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
GROQ_API_KEY=your_groq_api_key
GROQ_DEFENDER_MODEL=llama-3.1-8b-instant
GROQ_JUDGE_MODEL=llama-3.3-70b-versatile
DEEPSEEK_API_KEY=your_deepseek_api_key
DEEPSEEK_BASE_URL=https://api.deepseek.com
DEEPSEEK_MODEL=deepseek-reasoner
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# LLM PROVIDERS - FALLBACK (LOCAL)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_ANALYZER_MODEL=llama3.2:1b
OLLAMA_MODEL=mistral:latest
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# OPTIONAL: Neo4j Knowledge Graph
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your-neo4j-password| Service | Free Tier | Link |
|---|---|---|
| SerpAPI | 100 req/month | serpapi.com |
| NewsAPI | 100 req/day | newsapi.org |
| Google Gemini | 60 req/min | ai.google.dev |
| Groq | 7500 req/day | groq.com |
| DeepSeek | $5 free credit | platform.deepseek.com |
Backend CORS Settings:
CORS_ORIGINS=http://localhost:5173What this means:
- Frontend on
http://localhost:5173can make API calls tohttp://localhost:8000 - Prevents cross-origin request blocking
- For production, update to your domain:
CORS_ORIGINS=https://yourdomain.com
Verify a single claim with full multi-agent pipeline.
Request:
{
"claim": "The Earth orbits the Sun"
}Response:
{
"success": true,
"claim": "The Earth orbits the Sun",
"verdict": "TRUE",
"confidence": 98,
"disagreement_score": 0.05,
"contentiousness": "Low",
"reasoning": "Scientific consensus confirms...",
"prosecutor_analysis": {
"arguments": ["..."],
"strength": "weak"
},
"defender_analysis": {
"arguments": ["..."],
"strength": "strong"
},
"evidence": [
{
"title": "Earth's Orbit",
"url": "https://example.com",
"domain": "nasa.gov",
"snippet": "...",
"relevance_score": 0.95,
"credibility": 98
}
],
"history_id": "12345",
"short_id": "abc123",
"cache_hit": false,
"processing_time_seconds": 45.23
}Verify up to 5 claims concurrently.
Request:
{
"claims": [
"Claim 1",
"Claim 2",
"Claim 3"
]
}Response:
{
"results": [
{ /* verify response */ },
{ /* verify response */ },
{ /* verify response */ }
],
"total_time_seconds": 120.5
}Quick verification wrapper around /verify.
Retrieve user's claim verification history.
Response:
{
"claims": [
{
"id": 1,
"claim": "Sample claim",
"verdict": "TRUE",
"confidence": 85,
"timestamp": "2026-05-11T10:30:00Z",
"short_id": "abc123",
"domain": "health"
}
],
"is_authenticated": true,
"total": 42
}Retrieve detailed verification snapshot.
Response: Full verification response (same as /api/verify)
Download PDF report for a verification.
Example:
curl -o verdict.pdf http://localhost:8000/api/export/pdf/12345Public view of a shared verification (no auth required).
Register new user.
Request:
{
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword123"
}Response:
{
"id": 1,
"username": "johndoe",
"email": "john@example.com",
"created_at": "2026-05-11T10:30:00Z"
}Login user.
Request:
{
"username": "johndoe",
"password": "securepassword123"
}Response:
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"token_type": "bearer",
"user": {
"id": 1,
"username": "johndoe",
"email": "john@example.com"
}
}Get current authenticated user.
Check username availability.
Check email availability.
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET | Service health + LLM provider status |
/api/stats |
GET | Aggregate verification statistics |
/api/trending |
GET | Top trending claims being verified |
/api/sources |
GET | Supported evidence sources metadata |
fake-news-ai/
โโโ README.md # Main documentation (this file)
โโโ PROJECT_SETUP_GUIDE.md # Detailed setup reference (deprecated, merged here)
โโโ .github/
โ โโโ workflows/
โ โโโ secret-scan.yml # GitHub Actions CI/CD
โโโ .gitleaks.toml # Secret scanning config
โโโ .pre-commit-config.yaml # Pre-commit hooks
โ
โโโ backend/
โ โโโ main.py # FastAPI app + route handlers
โ โโโ agents.py # LangGraph orchestrator
โ โโโ state.py # VerificationState definition
โ โโโ rag_core.py # RAG pipeline (FAISS ranking)
โ โโโ retrieval.py # Multi-source evidence retrieval
โ โโโ filters.py # Source quality filters
โ โโโ credibility.py # Domain credibility scoring
โ โโโ database.py # SQLAlchemy models + ORM
โ โโโ auth.py # JWT authentication logic
โ โโโ pdf_export.py # ReportLab PDF generation
โ โโโ llm_client.py # Multi-LLM fallback chain
โ โโโ gemini_client.py # Gemini-specific client
โ โ
โ โโโ agents/
โ โ โโโ claim_analyzer.py # Entity extraction + analysis
โ โ โโโ prosecutor.py # Prosecutor agent
โ โ โโโ defender.py # Defender agent
โ โ โโโ judge.py # Judge agent (verdict synthesis)
โ โ โโโ source_tracker.py # Evidence attribution
โ โ
โ โโโ rag/
โ โ โโโ embeddings.py # Sentence transformer wrappers
โ โ โโโ faiss_store.py # FAISS vector store
โ โ โโโ retriever.py # RAG retriever interface
โ โ โโโ knowledge_base.py # Knowledge base indexing
โ โ โโโ realtime_fetcher.py # Real-time source fetching
โ โ
โ โโโ services/
โ โ โโโ cache_service.py # Semantic caching
โ โ โโโ credibility_service.py # Credibility scoring
โ โ โโโ evidence_classifier.py # Evidence categorization
โ โ โโโ metrics_service.py # Analytics/metrics
โ โ โโโ ranking_service.py # Evidence ranking utilities
โ โ โโโ llm_client.py # LLM provider integration
โ โ
โ โโโ tests/
โ โ โโโ conftest.py # pytest configuration
โ โ โโโ test_gemini.py # Gemini integration tests
โ โ โโโ test_pipeline_recovery.py # Fallback mechanism tests
โ โ โโโ test_retriever_*.py # RAG pipeline tests
โ โ โโโ test_search_apis.py # Search API tests
โ โ
โ โโโ data/
โ โ โโโ news_articles.json # Sample dataset
โ โ โโโ faiss_vectors.npy # Pre-computed embeddings
โ โ
โ โโโ requirements.txt # Python dependencies (100+ packages)
โ โโโ .env.example # Environment variable template
โ โโโ start.sh # Backend startup script
โ โโโ veritas.db # SQLite database (auto-created)
โ
โโโ frontend/react-app/
โโโ package.json # Node dependencies
โโโ vite.config.js # Vite build configuration
โโโ eslint.config.js # Linting rules
โ
โโโ src/
โ โโโ main.jsx # App entry point
โ โโโ App.jsx # Root component
โ โโโ App.css # Global styles
โ โ
โ โโโ pages/
โ โ โโโ Home.jsx # Main verification workflow
โ โ โโโ History.jsx # Claim history + replay
โ โ โโโ Stats.jsx # Analytics dashboard
โ โ โโโ Login.jsx # User login
โ โ โโโ Register.jsx # User registration
โ โ โโโ Profile.jsx # User profile
โ โ
โ โโโ components/
โ โ โโโ AgentCard.jsx # Prosecutor/Defender card
โ โ โโโ EvidenceCard.jsx # Evidence item display
โ โ โโโ ConfidenceGauge.jsx # Confidence meter
โ โ โโโ VerdictBadge.jsx # Verdict display badge
โ โ โโโ PipelineProgress.jsx # Real-time pipeline stages
โ โ โโโ SkeletonLoader.jsx # Loading placeholder
โ โ โโโ MetricsPanel.jsx # Statistics panel
โ โ โโโ ui/ # Reusable UI elements
โ โ
โ โโโ hooks/
โ โ โโโ useVoice.js # Voice input/output (optional)
โ โ
โ โโโ services/
โ โ โโโ api.js # Axios API client
โ โ
โ โโโ lib/
โ โ โโโ utils.ts # Utility functions
โ โ
โ โโโ assets/ # Images, logos, icons
โ
โโโ public/ # Static assets
โโโ start.sh # Frontend startup script
โโโ index.html # HTML entry point
CREATE TABLE users (
id INTEGER PRIMARY KEY,
username VARCHAR(64) UNIQUE NOT NULL,
email VARCHAR(128) UNIQUE NOT NULL,
hashed_password VARCHAR(256) NOT NULL,
created_at DATETIME DEFAULT NOW(),
is_active BOOLEAN DEFAULT TRUE
);CREATE TABLE claim_history (
id INTEGER PRIMARY KEY,
user_id INTEGER FOREIGN KEY,
claim_text TEXT NOT NULL,
verdict VARCHAR(32) NOT NULL, -- TRUE/FALSE/MIXED/INSUFFICIENT_DATA
confidence FLOAT NOT NULL, -- 0.0-100.0
domain VARCHAR(64) DEFAULT "general", -- Category (Politics, Health, etc.)
timestamp DATETIME DEFAULT NOW(),
short_id VARCHAR(16) UNIQUE, -- For sharing
bookmarked BOOLEAN DEFAULT FALSE,
details_json TEXT -- Full response JSON
);CREATE TABLE claim_cache (
claim_hash VARCHAR(64) PRIMARY KEY, -- SHA256 hash
result_json TEXT NOT NULL,
timestamp DATETIME DEFAULT NOW(),
ttl_seconds INTEGER DEFAULT 604800 -- 7 days
);- Registration โ Backend hashes password with bcrypt โ Stores in DB
- Login โ Verifies password โ Generates JWT token (24-hour expiration)
- API Requests โ Include
Authorization: Bearer <token>header - Token Verification โ JWT decoded and validated on each request
- Logout โ Frontend removes token from localStorage
Token Structure (JWT):
Header: {"alg": "HS256", "typ": "JWT"}
Payload: {"sub": "username", "exp": 1234567890, "iat": 1234567890}
Signature: HMACSHA256(header.payload, SECRET_KEY)
Terminal 1 โ Backend:
cd fake-news-ai/backend
source venv/bin/activate
python3 -m uvicorn main:app --reload --port 8000Terminal 2 โ Frontend:
cd fake-news-ai/frontend/react-app
npm run dev -- --host 0.0.0.0 --port 5173Terminal 3 โ Ollama (optional):
ollama serveBackend:
# Create optimized build
cd backend
python3 -m uvicorn main:app --host 0.0.0.0 --port 8000
# With gunicorn for production:
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:appFrontend:
cd frontend/react-app
npm run build # Creates dist/ folder (~500KB minified)
npm run preview # Preview production build locallyBackend Tests:
cd backend
pytest tests/ -vFrontend Build Check:
cd frontend/react-app
npm run lint
npm run buildPre-commit Hooks (Secret Scanning):
# Install pre-commit
pip install pre-commit
# Setup git hooks
pre-commit install
# Run gitleaks scan
pre-commit run gitleaks --all-files| Stage | Duration | Notes |
|---|---|---|
| Claim Analysis | 5-10s | Entity extraction + decomposition |
| Evidence Retrieval | 8-15s | Multi-API search + FAISS ranking |
| Prosecutor Agent | 60-90s | Argument generation |
| Defender Agent | 60-90s | Argument generation |
| Judge Agent | 90-120s | Verdict synthesis |
| Total Pipeline | 220-325s | Full end-to-end processing |
Optimization Strategies:
- โ Semantic caching (skip re-processing identical claims)
- โ Parallel evidence retrieval across APIs
- โ FAISS indexing for fast semantic search
- โ Frontend request timeout: 600s (10 minutes)
- โ LLM context window limits to prevent slowdown
- โ Keep-alive settings on Ollama for warm model state
If primary LLM fails:
- Gemini (primary) โ timeout
- Groq (secondary) โ timeout
- DeepSeek (tertiary) โ timeout
- Ollama (local fallback) โ use local inference
- Deterministic โ return structured placeholder verdict
API remains responsive even when external services degrade.
- JWT-based stateless auth
- bcrypt password hashing (cost factor: 12)
- Secure token expiration (24 hours)
- HTTPS support (production deployment)
- Local SQLite storage (no cloud transmission by default)
- Optional Neo4j isolation
- CORS restrictions (configurable per domain)
.envfiles (ignored in version control)- GitHub Actions secret scanning (gitleaks)
- Pre-commit hooks for leak prevention
- No hardcoded credentials in source code
- Rate limiting (configurable)
- Input validation via Pydantic
- SQL injection prevention (SQLAlchemy ORM)
- CSRF protection (session-based)
Error: ModuleNotFoundError: No module named 'fastapi'
# Forgot to activate venv
source venv/bin/activate
pip install -r requirements.txtError: Port 8000 already in use
# Kill process using port
lsof -ti:8000 | xargs kill -9
# Or use different port
python3 -m uvicorn main:app --port 8001Error: [LLM] Gemini: DISABLED and OLLAMA: http://localhost:11434 unreachable
# Check Gemini key in .env
grep GEMINI_API_KEY backend/.env
# Or start Ollama
ollama serve # In another terminalError: sqlite3.OperationalError: database is locked
# Close any connections, then try again
# Or remove old database and restart
rm backend/veritas.db
python3 -m uvicorn main:app --port 8000 --reloadError: npm: command not found
# Install Node.js from https://nodejs.org
node --version # Should be 16+
npm --version # Should be 8+Error: Cannot GET http://localhost:5173
# Vite dev server not running
cd frontend/react-app
npm install
npm run devError: POST /api/verify 500 Internal Server Error
- Check backend logs:
tail -f backend/veritas_debug.log - Verify .env files are correct
- Check API keys (Gemini, NewsAPI, SerpAPI)
- Ensure Ollama is running if using fallback
Error: ERR_CONNECTION_REFUSED or CORS error
# 1. Verify backend is running on port 8000
curl http://localhost:8000/docs
# 2. Check CORS_ORIGINS in backend/.env
cat backend/.env | grep CORS_ORIGINS
# Should be: http://localhost:5173
# 3. Check frontend .env
cat frontend/react-app/.env
# Should be: VITE_API_BASE_URL=http://localhost:8000
# 4. Check CORS middleware in backend/main.pyError: npm install fails with peer dependency warnings
npm install --legacy-peer-depsNewsAPI 401 Unauthorized:
# Check key in .env
grep NEWSAPI_KEY backend/.env
# Test key manually
curl "https://newsapi.org/v2/everything?q=covid&apiKey=YOUR_KEY"Gemini API quota exceeded:
# Check quota at https://console.cloud.google.com
# Or switch to Ollama for local-only operation
# Edit .env: GEMINI_API_KEY=DISABLEDVerification takes >10 seconds:
-
Check retrieval: Is NewsAPI/SerpAPI responding?
curl https://newsapi.org/v2/everything?q=test curl https://serpapi.com/search?q=test
-
Check LLM provider: Are Gemini/Ollama responsive?
curl http://localhost:11434/api/generate
-
Enable query caching:
# In backend/main.py, set: ENABLE_ADVANCED_CACHE = True -
Check database size:
ls -lh backend/veritas.db # If >100MB, consider archive old data
Lost data in veritas.db?
# Backup database before deleting
cp backend/veritas.db backend/veritas.db.backup
rm backend/veritas.db
# Restart backend to recreate with fresh schemaBe respectful, inclusive, and constructive in all interactions.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit with clear messages:
git commit -m "Add feature X" - Run tests:
pytest tests/ornpm run lint - Push to your fork
- Open a Pull Request with description
- Use GitHub Issues
- Include: Python/Node version, environment, reproduction steps, error logs
- Attach relevant code snippets
- Open a GitHub Discussion
- Explain use case and expected behavior
- Reference related issues
- Python: PEP 8 (via pylint/flake8)
- JavaScript: ESLint with React rules
- Commits: Clear, descriptive messages
- Documentation: Docstrings and comments for complex logic
| Metric | Value |
|---|---|
| Python Files | 40+ |
| React Components | 15+ |
| API Endpoints | 11 |
| Database Tables | 3 |
| Dependencies | 100+ |
| Test Suite | 8+ test files |
| Documentation | 2000+ lines |
Built with:
- LangGraph for agent orchestration
- FastAPI for REST API
- React + Vite for frontend
- FAISS for vector search
- LLM Providers (Gemini, Groq, DeepSeek, Ollama)
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: Contact via GitHub profile
This project is provided as-is for educational and research purposes.
Made with โค๏ธ for transparent, explainable AI fact-checking
Last Updated: May 11, 2026