How youcef3939/trace works
Purpose and Runtime
TRACE is a Next.js/React media-information-literacy platform. Users submit text, URLs, or images for an explainable, evidence-grounded investigation rather than a bare truth verdict. The App Router supplies both rendered pages and Node-backed route handlers. Primary shell and landing entry points are app/layout.tsx, app/page.tsx, and app/globals.css.
User-Facing Investigation Experience
The investigation workflow is exposed at app/investigate/page.tsx, with its main interactive presentation in components/InvestigateExperience.tsx and components/InvestigationLive.tsx. The browser submits user material to app/api/investigate/route.ts; the returned investigation chain is rendered as a guided, inspectable experience rather than a single score.
Investigation Pipeline
lib/pipeline/runInvestigation.ts is the orchestration boundary for the core verification flow. It composes:
• claim identification: lib/pipeline/extractClaims.ts
• source-origin analysis: lib/pipeline/traceSource.ts
• supporting/contradicting web evidence: lib/pipeline/retrieveEvidence.ts
• final evidence-based judgment: lib/pipeline/assess.ts
This separation makes individual stages independently replaceable while preserving a single API-level workflow.
AI, Retrieval, and Grounding Boundaries
LLM-facing work is concentrated in pipeline stages, while web retrieval is abstracted through lib/tavily.ts and lib/verifySearch.ts. lib/manipulationSignals.ts adds heuristic indicators such as potentially misleading framing. The intended control flow is: submitted content → extracted claims → source/evidence retrieval → assessment with explanation. Retrieval results are the factual boundary that should constrain generated assessments.
Image/OCR Input Path
Image submission is handled independently by app/api/ocr/route.ts, with eng.traineddata available as OCR language data. OCR-derived text can then enter the same investigation pipeline as typed or pasted content, keeping multimodal ingestion separate from claim assessment.
Learning and Lab Modes
Educational content is delivered through app/learn/page.tsx, components/LearnContent.tsx, and the explanatory site sections. A separate interactive practice mode lives at app/lab/page.tsx; components/lab/LabGame.tsx drives the challenge UI using local claim content in lib/lab/claims.ts. Lab evaluation is exposed through app/api/lab/evaluate/route.ts, separating pedagogy/game state from real-content investigations.
Persistence and Data Model
Supabase is the persistence integration boundary, initialized through lib/supabase.ts with relational schema definitions in supabase/schema.sql. Investigation/source/evidence relationships are modeled for durable history and traceability. Shared trace-oriented types are centralized in types/trace.ts, providing a contract between pipeline/API output and UI consumers.
Supporting Site Surface
Informational routes—app/how-it-works/page.tsx, app/resources/page.tsx, and app/about/page.tsx—frame the product and learning model. Shared navigation and framing are provided by components/Nav.tsx, components/Footer.tsx, and reusable presentation components, while API routes remain the operational boundary for OCR, investigations, and lab evaluation.
Main entry points: runInvestigation.ts Investigation orchestrator · InvestigateExperience.tsx Investigation experience · route.ts Investigation API · retrieveEvidence.ts Evidence retrieval
Components 25
Next.js App
Rendered routes and Node-backed API handlers.
- App shell
app/layout.tsx - Landing page
app/page.tsx - Investigate route
app/investigate/page.tsx - Investigation API · Operational boundary for submitted investigation material.
app/api/investigate/route.ts - OCR API · Separates image transcription from claim assessment.
app/api/ocr/route.ts - Learning content
app/learn/page.tsx - Lab route
app/lab/page.tsx - Lab evaluation API
app/api/lab/evaluate/route.ts
User Experiences
Interactive investigation, learning, and practice interfaces.
- Investigation experience · Guided, inspectable rendering of the investigation chain.
components/InvestigateExperience.tsx - Live investigation view
components/InvestigationLive.tsx - Learning experience
components/LearnContent.tsx - Lab game · Practice challenges using local claims rather than real investigations.
components/lab/LabGame.tsx
Investigation Pipeline
Replaceable stages for evidence-grounded assessment.
- Investigation orchestrator · Composes the verification workflow into one API-level flow.
lib/pipeline/runInvestigation.ts - Claim extraction
lib/pipeline/extractClaims.ts - Source tracing
lib/pipeline/traceSource.ts - Evidence retrieval
lib/pipeline/retrieveEvidence.ts - Evidence assessment · Produces an explained judgment constrained by retrieved evidence.
lib/pipeline/assess.ts
Data & Integrations
Retrieval, persistence, and shared contracts.
- OCR language data
eng.traineddata - Web retrieval adapters
lib/tavily.ts - Verification search
lib/verifySearch.ts - Manipulation signals · Adds indicators such as misleading framing.
lib/manipulationSignals.ts - Trace contract · Contract between pipeline/API output and UI consumers.
types/trace.ts - Supabase persistence · Stores durable investigation, source, and evidence history.
lib/supabase.ts - Trace schema · Models investigation, source, and evidence relationships.
supabase/schema.sql - Lab claims
lib/lab/claims.ts
Connections 26
- App shell → Landing page: frames
- App shell → Investigate route: frames
- Investigate route → Investigation experience: renders
- Investigation experience → OCR API: submits image
- OCR language data → OCR API: OCR data
- OCR API → Investigation API: OCR text
- Investigation experience → Investigation API: submits text or URL
- Investigation API → Investigation orchestrator: runs
- Investigation orchestrator → Claim extraction: extracts
- Claim extraction → Source tracing: claims
- Source tracing → Evidence retrieval: origin context
- Evidence retrieval → Evidence assessment: grounding evidence
- Web retrieval adapters → Evidence retrieval: web results
- Verification search → Evidence retrieval: verification results
- Manipulation signals → Evidence assessment: heuristics
- Evidence assessment → Investigation orchestrator: explained judgment
- Investigation orchestrator → Supabase persistence: persists trace
- Trace schema → Supabase persistence: defines relations
- Investigation orchestrator → Trace contract: returns contract
- Trace contract → Live investigation view: typed result
- Investigation API → Live investigation view: investigation chain
- Investigation experience → Live investigation view: renders
- Learning content → Learning experience: renders
- Lab route → Lab game: renders
- Lab claims → Lab game: challenge content
- Lab game → Lab evaluation API: submits evaluation