# cprite/phishing-detection-ext architecture

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

- Interactive diagram: https://gitdiagram.com/cprite/phishing-detection-ext
- Repository: https://github.com/cprite/phishing-detection-ext

## Overview

No Phishing is a self-contained Chrome extension that scores visited pages locally. The workflow runs from page URL/link-count reporting through feature extraction, KNN plus lookalike checks, and—when needed—a warning screen; user decisions update trusted domains and, in the open-source build, feedback points. The popup also manages settings and trusted sites and exposes model stats. A separate documented model-export step prepares the bundled seed data. Connections follow the excerpts and README; unsampled details are not inferred.

Main entry points: [`extension/background.js`](https://github.com/cprite/phishing-detection-ext/blob/main/extension/background.js) (Service worker), [`extension/storage.js`](https://github.com/cprite/phishing-detection-ext/blob/main/extension/storage.js) (Dataset manager), [`extension/popup.js`](https://github.com/cprite/phishing-detection-ext/blob/main/extension/popup.js) (Popup controller), [`extension/warning.html`](https://github.com/cprite/phishing-detection-ext/blob/main/extension/warning.html) (Warning page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Page capture"]
  node_content["Page reporter<br/>[content.js]"]
  node_worker["Service worker<br/>[background.js]"]
end

subgraph group_detection["Detection engine"]
  node_features["URL features<br/>[features.js]"]
  node_knn["KNN classifier<br/>[knn.js]"]
  node_lookalike["Lookalike detector<br/>[lookalike.js]"]
end

subgraph group_decisions["User decisions"]
  node_popup["Extension popup<br/>[popup.html]"]
  node_popupcode["Popup controller<br/>[popup.js]"]
  node_warning["Warning page<br/>[warning.html]"]
  node_warningcode["Warning controller<br/>[warning.js]"]
end

subgraph group_learning["Local learning"]
  node_store["Dataset manager<br/>[storage.js]"]
  node_seed[("Seed dataset<br/>[seed_model.json]")]
  node_localdata[("Local extension storage")]
  node_exporter["Seed exporter<br/>[export_model.py]"]
  node_seedtest[("Held-out test set<br/>[seed_test.json]")]
end

node_user(("User"))
node_chrome["Chrome browser"]

node_chrome -->|"injects on pages"| node_content
node_content -->|"reports page"| node_worker
node_worker -->|"extracts features"| node_features
node_worker -->|"builds dataset"| node_store
node_worker -->|"scales and predicts"| node_knn
node_worker -->|"checks hostname"| node_lookalike
node_worker -->|"redirects on verdict"| node_warning
node_worker -->|"reads and writes"| node_localdata
node_store -->|"loads seed"| node_seed
node_store -->|"reads and writes feedback"| node_localdata
node_popup -->|"loads controller"| node_popupcode
node_popupcode -->|"requests state and stats"| node_worker
node_popupcode -->|"manages trusted sites"| node_localdata
node_warning -->|"loads controller"| node_warningcode
node_warningcode -->|"requests trust and feedback"| node_worker
node_user -->|"opens and configures"| node_popup
node_user -->|"chooses proceed or back"| node_warning
node_exporter -->|"writes training data"| node_seed
node_exporter -->|"writes holdout data"| node_seedtest
node_store -->|"loads test set"| node_seedtest

click node_content "https://github.com/cprite/phishing-detection-ext/blob/main/extension/content.js"
click node_worker "https://github.com/cprite/phishing-detection-ext/blob/main/extension/background.js"
click node_features "https://github.com/cprite/phishing-detection-ext/blob/main/extension/features.js"
click node_knn "https://github.com/cprite/phishing-detection-ext/blob/main/extension/knn.js"
click node_lookalike "https://github.com/cprite/phishing-detection-ext/blob/main/extension/lookalike.js"
click node_store "https://github.com/cprite/phishing-detection-ext/blob/main/extension/storage.js"
click node_seed "https://github.com/cprite/phishing-detection-ext/blob/main/saved_models/seed_model.json"
click node_exporter "https://github.com/cprite/phishing-detection-ext/blob/main/export_model.py"
click node_seedtest "https://github.com/cprite/phishing-detection-ext/blob/main/saved_models/seed_test.json"
click node_popup "https://github.com/cprite/phishing-detection-ext/blob/main/extension/popup.html"
click node_popupcode "https://github.com/cprite/phishing-detection-ext/blob/main/extension/popup.js"
click node_warning "https://github.com/cprite/phishing-detection-ext/blob/main/extension/warning.html"
click node_warningcode "https://github.com/cprite/phishing-detection-ext/blob/main/extension/warning.js"

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_worker,node_user,node_chrome toneBlue
class node_features,node_knn,node_lookalike toneAmber
class node_popup,node_popupcode,node_warning,node_warningcode toneMint
class node_store,node_seed,node_localdata,node_exporter,node_seedtest toneRose
```

## Components

### Page capture

- [Page reporter](https://github.com/cprite/phishing-detection-ext/blob/main/extension/content.js): `extension/content.js`
- [Service worker](https://github.com/cprite/phishing-detection-ext/blob/main/extension/background.js): `extension/background.js`

### Detection engine

- [URL features](https://github.com/cprite/phishing-detection-ext/blob/main/extension/features.js): `extension/features.js`
- [KNN classifier](https://github.com/cprite/phishing-detection-ext/blob/main/extension/knn.js): `extension/knn.js`
- [Lookalike detector](https://github.com/cprite/phishing-detection-ext/blob/main/extension/lookalike.js): `extension/lookalike.js`

### User decisions

- [Extension popup](https://github.com/cprite/phishing-detection-ext/blob/main/extension/popup.html): `extension/popup.html`
- [Popup controller](https://github.com/cprite/phishing-detection-ext/blob/main/extension/popup.js): `extension/popup.js`
- [Warning page](https://github.com/cprite/phishing-detection-ext/blob/main/extension/warning.html): `extension/warning.html`
- [Warning controller](https://github.com/cprite/phishing-detection-ext/blob/main/extension/warning.js): `extension/warning.js`

### Local learning

- [Dataset manager](https://github.com/cprite/phishing-detection-ext/blob/main/extension/storage.js): `extension/storage.js`
- [Seed dataset](https://github.com/cprite/phishing-detection-ext/blob/main/saved_models/seed_model.json): `saved_models/seed_model.json`
- **Local extension storage**
- [Seed exporter](https://github.com/cprite/phishing-detection-ext/blob/main/export_model.py): `export_model.py`
- [Held-out test set](https://github.com/cprite/phishing-detection-ext/blob/main/saved_models/seed_test.json): `saved_models/seed_test.json`

### Other components

- **User**
- **Chrome browser**

## Connections

- Chrome browser → Page reporter: injects on pages (evidence: `README.md`)
- Page reporter → Service worker: reports page (evidence: `extension/content.js`)
- Service worker → URL features: extracts features (evidence: `README.md`)
- Service worker → Dataset manager: builds dataset (evidence: `extension/background.js`)
- Service worker → KNN classifier: scales and predicts (evidence: `extension/background.js`)
- Service worker → Lookalike detector: checks hostname (evidence: `README.md`)
- Service worker → Warning page: redirects on verdict (evidence: `extension/background.js`)
- Service worker → Local extension storage: reads and writes (evidence: `extension/background.js`)
- Dataset manager → Seed dataset: loads seed (evidence: `extension/storage.js`)
- Dataset manager → Local extension storage: reads and writes feedback (evidence: `extension/storage.js`)
- Extension popup → Popup controller: loads controller (evidence: `README.md`)
- Popup controller → Service worker: requests state and stats (evidence: `extension/popup.js`)
- Popup controller → Local extension storage: manages trusted sites (evidence: `extension/popup.js`)
- Warning page → Warning controller: loads controller (evidence: `README.md`)
- Warning controller → Service worker: requests trust and feedback (evidence: `extension/warning.js`)
- User → Extension popup: opens and configures (evidence: `README.md`)
- User → Warning page: chooses proceed or back
- Seed exporter → Seed dataset: writes training data (evidence: `export_model.py`)
- Seed exporter → Held-out test set: writes holdout data (evidence: `export_model.py`)
- Dataset manager → Held-out test set: loads test set (evidence: `extension/storage.js`)
