# rpanigrahi222/intruth-factcheck architecture

> Architecture diagram of the GitHub repository rpanigrahi222/intruth-factcheck, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rpanigrahi222/intruth-factcheck
- Repository: https://github.com/rpanigrahi222/intruth-factcheck

## Overview

1. **What this repo is**
   - This is a **Chrome Manifest V3 extension** called *InTruth* / *realtime-factcheck*.
   - Its purpose is to **listen to the active tab’s audio**, transcribe speech in real time, detect check-worthy claims, and show verdicts and evidence back to the user while the event is still happening.

2. **Top-level runtime split**
   - The architecture is split across the standard extension contexts:
     - **Popup UI** for user control and configuration
     - **Background service worker** for orchestration
     - **Content script** for in-page overlay and page interaction
     - **Offscreen document** for audio/transcription work that can’t live in the service worker
   - `manifest.json` is the key boundary definition for permissions, injections, and context wiring.

3. **Popup as the control plane**
   - `src/popup/popup.html`, `popup.js`, and `popup.css` implement the extension’s front door.
   - This is where the user likely starts/stops a session, supplies their **bring-your-own Anthropic API key**, and sets session options.
   - The popup is the only obvious user-facing configuration surface; it likely writes to extension-local storage and sends commands into the runtime.

4. **Background service worker as orchestrator**
   - `src/background/service-worker-ex.js` is the central coordinator.
   - In an MV3 extension, this is typically responsible for:
     - receiving commands from the popup,
     - managing session state,
     - triggering tab audio capture,
     - routing messages between popup, offscreen page, and content script,
     - and handling lifecycle/event transitions.
   - This is the main integration boundary between UI intent and the real-time processing pipeline.

5. **Offscreen document for audio processing**
   - `src/offscreen/offscreen.html` and `offscreen-ex.js` implement the audio-processing worker surface.
   - The README and permissions indicate this is where **tab audio capture / transcription** happens, since the extension uses `offscreen` plus `tabCapture`.
   - Architecturally, this isolates long-running media work from the ephemeral service worker and keeps transcription alive as a separate browser context.

6. **Content script for on-page presentation**
   - `src/content/overlay.js`, `overlay.css`, and related files inject the in-page UI shown during a live session.
   - This overlay is the user’s real-time view of detected claims, verdicts, and explanations.
   - Because it runs in the page context, it acts as the bridge from extension state to something visually anchored on the active tab.

7. **Claim and transcript feature extraction**
   - `src/content/lexical-features.js` suggests a local feature layer for analyzing text patterns, likely used to detect or rank candidate claims.
   - `src/content/session-export.js` indicates session data can be packaged out of the live flow, probably for review or research use.
   - These files suggest a separation between **raw transcript handling** and **higher-level claim selection / session reporting**.

8. **Real-time data flow**
   - The likely flow is:
     1. User starts a session in the popup.
     2. Background service worker requests active-tab audio capture.
     3. Offscreen page receives audio and performs transcription.
     4. Transcript chunks are analyzed for check-worthy claims.
     5. Claim text and context are sent for AI/evidence evaluation.
     6. Results are returned to the background/content layer.
     7. The overlay displays verdicts and sources in real time.
   - This is a streaming pipeline, not a batch workflow.

9. **External AI/service boundary**
   - The README states users provide their own **Anthropic API key**.
   - That means the extension has a hard trust boundary: transcript data may leave the browser and be sent to the user-configured AI service for fact-checking.
   - The repo explicitly positions this as **local control of credentials**, with no operator-managed API key backend.

10. **Local state and privacy boundary**
   - The `storage` permission and README indicate user preferences and API configuration are stored **locally in the browser**.
   - There is no sign of a server-side component in this repo.
   - Architecturally, this is a client-only extension with external API calls only to user-chosen services.

11. **Permissions-driven architecture**
   - The extension depends on `tabCapture`, `activeTab`, `scripting`, `storage`, and `offscreen`.
   - These permissions directly map to the main subsystems:
     - `tabCapture` → audio ingestion
     - `activeTab` / `scripting` → page targeting and injection
     - `offscreen` → media/transcription worker
     - `storage` → local config/session state

