← Back to ThinkTrace

How ThinkTrace works

The technical architecture behind the 4-agent parallel reasoning pipeline, triple-store data layer, and enterprise security model.

Architecture

Parser runs first and extracts all claims. Then Mapper, Detector, and Verifier fire simultaneously via ThreadPoolExecutor, reducing analysis time from ~90 seconds sequential to ~20 seconds parallel. The Epistemic Scorer synthesises all findings last.

# Execution flow
Parser ──────────────────────────────────► Claims
├── Mapper ──► Argument graph + validity scores
├── Detector ► Named fallacies + severity
└── Verifier ► Fact verdicts (5 sources async)
└── Epistemic Scorer ──► 0–100 score

The 4 Agents

Parser

Reads your content and extracts every distinct claim like premises, conclusions, and supporting sub-claims. Tracks attribution metadata to distinguish the author's own assertions from reported views.

Implementation: Sends a structured extraction prompt to Claude Sonnet. Returns typed claims with confidence scores and attribution flags.

Mapper

Builds a directed argument graph showing which claims support which, which contradict each other, and where the reasoning chain breaks. Scores each logical connection 0.0–1.0 for validity.

Implementation: Uses brace-counting JSON extraction to parse Claude's response into nodes and edges. Identifies missing premises and circular reasoning.

Detector

Identifies named logical fallacies with severity ratings. Only fires on the author's own claims, not on views attributed to others. Each fallacy is explained in plain language.

Implementation: Context-aware prompt includes content type metadata. Encyclopedic content is handled differently from direct arguments.

Verifier

Fact-checks every verifiable claim against 5 live sources simultaneously: Google Search, Wikipedia, ArXiv, PubMed, and NewsAPI. Each claim gets a verdict and source attribution.

Implementation: Smart routing. Medical claims hit PubMed, scientific claims hit ArXiv, current events hit NewsAPI. All sources run in parallel with 8-second per-source timeouts.

Triple Store Data Layer

Every analysis is saved to three stores simultaneously, each optimised for a different access pattern.

PostgreSQL
Primary store

Full analysis records, user accounts, org data. SQLAlchemy QueuePool with 10 base + 20 overflow connections.

Pinecone
Vector search

384-dim semantic embeddings per analysis, namespaced by org. Enables similarity search across past analyses.

Neo4j Aura
Graph queries

Org → User → Analysis → Claim → Fallacy graph. Enables cross-analysis queries and relationship traversal.

Production Readiness

Horizontal scaling
Stateless API. Redis holds all shared state (token blacklist, rate limits, OTP). Add instances without coordination.
Rate limiting
Per-IP limits on every endpoint. Register: 5/hr, Login: 20/hr, OTP: 10/10min, Analyze: 3/day guest / 100/hr authenticated. 50 analyses/month per org.
Security
bcrypt passwords, JWT blacklist on logout, brute force lockout after 5 attempts, OTP single-use with 10min TTL, CORS locked to frontend domain.
Reliability
Content hash caching (24hr TTL, ~460ms on hit). Celery task_acks_late + reject_on_worker_lost. Graceful degradation if Neo4j or Redis unavailable.
Observability
LangSmith traces every Claude call. Request ID on every response. Health endpoint verifies DB + Redis. Structured logging across all agents.
Load tested
4 simultaneous authenticated analyses completed in 19–24 seconds with zero failures. True parallel execution across Gunicorn workers confirmed.

Full Stack

AI Orchestration

LangGraph
LangChain
LangSmith

LLM

Claude API (Sonnet)
4 parallel agents
Epistemic scoring

Async Queue

Celery workers
Redis broker
Upstash Redis

Data

PostgreSQL
Neo4j graph
Pinecone vectors

Fact Checking

Serper Search
Wikipedia API
ArXiv + PubMed + News

Backend

FastAPI
JWT + OTP Auth
Multi-tenant orgs

Frontend

Next.js 14
TypeScript
Tailwind CSS

Infrastructure

Railway cloud
GitHub Actions CI
Docker
View on GitHub →API Documentation →← Back to app