A full-stack fake news detection system combining a Chrome/Edge sidebar extension with a FastAPI backend. Uses Google Gemini AI for content analysis, SerpAPI + NewsAPI for real-time source cross-referencing, and a curated credibility database of 100+ Indian news sources across 10 languages.
|
|
| Language | Code | Regional Sources |
|---|---|---|
| English | en |
International & Indian English media |
| Hindi | hi |
Hindi News18, Indian Express Hindi, The Hindu Hindi |
| Telugu | te |
Eenadu, Sakshi, Telangana Today |
| Tamil | ta |
Dinamani, Dinakaran, Tamil The Hindu |
| Bengali | bn |
Bengali News18, Bengali OneIndia |
| Gujarati | gu |
Gujarati News18, Gujarati OneIndia |
| Marathi | mr |
Marathi News18, Marathi OneIndia |
| Kannada | kn |
Kannada News18, Kannada OneIndia |
| Malayalam | ml |
Malayalam News18, Malayalam OneIndia |
| Punjabi | pa |
Punjabi News18, Punjabi OneIndia |
flowchart TD
A([👤 User selects text on any webpage]) --> B
subgraph EXT["🧩 Browser Extension (Manifest V3)"]
B[Content script detects selection]
C[Sidebar / Context Menu triggered]
B --> C
end
C -->|POST /analyze_text| D
subgraph API["⚙️ FastAPI Backend"]
D[Request Router]
subgraph SOURCES["📡 News Source APIs"]
E[SerpAPI\nGoogle News]
F[NewsAPI\nHeadlines]
G[Optional APIs\nMediaStack · GNews\nNewsData · RapidAPI]
end
D --> E & F & G
H[🔍 Relevance Filter\nRegional boost · Lang-aware\nExcludes spam domains]
E & F & G --> H
I[🏅 Source Credibility Engine\n100+ Indian domains · 10 languages\nDomain scoring]
H --> I
J{Gemini\nAvailable?}
I --> J
K[🤖 Gemini AI Analysis\ngemini-2.5-flash-lite\nText + Vision · Structured JSON]
L[🔄 Heuristic Fallback\nScikit-learn TF-IDF\nClickbait & bias detection]
J -- Yes --> K
J -- No --> L
end
K & L --> M
subgraph RESP["📊 Structured Response"]
M[Classification · Confidence\nExplanation · Verified sources\nCredibility summary · Language]
end
M --> N([✅ Results rendered in sidebar])
style EXT fill:#e8f4fd,stroke:#4A90D9,stroke-width:1.5px,color:#1a1a2e
style API fill:#f0fdf4,stroke:#22C55E,stroke-width:1.5px,color:#1a1a2e
style SOURCES fill:#fef9c3,stroke:#EAB308,stroke-width:1px,color:#1a1a2e
style RESP fill:#fdf4ff,stroke:#A855F7,stroke-width:1.5px,color:#1a1a2e
flowchart LR
A([🖼️ Image URL or base64]) --> B
B[OCR Extraction\nExtract text from image] --> C
C[Fact-Check Text\nRun through main AI pipeline] --> D
D[Reverse Image Search\nGoogle Lens · Google Images] --> E
E([📋 Authenticity report\nis_authentic · confidence\nsimilar_images])
style A fill:#fdf4ff,stroke:#A855F7,stroke-width:1.5px
style E fill:#f0fdf4,stroke:#22C55E,stroke-width:1.5px
FactifyAI/
├── 📂 backend/
│ ├── main.py # FastAPI app — endpoints & request models
│ ├── 📂 services/
│ │ ├── gemini_service.py # Vertex AI Gemini (text + vision)
│ │ ├── serpapi_service.py # SerpAPI news & reverse image search
│ │ ├── newsapi_service.py # NewsAPI headlines & article search
│ │ ├── additional_apis_service.py # RapidAPI, MediaStack, NewsData, GNews
│ │ ├── source_verification.py # Domain credibility database & scoring
│ │ └── relevance_filter.py # Regional language-aware source filtering
│ ├── 📂 utils/
│ │ ├── language_detector.py # Unicode-based Indic language detection
│ │ └── text_processor.py # Text cleaning, keyword extraction, bias detection
│ ├── 📂 models/
│ │ ├── fake_news_model.pkl # Scikit-learn fallback model
│ │ └── vectorizer.pkl # TF-IDF vectorizer for fallback
│ ├── requirements.txt
│ └── env.example # Environment variable template
├── 📂 extension/
│ ├── manifest.json # Manifest V3 config
│ ├── background.js # Service worker — context menus, messaging
│ ├── content.js # Content script — text selection detection
│ ├── sidebar.html # Sidebar panel UI
│ ├── sidebar.css # Sidebar styles
│ ├── sidebar.js # Sidebar logic — API calls, result rendering
│ └── 📂 icons/ # Extension icons (16 / 48 / 128px + logo)
├── create_env.py # Helper to generate .env from template
├── start_backend.py # One-click backend startup script
└── test_final.py # API integration test script
- Python 3.8+
- Chrome or Edge browser
- API keys (see below)
git clone https://github.com/YOUR_USERNAME/FactifyAI.git
cd FactifyAI
# Install backend dependencies
cd backend
pip install -r requirements.txt# Option A — use the helper script (recommended)
cd ..
python create_env.py
# Then edit backend/.env with your actual keys
# Option B — copy the template manually
cp backend/env.example backend/.env
# Edit backend/.env with your keysRequired API keys:
| API | Purpose | Get Key |
|---|---|---|
| Google Cloud (Gemini) | AI text analysis, OCR, image analysis | Google Cloud Console — Enable Vertex AI, create a Service Account, download JSON key |
| SerpAPI | Google News search, reverse image search | serpapi.com |
| NewsAPI | News article search & headlines | newsapi.org |
Optional API keys (enhance accuracy with additional sources):
| API | Purpose | Get Key |
|---|---|---|
| RapidAPI | News aggregator | rapidapi.com |
| MediaStack | Global news feed | mediastack.com |
| NewsData | News articles | newsdata.io |
| GNews | Google News aggregator | gnews.io |
💡 Gemini Credentials: Place the downloaded service account JSON as
backend/credentials.json, or set individual environment variables in.env. The service checks for the JSON file first and falls back to environment variables.
# Option A — startup script (recommended)
python start_backend.py
# Option B — run uvicorn directly
cd backend
uvicorn main:app --reload --host 0.0.0.0 --port 8000API available at http://localhost:8000 · Interactive docs at /docs
- Open
chrome://extensions/(oredge://extensions/) - Enable Developer mode
- Click Load unpacked → select the
extension/folder - Pin the FactifyAI extension for easy access
// Request
{ "url": "https://example.com/article" }
// Response
{
"domain": "example.com",
"credibility_score": 0.75,
"assessment": "Moderately Credible",
"details": "Analysis details...",
"recommendations": "Cross-reference with other sources"
}// Request
{ "image_url": "https://example.com/image.jpg", "image_data": "base64..." }
// Response
{
"status": "success",
"analysis": "OCR + fact-check + reverse search results...",
"extracted_text": "Text found in image...",
"fact_check_result": { "classification": "...", "confidence": 0.8 },
"is_authentic": true,
"confidence": 0.85,
"similar_images": [...]
}| Method | Endpoint | Description |
|---|---|---|
POST |
/comprehensive_verification |
Full pipeline: text + multi-source + credibility in one request |
GET |
/health |
Availability status of Gemini, SerpAPI, and NewsAPI |
GET |
/languages |
List all supported languages |
graph LR
A["🤖 AI Engine\nGemini 2.5 Flash Lite\nVertex AI"]
B["⚙️ Backend\nPython · FastAPI\naiohttp · Pydantic"]
C["📰 News APIs\nSerpAPI · NewsAPI\nRapidAPI · MediaStack\nNewsData · GNews"]
D["🔤 NLP\nUnicode Indic detection\nRegex text processing"]
E["🧠 ML Fallback\nscikit-learn\nTF-IDF + Classifier"]
F["🧩 Extension\nManifest V3\nSide Panel API\nService Workers"]
G["🔐 Auth\nGoogle Service Account\nOAuth2"]
B --> A
B --> C
B --> D
B --> E
F --> B
G --> A
style A fill:#e8f4fd,stroke:#4285F4,stroke-width:1.5px
style B fill:#f0fdf4,stroke:#22C55E,stroke-width:1.5px
style C fill:#fef9c3,stroke:#EAB308,stroke-width:1.5px
style D fill:#fdf4ff,stroke:#A855F7,stroke-width:1.5px
style E fill:#fff7ed,stroke:#F97316,stroke-width:1.5px
style F fill:#f0f9ff,stroke:#0EA5E9,stroke-width:1.5px
style G fill:#fef2f2,stroke:#EF4444,stroke-width:1.5px
Made with ❤️ for India's multilingual internet