# srichu05/truthlens-ai architecture

> Architecture diagram of the GitHub repository srichu05/truthlens-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/srichu05/truthlens-ai
- Repository: https://github.com/srichu05/truthlens-ai

## Overview

TruthLens AI is a web platform for assessing news credibility. A user submits text, a URL, or a document through the analyzer; the backend extracts claims, combines heuristic signals with fact-check evidence, and returns a verdict with supporting explanations. The product also provides authentication, analysis history, dashboards, real-article corrections, shared results, and PDF reports. The README documents the verification stages, while sampled source confirms application routing, API/auth behavior, persistence setup, and fact-check lookup/cache behavior; unsampled implementation details limit some wiring shown here.

Main entry points: [`src/services/api.ts`](https://github.com/srichu05/truthlens-ai/blob/main/src/services/api.ts) (API client), [`backend/app/api/analyzer.py`](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/analyzer.py) (Analysis endpoints), [`src/pages/RealArticles.tsx`](https://github.com/srichu05/truthlens-ai/blob/main/src/pages/RealArticles.tsx) (Article browsing), [`backend/app/api/real_articles.py`](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/real_articles.py) (Real-article endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["App routing<br/>[App.tsx]"]
  node_analyzer_ui["News analyzer<br/>[NewsAnalyzer.tsx]"]
  node_history_ui["History and dashboard"]
  node_articles_ui["Article browsing<br/>[RealArticles.tsx]"]
  node_detail_ui["Article detail"]
  node_shared_ui["Shared result"]
  node_profile_ui["Profile and auth<br/>[Profile.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_pdf["PDF report<br/>[pdfGenerator.ts]"]
end

subgraph group_analysis["Credibility analysis"]
  node_analyzer_api["Analysis endpoints<br/>[analyzer.py]"]
  node_scraper["Web and file input<br/>[web_scraper.py]"]
  node_nlp["Claim extraction<br/>[nlp_analyzer.py]"]
  node_verdict["Verdict and explanation<br/>[analyzer.py]"]
end

subgraph group_accounts["Accounts and history"]
  node_history_api["History endpoints<br/>[history.py]"]
  node_auth_api["Auth endpoints<br/>[auth.py]"]
  node_database[("Application database<br/>[session.py]")]
  node_models["User and analysis records<br/>[analysis.py]"]
end

subgraph group_articles["Real articles"]
  node_real_api["Real-article endpoints<br/>[real_articles.py]"]
  node_real_service["Article sourcing<br/>[real_articles.py]"]
end

subgraph group_evidence["Evidence services"]
  node_factcheck["Claim verification"]
  node_cache[("Fact-check cache<br/>[factcheck_cache.py]")]
end

node_reader(("News reader"))
node_registry["Global fact-check registry"]
node_supabase_auth["Supabase Auth"]

node_reader -->|"opens"| node_app
node_app -->|"routes to"| node_analyzer_ui
node_analyzer_ui -->|"submits input"| node_api_client
node_api_client -->|"requests analysis"| node_analyzer_api
node_analyzer_api -->|"extracts content"| node_scraper
node_analyzer_api -->|"extracts claims"| node_nlp
node_analyzer_api -->|"checks claims"| node_factcheck
node_factcheck -->|"reads and writes"| node_cache
node_factcheck -.->|"queries reviews"| node_registry
node_analyzer_api -->|"synthesizes result"| node_verdict
node_verdict -->|"returns result"| node_api_client
node_reader -->|"views analyses"| node_history_ui
node_history_ui -->|"requests history"| node_api_client
node_api_client -->|"requests records"| node_history_api
node_history_api -->|"reads and writes"| node_database
node_models -->|"maps records"| node_database
node_reader -->|"signs in"| node_profile_ui
node_profile_ui -->|"authenticates"| node_api_client
node_api_client -->|"uses auth"| node_supabase_auth
node_api_client -.->|"checks backend session"| node_auth_api
node_reader -->|"browses articles"| node_articles_ui
node_articles_ui -->|"requests articles"| node_api_client
node_api_client -->|"requests articles"| node_real_api
node_real_api -->|"loads articles"| node_real_service
node_real_api -->|"reads and writes"| node_database
node_articles_ui -->|"selects article"| node_detail_ui
node_reader -->|"opens shared result"| node_shared_ui
node_verdict -->|"formats report"| node_pdf

click node_app "https://github.com/srichu05/truthlens-ai/blob/main/src/App.tsx"
click node_analyzer_ui "https://github.com/srichu05/truthlens-ai/blob/main/src/pages/NewsAnalyzer.tsx"
click node_history_ui "https://github.com/srichu05/truthlens-ai/blob/main/src/pages/AnalysisHistory.tsx"
click node_articles_ui "https://github.com/srichu05/truthlens-ai/blob/main/src/pages/RealArticles.tsx"
click node_detail_ui "https://github.com/srichu05/truthlens-ai/blob/main/src/pages/RealArticleDetail.tsx"
click node_shared_ui "https://github.com/srichu05/truthlens-ai/blob/main/src/pages/SharedResultPage.tsx"
click node_profile_ui "https://github.com/srichu05/truthlens-ai/blob/main/src/pages/Profile.tsx"
click node_api_client "https://github.com/srichu05/truthlens-ai/blob/main/src/services/api.ts"
click node_pdf "https://github.com/srichu05/truthlens-ai/blob/main/src/utils/pdfGenerator.ts"
click node_analyzer_api "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/analyzer.py"
click node_scraper "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/web_scraper.py"
click node_nlp "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/nlp_analyzer.py"
click node_factcheck "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/factcheck_service.py"
click node_cache "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/factcheck_cache.py"
click node_verdict "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/analyzer.py"
click node_history_api "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/history.py"
click node_auth_api "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/auth.py"
click node_real_api "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/real_articles.py"
click node_real_service "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/real_articles.py"
click node_database "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/db/session.py"
click node_models "https://github.com/srichu05/truthlens-ai/blob/main/backend/app/models/analysis.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_analyzer_ui,node_history_ui,node_articles_ui,node_detail_ui,node_shared_ui,node_profile_ui,node_api_client,node_pdf toneBlue
class node_analyzer_api,node_scraper,node_nlp,node_verdict toneAmber
class node_history_api,node_auth_api,node_database,node_models toneMint
class node_real_api,node_real_service toneRose
class node_factcheck,node_cache,node_reader,node_registry,node_supabase_auth toneIndigo
```

## Components

### Web application

- [App routing](https://github.com/srichu05/truthlens-ai/blob/main/src/App.tsx): `src/App.tsx`
- [News analyzer](https://github.com/srichu05/truthlens-ai/blob/main/src/pages/NewsAnalyzer.tsx): `src/pages/NewsAnalyzer.tsx`
- [History and dashboard](https://github.com/srichu05/truthlens-ai/blob/main/src/pages/AnalysisHistory.tsx): `src/pages/AnalysisHistory.tsx`
- [Article browsing](https://github.com/srichu05/truthlens-ai/blob/main/src/pages/RealArticles.tsx): `src/pages/RealArticles.tsx`
- [Article detail](https://github.com/srichu05/truthlens-ai/blob/main/src/pages/RealArticleDetail.tsx): `src/pages/RealArticleDetail.tsx`
- [Shared result](https://github.com/srichu05/truthlens-ai/blob/main/src/pages/SharedResultPage.tsx): `src/pages/SharedResultPage.tsx`
- [Profile and auth](https://github.com/srichu05/truthlens-ai/blob/main/src/pages/Profile.tsx): `src/pages/Profile.tsx`
- [API client](https://github.com/srichu05/truthlens-ai/blob/main/src/services/api.ts): `src/services/api.ts`
- [PDF report](https://github.com/srichu05/truthlens-ai/blob/main/src/utils/pdfGenerator.ts): `src/utils/pdfGenerator.ts`

### Credibility analysis

- [Analysis endpoints](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/analyzer.py): `backend/app/api/analyzer.py`
- [Web and file input](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/web_scraper.py): `backend/app/services/web_scraper.py`
- [Claim extraction](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/nlp_analyzer.py): `backend/app/services/nlp_analyzer.py`
- [Verdict and explanation](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/analyzer.py): `backend/app/api/analyzer.py`

### Accounts and history

- [History endpoints](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/history.py): `backend/app/api/history.py`
- [Auth endpoints](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Application database](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [User and analysis records](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/models/analysis.py): `backend/app/models/analysis.py`

### Real articles

- [Real-article endpoints](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/api/real_articles.py): `backend/app/api/real_articles.py`
- [Article sourcing](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/real_articles.py): `backend/app/services/real_articles.py`

### Evidence services

- [Claim verification](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/factcheck_service.py): `backend/app/services/factcheck_service.py`
- [Fact-check cache](https://github.com/srichu05/truthlens-ai/blob/main/backend/app/services/factcheck_cache.py): `backend/app/services/factcheck_cache.py`

### Other components

- **News reader**
- **Global fact-check registry**
- **Supabase Auth**

## Connections

- News reader → App routing: opens
- App routing → News analyzer: routes to
- News analyzer → API client: submits input
- API client → Analysis endpoints: requests analysis
- Analysis endpoints → Web and file input: extracts content
- Analysis endpoints → Claim extraction: extracts claims
- Analysis endpoints → Claim verification: checks claims
- Claim verification → Fact-check cache: reads and writes
- Claim verification → Global fact-check registry: queries reviews
- Analysis endpoints → Verdict and explanation: synthesizes result
- Verdict and explanation → API client: returns result
- News reader → History and dashboard: views analyses
- History and dashboard → API client: requests history
- API client → History endpoints: requests records
- History endpoints → Application database: reads and writes
- User and analysis records → Application database: maps records
- News reader → Profile and auth: signs in
- Profile and auth → API client: authenticates
- API client → Supabase Auth: uses auth
- API client → Auth endpoints: checks backend session
- News reader → Article browsing: browses articles
- Article browsing → API client: requests articles
- API client → Real-article endpoints: requests articles
- Real-article endpoints → Article sourcing: loads articles
- Real-article endpoints → Application database: reads and writes
- Article browsing → Article detail: selects article
- News reader → Shared result: opens shared result
- Verdict and explanation → PDF report: formats report