12. **Assets and packaging**
   - `assets/` likely contains icons or static resources used by the extension UI and store packaging.
   - `LICENSE` and README indicate a standalone open-source extension project, not a multi-service app.

13. **Diagram takeaway**
   - The cleanest architecture diagram should show a **browser extension with four contexts**:
     - user popup,
     - background orchestrator,
     - offscreen audio/transcription worker,
     - content overlay injected into the page.
   - Around that, show two external dependencies:
     - the **active browser tab’s audio/video stream** as the input source,
     - and **Anthropic / other AI services** as the verdict-generation boundary.

Main entry points: [`realtime-factcheck/src/background/service-worker-ex.js`](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/background/service-worker-ex.js) (Orchestrator), [`realtime-factcheck/manifest.json`](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/manifest.json) (Manifest), [`realtime-factcheck/src/content/overlay.js`](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/content/overlay.js) (Overlay UI), [`realtime-factcheck/src/popup/popup.js`](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/popup/popup.js) (Popup logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo["Extension"]
  node_manifest["Manifest<br/>mv3 config<br/>[manifest.json]"]
  node_popup_html["Popup UI<br/>control panel<br/>[popup.html]"]
  node_popup_js["Popup logic<br/>ui controller<br/>[popup.js]"]
  node_service_worker["Orchestrator<br/>background worker"]
  node_offscreen_html["Offscreen page<br/>media host<br/>[offscreen.html]"]
  node_offscreen_js["Audio worker<br/>transcription worker<br/>[offscreen-ex.js]"]
  node_overlay_js["Overlay UI<br/>content script<br/>[overlay.js]"]
  node_overlay_css["Overlay style<br/>in-page styling<br/>[overlay.css]"]
  node_lexical_features["Claim features<br/>text analysis"]
  node_session_export["Session export<br/>reporting<br/>[session-export.js]"]
end

subgraph group_page["Browser page"]
  node_tab_audio[("Tab audio<br/>browser media source")]
  node_active_tab["Active tab<br/>browser target"]
end

subgraph group_external["External boundary"]
  node_anthropic_api(("Anthropic API<br/>external fact-checking"))
  node_local_storage[("Local storage<br/>browser state")]
  node_assets["Assets<br/>static resources"]
end

node_manifest -->|"defines UI"| node_popup_html
node_manifest -->|"registers worker"| node_service_worker
node_manifest -->|"enables offscreen"| node_offscreen_html
node_manifest -->|"injects content"| node_overlay_js
node_popup_html -->|"loads logic"| node_popup_js
node_popup_js -->|"commands"| node_service_worker
node_service_worker -->|"reads/writes"| node_local_storage
node_service_worker -->|"captures"| node_tab_audio
node_service_worker -->|"routes audio"| node_offscreen_js
node_offscreen_html -->|"hosts"| node_offscreen_js
node_offscreen_js -->|"transcripts"| node_service_worker
node_service_worker -->|"analyzes text"| node_lexical_features
node_service_worker -->|"verdict requests"| node_anthropic_api
node_service_worker -->|"pushes results"| node_overlay_js
node_overlay_js -->|"styles"| node_overlay_css
node_overlay_js -->|"renders in"| node_active_tab
node_service_worker -->|"packages session"| node_session_export
node_popup_js -->|"configures"| node_local_storage
node_service_worker -.->|"uses assets"| node_assets

click node_manifest "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/manifest.json"
click node_popup_html "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/popup/popup.html"
click node_popup_js "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/popup/popup.js"
click node_service_worker "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/background/service-worker-ex.js"
click node_offscreen_html "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/offscreen/offscreen.html"
click node_offscreen_js "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/offscreen/offscreen-ex.js"
click node_overlay_js "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/content/overlay.js"
click node_overlay_css "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/content/overlay.css"
click node_lexical_features "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/content/lexical-features.js"
click node_session_export "https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/content/session-export.js"
click node_assets "https://github.com/rpanigrahi222/intruth-factcheck/tree/master/realtime-factcheck/assets"

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_manifest,node_popup_html,node_popup_js,node_service_worker,node_offscreen_html,node_offscreen_js,node_overlay_js,node_overlay_css,node_lexical_features,node_session_export toneBlue
class node_tab_audio,node_active_tab toneAmber
class node_anthropic_api,node_local_storage,node_assets toneMint
```

## Components

### Extension

Core Manifest V3 extension contexts and shared configuration

- [Manifest](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/manifest.json): mv3 config · Defines permissions, contexts, and extension wiring · `realtime-factcheck/manifest.json`
- [Popup UI](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/popup/popup.html): control panel · User-facing entry point for starting sessions and setting credentials · `realtime-factcheck/src/popup/popup.html`
- [Popup logic](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/popup/popup.js): ui controller · Handles user actions and sends commands into the extension runtime · `realtime-factcheck/src/popup/popup.js`
- [Orchestrator](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/background/service-worker-ex.js): background worker · Central coordinator for session state, messaging, and lifecycle events · `realtime-factcheck/src/background/service-worker-ex.js`
- [Offscreen page](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/offscreen/offscreen.html): media host · Hidden extension context used to keep audio and transcription work alive · `realtime-factcheck/src/offscreen/offscreen.html`
- [Audio worker](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/offscreen/offscreen-ex.js): transcription worker · Processes captured audio and produces transcript output · `realtime-factcheck/src/offscreen/offscreen-ex.js`
- [Overlay UI](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/content/overlay.js): content script · Injects the live verdict and claim display into the active tab · `realtime-factcheck/src/content/overlay.js`
- [Overlay style](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/content/overlay.css): in-page styling · Styles the injected live overlay · `realtime-factcheck/src/content/overlay.css`
- [Claim features](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/content/lexical-features.js): text analysis · Local feature layer for spotting or ranking check-worthy claims · `realtime-factcheck/src/content/lexical-features.js`
- [Session export](https://github.com/rpanigrahi222/intruth-factcheck/blob/master/realtime-factcheck/src/content/session-export.js): reporting · Packages live-session data for later review or export · `realtime-factcheck/src/content/session-export.js`

### Browser page

The active tab and injected in-page surface

- **Tab audio**: browser media source · Audio stream captured from the active tab
- **Active tab**: browser target · Current page where audio is captured and overlay is injected

### External boundary

Local browser state and remote AI/service dependencies

- **Anthropic API**: external fact-checking · Remote model service used for verdict generation with user-provided credentials
- **Local storage**: browser state · Stores API key, preferences, and session state in the browser
- [Assets](https://github.com/rpanigrahi222/intruth-factcheck/tree/master/realtime-factcheck/assets): static resources · Extension icons and other packaged static files · `realtime-factcheck/assets`

## Connections

- Manifest → Popup UI: defines UI · Registers the popup entry point and extension surface
- Manifest → Orchestrator: registers worker · Declares the background service worker and permissions
- Manifest → Offscreen page: enables offscreen · Allows hidden audio/transcription context
- Manifest → Overlay UI: injects content · Wires page scripting and content-script execution
- Popup UI → Popup logic: loads logic · Popup markup is driven by popup behavior
- Popup logic → Orchestrator: commands · User actions are sent to the orchestrator
- Orchestrator → Local storage: reads/writes · Persists configuration and session state locally
- Orchestrator → Tab audio: captures · Starts and manages audio ingestion from the active tab
- Orchestrator → Audio worker: routes audio · Delegates media processing to the offscreen worker
- Offscreen page → Audio worker: hosts · Hidden page loads the transcription worker logic
- Audio worker → Orchestrator: transcripts · Streams transcript chunks back to the orchestrator
- Orchestrator → Claim features: analyzes text · Uses text features to identify check-worthy claims
- Orchestrator → Anthropic API: verdict requests · Sends candidate claims for fact-checking and evidence retrieval
- Orchestrator → Overlay UI: pushes results · Delivers live verdicts and evidence to the page overlay
- Overlay UI → Overlay style: styles · Overlay behavior is rendered with its companion stylesheet
- Overlay UI → Active tab: renders in · Displays live results inside the current page
- Orchestrator → Session export: packages session · Prepares live session data for export or review
- Popup logic → Local storage: configures · Stores API key and user preferences locally
- Orchestrator → Assets: uses assets · Shared packaged resources for extension UI and branding
