# panduthegang/verifai-news_detection-system architecture

> Architecture diagram of the GitHub repository panduthegang/verifai-news_detection-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/panduthegang/verifai-news_detection-system
- Repository: https://github.com/panduthegang/verifai-news_detection-system

## Overview

##### Project Type & Purpose
- Type: A single-page, front-end-centric, React-TypeScript application that leverages BaaS (Firebase) and external AI/ML services.
- Purpose: Provide AI-powered content verification and analytics (credibility scoring, bias detection, OCR, news monitoring) with multilingual support.

##### File Structure
- Top-level:
- public/: static assets, HTML, locale JSON
- src/: React app (pages/, components/, lib/, utils/, i18n/)
- config files: Vite, Tailwind, ESLint, Firebase
- Key directories:
- src/pages: Route-level React components (Home, Analysis, News, Social…)
- src/components: Reusable UI pieces, patterns, charts, chatbot, private routes
- src/lib: Firebase setup (auth.ts, firestore.ts), utility functions
- src/utils: Wrappers around AI & search APIs (geminiHelper, serperApi, imageAnalyzer, newsAnalyzer)
- No custom backend: all “server” functionality is via Firebase (Authentication + Firestore) and direct calls to external APIs using client-side keys (secured in Vercel env).

##### README Insights
- Frontend tech: React 18, TypeScript, Vite, Tailwind CSS, Framer Motion, Radix UI
- AI/ML: Google Gemini, OCR
- BaaS: Firebase Auth + Firestore
- External search: Serper API
- Deployment: Vercel (vercel.json)

##### Main Components & Their Relationships
a. Frontend SPA (browser)
- UI Layer: pages & components render views, handle routing (React Router)
- State & Theme: context providers (AuthProvider, theme-provider), i18n (i18next)
b. Data Access Layer (lib/)
- Firebase SDK wrappers → Authentication & Firestore queries
- Utils → format data, handle environment variables
c. External AI/ML Services
- Google Gemini API (via geminiHelper.ts)
- OCR engine (imageAnalyzer.ts)
- Serper search API (newsAnalyzer.ts, serperApi.ts)
d. Persistence & Hosting
- Firestore Database: stores user profiles, history, community feed, bookmarks
- Vercel: hosts static SPA, injects env vars for APIs

##### Architectural Patterns & Principles
- Component-based UI (atoms → molecules → pages)
- Separation of concerns:
- Presentation (components/)
- Business logic & API orchestration (utils/, lib/)
- Routing & page layouts (pages/)
- BaaS micro-services approach (outsourced Auth + DB)
- Client-driven API orchestration (calls from browser)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Hosting
    User("User"):::infra
    Vercel["Vercel Hosting (CI/CD & Env Vars)"]:::infra

    %% SPA - UI Layer
    subgraph "React SPA (Vite + Tailwind + i18n)" 
        Main["main.tsx"]:::ui
        App["App.tsx"]:::ui
        I18n["i18n Init (i18next)"]:::ui
        Pages["src/pages (Route-Level Pages)"]:::ui
        Components["src/components (UI Components)"]:::ui

        Main --> App
        App --> Pages
        App --> Components
        App --> I18n
    end

    %% API Orchestration & Data Layer
    subgraph "API Orchestration & Data Layer" 
        Lib["src/lib (Firebase SDK Wrappers)"]:::ui
        Utils["src/utils (AI & Search Wrappers)"]:::ui

        App --> Lib
        App --> Utils
    end

    %% BaaS Services
    subgraph "BaaS Services" 
        Auth["Firebase Auth"]:::firebase
        FirestoreDB["Firestore Database"]:::firebase

        Lib --> Auth
        Lib --> FirestoreDB
        App --> Auth
        App --> FirestoreDB
    end

    %% External AI Services
    subgraph "External AI & Search Services" 
        Gemini["Google Gemini API"]:::external
        OCR["OCR Engine"]:::external
        Serper["Serper Search API"]:::external

        Utils --> Gemini
        Utils --> OCR
        Utils --> Serper
    end

    %% Connections from User and Hosting
    User --> Main
    Vercel --> Main

    %% Click Events
    click Main "https://github.com/panduthegang/verifai-news_detection-system/blob/main/src/main.tsx"
    click App "https://github.com/panduthegang/verifai-news_detection-system/blob/main/src/App.tsx"
    click Pages "https://github.com/panduthegang/verifai-news_detection-system/tree/main/src/pages"
    click Components "https://github.com/panduthegang/verifai-news_detection-system/tree/main/src/components"
    click I18n "https://github.com/panduthegang/verifai-news_detection-system/blob/main/src/i18n/index.ts"
    click Lib "https://github.com/panduthegang/verifai-news_detection-system/tree/main/src/lib"
    click Utils "https://github.com/panduthegang/verifai-news_detection-system/tree/main/src/utils"
    click Auth "https://github.com/panduthegang/verifai-news_detection-system/blob/main/src/lib/auth.ts"
    click FirestoreDB "https://github.com/panduthegang/verifai-news_detection-system/blob/main/src/lib/firestore.ts"
    click Gemini "https://github.com/panduthegang/verifai-news_detection-system/blob/main/src/utils/geminiHelper.ts"
    click OCR "https://github.com/panduthegang/verifai-news_detection-system/blob/main/src/utils/imageAnalyzer.ts"
    click Serper "https://github.com/panduthegang/verifai-news_detection-system/blob/main/src/utils/serperApi.ts"
    click Vercel "https://github.com/panduthegang/verifai-news_detection-system/blob/main/vercel.json"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef firebase fill:#DFF5D0,stroke:#333,stroke-width:1px
    classDef external fill:#FFE8B0,stroke:#333,stroke-width:1px
    classDef infra fill:#E0E0E0,stroke:#333,stroke-width:1px
```
