# khan123-code/gmail-phishing-detector-2.0 architecture

> Architecture diagram of the GitHub repository khan123-code/gmail-phishing-detector-2.0, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khan123-code/gmail-phishing-detector-2.0
- Repository: https://github.com/khan123-code/gmail-phishing-detector-2.0

## Overview

Gmail Phishing Detector is a Chrome extension backed by a local FastAPI service. In Gmail, the extension extracts an open email and submits it for multi-layer phishing analysis; the backend combines sender-domain, URL, credential, authentication, and semantic signals into a risk result that the extension displays. Users can separately request an AI summary, which uses Gemini, and view the latest detection status in the extension popup. The README documents these capabilities; unsampled extension and detector code limits some implementation detail.

Main entry points: [`backend/smart_predict.py`](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/smart_predict.py) (Risk scoring), [`extension/content.js`](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/extension/content.js) (Email analysis UI), [`backend/app.py`](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/app.py) (FastAPI endpoints), [`backend/summarizer.py`](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/summarizer.py) (Summary generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Gmail Extension"]
  node_content["Email analysis UI<br/>[content.js]"]
  node_popup["Result popup<br/>[popup.js]"]
end

subgraph group_api["Local API"]
  node_api_app["FastAPI endpoints<br/>[app.py]"]
end

subgraph group_detection["Detection Engine"]
  node_predict["Risk scoring<br/>[smart_predict.py]"]
  node_domain["Sender domain checks<br/>[domain_checker.py]"]
  node_urls["URL analysis<br/>[url_analyzer.py]"]
  node_credentials["Credential detection"]
  node_authentication["Email authentication"]
  node_semantic["Semantic analysis"]
end

subgraph group_summary["Email Summary"]
  node_summarizer["Summary generation<br/>[summarizer.py]"]
end

node_gmail(("Gmail email"))
node_gemini["Google Gemini API"]

node_gmail -->|"provides email"| node_content
node_content -->|"posts analysis"| node_api_app
node_api_app -->|"calls prediction"| node_predict
node_predict -->|"checks sender"| node_domain
node_predict -->|"analyzes links"| node_urls
node_predict -->|"detects requests"| node_credentials
node_predict -->|"checks records"| node_authentication
node_predict -->|"analyzes meaning"| node_semantic
node_api_app -->|"returns result"| node_content
node_content -->|"stores result"| node_popup
node_content -->|"requests summary"| node_api_app
node_api_app -->|"calls summary"| node_summarizer
node_summarizer -->|"generates summary"| node_gemini

click node_content "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/extension/content.js"
click node_popup "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/extension/popup.js"
click node_api_app "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/app.py"
click node_predict "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/smart_predict.py"
click node_domain "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/domain_checker.py"
click node_urls "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/url_analyzer.py"
click node_credentials "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/credential_detector.py"
click node_authentication "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/email_auth_checker.py"
click node_semantic "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/semantic_analyzer.py"
click node_summarizer "https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/summarizer.py"

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_content,node_popup toneBlue
class node_api_app toneAmber
class node_predict,node_domain,node_urls,node_credentials,node_authentication,node_semantic,node_gemini toneMint
class node_summarizer toneRose
class node_gmail toneIndigo
```

## Components

### Gmail Extension

- [Email analysis UI](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/extension/content.js): `extension/content.js`
- [Result popup](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/extension/popup.js): `extension/popup.js`

### Local API

- [FastAPI endpoints](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/app.py): `backend/app.py`

### Detection Engine

- [Risk scoring](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/smart_predict.py): `backend/smart_predict.py`
- [Sender domain checks](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/domain_checker.py): `backend/domain_checker.py`
- [URL analysis](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/url_analyzer.py): `backend/url_analyzer.py`
- [Credential detection](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/credential_detector.py): `backend/credential_detector.py`
- [Email authentication](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/email_auth_checker.py): `backend/email_auth_checker.py`
- [Semantic analysis](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/semantic_analyzer.py): `backend/semantic_analyzer.py`

### Email Summary

- [Summary generation](https://github.com/khan123-code/gmail-phishing-detector-2.0/blob/main/backend/summarizer.py): `backend/summarizer.py`

### Other components

- **Gmail email**
- **Google Gemini API**

## Connections

- Gmail email → Email analysis UI: provides email (evidence: `README.md`)
- Email analysis UI → FastAPI endpoints: posts analysis (evidence: `extension/content.js`)
- FastAPI endpoints → Risk scoring: calls prediction (evidence: `backend/app.py`)
- Risk scoring → Sender domain checks: checks sender (evidence: `backend/smart_predict.py`)
- Risk scoring → URL analysis: analyzes links (evidence: `backend/smart_predict.py`)
- Risk scoring → Credential detection: detects requests (evidence: `backend/smart_predict.py`)
- Risk scoring → Email authentication: checks records (evidence: `backend/smart_predict.py`)
- Risk scoring → Semantic analysis: analyzes meaning (evidence: `backend/smart_predict.py`)
- FastAPI endpoints → Email analysis UI: returns result (evidence: `extension/content.js`)
- Email analysis UI → Result popup: stores result (evidence: `extension/popup.js`)
- Email analysis UI → FastAPI endpoints: requests summary (evidence: `README.md`)
- FastAPI endpoints → Summary generation: calls summary (evidence: `backend/app.py`)
- Summary generation → Google Gemini API: generates summary (evidence: `backend/summarizer.py`)
