# 21prnv/satyacheck architecture

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

- Interactive diagram: https://gitdiagram.com/21prnv/satyacheck
- Repository: https://github.com/21prnv/satyacheck

## Overview

##### Project Type and Purpose
- SatyaCheck is a fact‑checking solution composed of two front‑end clients:
- A Next.js web application (“satyacheck‑web”) that provides a dashboard, login/auth flows, and displays historical analyses and user profiles.
- A Chrome browser extension (“satyacheck‑extension”) that runs directly in the user’s browser, scrapes the current page, submits content for verification, and shows results in a popup.
- Both clients rely on Supabase for data persistence (user accounts, audit logs, saved analyses) and on Google Gemini AI for real‑time content analysis.

##### File Structure
- Top level: two sibling directories, satyacheck‑web (Next.js) and satyacheck‑extension (Vite + React).
- satyacheck‑web:
- `app/` directory with Next.js 13 route handlers, server‑side actions, auth callbacks, and page components.
- `components/` UI & layout building blocks.
- `utils/` wrappers for Supabase client (both server and browser), motion utils, middleware.
- `next.config.ts`, Tailwind & PostCSS configs, type configs, package.json.
- satyacheck‑extension:
- `src/background.ts` orchestrates extension lifecycle & messaging.
- `src/content.ts` injects into page context to scrape and send data.
- `src/geminiClient.ts` handles calls to Google Gemini AI.
- `src/utils/supabaseClient.ts` for writing/reading to Supabase.
- `src/components/` React popup UI.
- Vite config, tsconfig files.

##### README for Insights
- The README explicitly calls out:
- Two main deliverables (web + extension).
- Feature list: Gemini AI integration, authenticity scoring, cross‑reference checks, author verification, Supabase storage.
- Environment variables for each client.
- This confirms a “JAMstack + serverless” architecture with no dedicated monolithic backend: Supabase provides auth, database, and edge functions; Gemini is an external AI service.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Chrome Extension"
        direction TB
        subgraph "Popup UI"
            direction TB
            App["App.tsx"]:::frontend
            Main["main.tsx"]:::frontend
            ComponentsExt["components/"]:::frontend
        end
        Background["Background Script"]:::frontend
        Content["Content Script"]:::frontend
        GeminiClient["GeminiClient"]:::frontend
        SupabaseClientExt["SupabaseClient"]:::frontend
        Messaging["Chrome Messaging Hook"]:::frontend
    end

    subgraph "Next.js Web App"
        direction TB
        Pages["Client Pages & Layout"]:::frontend
        ServerActions["Server Actions & API Routes"]:::frontend
        UIComponents["UI Components"]:::frontend
        SupabaseUtils["Supabase Utilities"]:::frontend
        Configs["Config & Middleware"]:::frontend
    end

    subgraph "Supabase"
        direction TB
        Auth["Auth Service"]:::backend
        DB["Database"]:::backend
    end

    GeminiAI["Google Gemini AI"]:::external
    ExternalSources["External Source APIs"]:::external

    %% Extension flows
    ComponentsExt -->|chrome.runtime.sendMessage| Messaging
    Messaging -->|chrome.runtime.onMessage| Background
    Background -->|chrome.runtime.sendMessage| Content
    Content -->|scraped content| Background
    Background -->|HTTPS REST| GeminiAI
    Background -->|HTTPS REST| DB
    ComponentsExt -->|display results| Background

    %% Web App flows
    Pages -->|calls| ServerActions
    ServerActions -->|reads/writes| DB
    Pages -->|reads| DB
    Pages -->|auth| Auth
    ServerActions -->|HTTPS REST| ExternalSources

    %% Click Events
    click App "https://github.com/21prnv/satyacheck/blob/main/satyacheck-extension/src/App.tsx"
    click Main "https://github.com/21prnv/satyacheck/blob/main/satyacheck-extension/src/main.tsx"
    click ComponentsExt "https://github.com/21prnv/satyacheck/tree/main/satyacheck-extension/src/components/"
    click Background "https://github.com/21prnv/satyacheck/blob/main/satyacheck-extension/src/background.ts"
    click Content "https://github.com/21prnv/satyacheck/blob/main/satyacheck-extension/src/content.ts"
    click GeminiClient "https://github.com/21prnv/satyacheck/blob/main/satyacheck-extension/src/geminiClient.ts"
    click SupabaseClientExt "https://github.com/21prnv/satyacheck/blob/main/satyacheck-extension/src/utils/supabaseClient.ts"
    click Messaging "https://github.com/21prnv/satyacheck/blob/main/satyacheck-extension/src/hooks/useChromeMessaging.ts"
    click Pages "https://github.com/21prnv/satyacheck/blob/main/satyacheck-web/app/page.tsx"
    click ServerActions "https://github.com/21prnv/satyacheck/blob/main/satyacheck-web/app/actions/auth.ts"
    click UIComponents "https://github.com/21prnv/satyacheck/tree/main/satyacheck-web/components/"
    click SupabaseUtils "https://github.com/21prnv/satyacheck/blob/main/satyacheck-web/utils/supbase/client.ts"
    click Configs "https://github.com/21prnv/satyacheck/blob/main/satyacheck-web/next.config.ts"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
```
