# jawad-nsu/factcheckerai architecture

> Architecture diagram of the GitHub repository jawad-nsu/factcheckerai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jawad-nsu/factcheckerai
- Repository: https://github.com/jawad-nsu/factcheckerai

## Overview

##### Project Overview
- This project is a Chrome extension that collects data from the current website (such as URL, page title, full HTML, text, meta, links, and images) and sends it to a backend API for further processing.
- In addition to the extension code, there is a backend API located in the api folder. The backend is likely built using Node.js (as seen by the package.json and server.js) and is responsible for receiving and processing the data collected by the extension.
- There is also a ‘src’ folder that appears to be for the frontend part of the extension (such as the popup UI) and is built using modern JavaScript/React with Vite (given the vite.config.js, .jsx files, etc.).

##### Main Components
a. Chrome Extension Components:
- Manifest & Permissions: The manifest.json file outlines permissions (accessing website content), which ties to the extension’s ability to interact with web pages.
- Content Script (content.js): Injected into webpages; scrapes website data.
- Background Script (background.js): Handles long-running tasks, events, and possibly manages communication between extension parts.

b. Backend API Server:
- API Directory (api folder): Contains server.js, package.json, and related config files. It acts as the endpoint for collected data.

##### Relationships and Data Flow
- The extension’s popup and content script interact – the user triggers data collection from the popup interface.
- Upon triggering, the content script collects website data and sends the data (via a secured POST request) to the backend API endpoint configured in content.js.
- User interaction → Popup UI → Content Script activation
- Content Script → API Server (HTTP POST)
- The background script potentially manages messaging between different parts of the extension or handles additional asynchronous events.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Chrome Extension Domain"
        UT("User Trigger"):::user
        MAN("Manifest & Permissions"):::extension
        CS("Content Script"):::extension
        BS("Background Script"):::extension
        AT("Assets"):::extension

        subgraph "Popup UI"
            PUI1("popup.html & popup.js"):::extension
            APP("src/App.jsx"):::extension
            MAIN("src/main.jsx"):::extension
        end
    end

    subgraph "Backend API Domain"
        API("Backend API Server"):::backend
    end

    UT -->|"clicksIcon"| PUI1
    PUI1 -->|"initiatesDataCollection"| CS
    CS -->|"HTTP_POST"| API
    CS <-->|"messaging"| BS
    PUI1 -->|"sendsMessage"| BS
    MAN -->|"configures"| CS
    MAN -->|"configures"| BS
    MAN -->|"defines"| PUI1
    AT ---|"suppliesAssets"| MAN

    classDef user fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef extension fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFB6C1,stroke:#000,stroke-width:2px;

    click MAN "https://github.com/jawad-nsu/factcheckerai/blob/main/manifest.json"
    click CS "https://github.com/jawad-nsu/factcheckerai/blob/main/content.js"
    click BS "https://github.com/jawad-nsu/factcheckerai/blob/main/background.js"
    click PUI1 "https://github.com/jawad-nsu/factcheckerai/blob/main/popup.html"
    click APP "https://github.com/jawad-nsu/factcheckerai/blob/main/src/App.jsx"
    click MAIN "https://github.com/jawad-nsu/factcheckerai/blob/main/src/main.jsx"
    click AT "https://github.com/jawad-nsu/factcheckerai/tree/main/icons/"
    click API "https://github.com/jawad-nsu/factcheckerai/blob/main/api/server.js"
```
