AI-powered medical misinformation detection. Users submit a piece of health-related content — pasted text, a URL, or a document (PDF/TXT/MD) — and VeriTrust returns an evidence-grounded verdict: Verdadero (true), Falso (false), Parcialmente falso (partly false), or Dudoso (uncertain), with a confidence score, a per-claim breakdown, the biomedical sources consulted, and a medical report explaining the verdict in plain Spanish.
Health misinformation spreads faster than experts can debunk it. VeriTrust automates the first pass of that debunking: it extracts the verifiable medical claims from a text, cross-checks each one against real biomedical literature (Europe PMC, PubMed, openFDA, AEMPS CIMA), derives a verdict from the stance of that literature, and writes up the result — with the honesty to say "Dudoso" and lower its confidence when the literature is thin, contradictory, or silent.
How it works
Analysis is asynchronous: the pipeline chains several LLM calls and literature lookups, so it runs in a background worker instead of the HTTP request. POST /analysis returns a pending id immediately; an arq worker picks the job off Redis, runs the LangGraph pipeline, and the frontend polls GET /analysis/{id} every 2 s (showing the live pipeline stage) until the verdict is ready.
flowchart TB
UI["Next.js frontend<br/>(Clerk auth)"]
subgraph WEB["Web process — FastAPI"]
API["POST /analysis → insert 'pending' row, enqueue job<br/>GET /analysis/{id} → status + result"]
end
PG[("PostgreSQL<br/>analyses, claims, sources")]
REDIS[("Redis<br/>arq job queue")]
subgraph WORKER["Worker process — arq (python -m app.worker)"]
PREP["Prepare input<br/>URL / file text extraction"]
subgraph GRAPH["LangGraph pipeline"]
EX["1 · Extractor<br/>claims + search queries + drug terms"]
TR["2 · Translator<br/>clinical English, one batched call"]
IN["3 · Investigator<br/>evidence retrieval + relevance judge"]
HE["4 · Health Expert<br/>evidence verdict + medical report"]
EX --> TR --> IN --> HE
end
PREP --> EX
end
LLM["LLM provider<br/>Mistral API (compose) · Ollama (local default)"]
LIT["Europe PMC · PubMed · openFDA · AEMPS CIMA"]
UI -- "JWT" --> API
API --> PG
API -- "enqueue" --> REDIS
REDIS --> PREP
EX -.-> LLM
TR -.-> LLM
IN -.-> LLM
HE -.-> LLM
IN --> LIT
HE -- "verdict · claims · sources · report" --> PG
UI -- "poll every 2s" --> API
The four agents
| Agent | Model | What it does |
|---|---|---|
| Extractor | llama3 |
Extracts the verifiable medical claims from the input text, plus an English boolean search query and the drug name (if any) for each claim. Structured output. |
| Translator | translategemma |
Translates all claims to clinical English in a single batched call — the literature sources work in English. |
| Investigator | ministral-3:14b¹ |
Queries Europe PMC, PubMed, and openFDA for every claim in parallel — plus AEMPS CIMA when the claim names a drug. An LLM judge filters the hits for relevance and tags each source's stance (supports / contradicts). Computes evidence coverage: the share of claims with relevant literature. |
| Health Expert | llama3.2 |
Derives each claim's fake probability from the stance of the retrieved literature (Laplace-smoothed, so thin evidence never reaches certainty), and bands each claim into true, false or uncertain — a band around the decision threshold maps to uncertain, and a claim no source speaks to is uncertain by construction, never false. The overall verdict follows from the claims' verdicts: true and false claims together make it partly false. Then it writes the medical report with llama3.2, grounded in the retrieved sources. |
¹ The ministral-3:14b judge needs ~11 GB loaded, ideally on a 16 GB GPU.
Three guardrails temper the raw verdict (app/core/verdict.py):
- Evidence attenuation — confidence is scaled down when little of the input is covered by actual literature, so the system never sounds sure about claims nobody has studied.
- Silence is not falsehood — a claim no retrieved source speaks to comes out Dudoso by construction, never Falso, and Laplace smoothing keeps thin evidence away from certainty.
- A truth never offsets a falsehood — a hoax wrapped in true statements comes out Parcialmente falso, not Verdadero (ADR-0002).
Product surface
- Analysis of pasted text, URLs (SSRF-hardened fetching), and uploaded PDF/TXT/MD files (≤ 10 MB), with per-stage progress while pending and retry for failed runs.
- Per-claim breakdown — each extracted claim gets its own verdict and confidence, alongside the sources that support or contradict it.
- History with search, pagination, and CSV export (formula-injection safe).
- Dashboard with aggregate metrics over your analyses.
- Public share links — a read-only
/r/{token}page per analysis, revocable. - Auth & limits — Clerk JWT on every API route, per-user rate limiting on submission.
Stack
- Backend — FastAPI + arq worker (Python 3.11), LangGraph, LangChain + Mistral/Ollama, raw async SQL via psycopg3 (no ORM)
- Frontend — Next.js 16 (App Router), React 19, Clerk, SWR, Tailwind CSS v4
- Data — PostgreSQL 16, Redis 7 (job queue)
- Evaluation — pipeline evaluation harness in
backend/evaluation/, scored against HealthVer and a hand-written Spanish gold set; seedocs/experiments/ - Ops — Docker Compose with healthchecks + autoheal, Caddy TLS reverse proxy, GitHub Actions CI/CD deploying to an EU VPS
Repository layout
backend/
app/ FastAPI service: routes, agents, db, schemas, prompts
evaluation/ Pipeline evaluation harness (separate test suite)
data/ HealthVer splits + gold_es.jsonl hand-written gold set (committed)
db/migrations/ Database schema as ordered SQL migrations (app/db/migrate.py)
frontend/
src/ Next.js App Router app
docs/
adr/ Architecture decision records
deploy/ Production runbooks (secrets, backups, monitoring, ops)
experiments/ Pipeline evaluation lab notebook
docker-compose.yml Local/full stack
docker-compose.prod.yml Production overlay: Caddy TLS + memory caps
Running it
Prerequisites
- Docker (for the compose stack) — or, for running processes natively: Python 3.11+ with
uv, Node.js 22+ withpnpm11 (corepack enable), PostgreSQL, Redis, and a Mistral, Groq, Google AI Studio or NVIDIA API key, or an Ollama install - A free Clerk application (authentication) — copy its JWKS URL, issuer, audience, secret key, and publishable key into
.env
Quick start — Docker
cp .env.example .env # set POSTGRES_PASSWORD, REDIS_PASSWORD and the Clerk publishable key
cp backend/.env.example backend/.env # set the LLM provider's API key, the Clerk JWKS values, and DATABASE_URL
cp frontend/.env.example frontend/.env # set the Clerk keys and API URLs
docker compose up -d --build
Frontend at http://localhost:3000, API at http://localhost:8000 (health at /healthz). The compose stack wires everything: Postgres, a one-shot migrate service that applies pending schema migrations before the API and worker start, Redis, the API, the worker, the frontend, and an autoheal sidecar that restarts any container whose healthcheck fails.
The worker defaults to LLM_PROVIDER=mistral, so agent calls go to the Mistral API; set LLM_PROVIDER=groq plus GROQ_API_KEY (or LLM_PROVIDER=google plus GOOGLE_API_KEY) in backend/.env to route them elsewhere. Either way the worker refuses to start without the chosen provider's key. For self-hosted inference, set LLM_PROVIDER=ollama, start the stack with docker compose --profile ollama up -d --build (or set COMPOSE_PROFILES=ollama in .env), and pull the models (docker compose exec ollama ollama pull llama3.2 && docker compose exec ollama ollama pull translategemma && docker compose exec ollama ollama pull ministral-3:14b).
Local development (processes on your machine)
cp backend/.env.example backend/.env # fill in DATABASE_URL, REDIS_URL, Clerk values
cp frontend/.env.example frontend/.env # fill in NEXT_PUBLIC_API_URL + Clerk keys
ollama pull llama3 && ollama pull llama3.2 && ollama pull translategemma && ollama pull ministral-3:14b
uv sync --directory backend --frozen
uv run --directory backend python -m app.db.migrate # apply pending schema migrations
uv run --directory backend uvicorn app.main:app # API → http://localhost:8000
uv run --directory backend python -m app.worker # worker (separate terminal)
pnpm --dir frontend install
pnpm --dir frontend dev # → http://localhost:3000
Required backend env: DATABASE_URL, CLERK_JWKS_URL, CLERK_AUDIENCE, CLERK_SECRET_KEY, STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, STRIPE_PRICE_PRO_MONTHLY, STRIPE_PRICE_PRO_YEARLY (and CORS_ALLOWED_ORIGINS outside ENVIRONMENT=development). Missing config surfaces at startup and as a /healthz 503, not as per-request 500s. See backend/.env.example for every knob (Ollama models/timeouts, evidence-source URLs, queue tuning, rate limits).
Production (VPS + Caddy TLS)
The production deployment is the same compose stack on a single EU VPS, behind a Caddy reverse proxy that terminates TLS (automatic Let's Encrypt) for the app domain (frontend; www. redirects to it) and the API domain (backend). The overlay unpublishes every port except Caddy's 80/443 and adds per-container memory caps.
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
Requires DNS A records for the app domain, its www. and the API domain, inbound 80/443, and APP_DOMAIN/API_DOMAIN/ACME_EMAIL in .env. NEXT_PUBLIC_API_URL is baked into the frontend at build time, so a domain change needs --build, not just a restart. Add https://<app domain> as an allowed origin in Clerk.
CI/CD: every push to main runs CI (.github/workflows/ci.yml); on success, .github/workflows/deploy.yml SSHes into the VPS, dumps the database to ~/backups/, and redeploys the stack (migrations included). Operational runbooks live in docs/deploy/:
- vps-setup.md — first-time server setup, from SSH keys to the first deploy
- env.md — the three production env files and how to change them
- backups.md — automated
pg_dumpbackups - monitoring.md — uptime checks + alerting
- ops.md — hardening, log rotation, day-2 operations
- stripe.md — Stripe Dashboard setup, local billing development and webhook operations
Development
All commands run from the repo root. CI enforces every gate below.
# Backend
uv run --directory backend pytest tests --cov=app --cov-fail-under=80 # app tests
uv run --directory backend pytest evaluation/tests --cov=evaluation --cov-fail-under=80 # evaluation tests (needs --extra evaluation)
uv run --directory backend ruff check app evaluation tests # lint
uv run --directory backend ruff format app evaluation tests # format
uv run --directory backend mypy # type-check
# Frontend
pnpm --dir frontend lint
pnpm --dir frontend typecheck # tsc, including tests
pnpm --dir frontend test # vitest
pnpm --dir frontend build # production build (also type-checks)
- Typed API contract —
frontend/src/types/api.d.tsis generated from the backend's OpenAPI spec. After any backend schema change runpnpm --dir frontend generate:api-types(backend running); never edit it by hand. - Database schema — ordered SQL files in
backend/db/migrations/, applied byapp/db/migrate.py(the composemigrateservice runs it on everyup). To change the schema, add the next numbered file; never edit one that has been applied — the runner refuses to start if an applied file changed. See ADR-0004. - Prompts — all agent system prompts live in
backend/app/prompts/prompts.yaml, never inline in Python. - Pipeline evaluation —
evaluation/evaluate_pipeline.pyruns the full four-agent pipeline against labeled HealthVer samples (or--partition gold) and reports classification metrics.
License
GNU Affero General Public License v3.0 — see LICENSE. Copyright (C) 2026 Lucas del Villar.
Earlier versions were released under the MIT License and remain available under it.
