# axd99999/phishing-detection-extension architecture

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

- Interactive diagram: https://gitdiagram.com/axd99999/phishing-detection-extension
- Repository: https://github.com/axd99999/phishing-detection-extension

## Overview

The product is a privacy-oriented Chrome extension that extracts phishing indicators in the browser, classifies them locally with a downloaded random-forest model, and warns users while showing feature scores. Its supporting backend prepares the UCI dataset and trains/exports the model. The runtime path is supported by sampled JavaScript; README documents dataset preparation and model training/export, though some backend and extension wiring was not sampled. The remote model source is an optional first-use fallback; subsequent classification can use the local cache.

Main entry points: [`frontend/js/background.js`](https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/background.js) (Message and classify), [`backend/dataset/preprocess.py`](https://github.com/axd99999/phishing-detection-extension/blob/main/backend/dataset/preprocess.py) (Dataset preprocessing), [`frontend/js/features.js`](https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/features.js) (Feature extraction), [`frontend/js/plugin_ui.js`](https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/plugin_ui.js) (Popup interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser Detection"]
  node_features["Feature extraction<br/>[features.js]"]
  node_background["Message and classify<br/>[background.js]"]
  node_predictor["Forest predictor<br/>[classifier.js]"]
  node_storage[("Chrome local storage")]
  node_model["Exported classifier<br/>[classifier.json]"]
end

subgraph group_extension["Extension UI"]
  node_popup["Popup interface<br/>[plugin_ui.js]"]
  node_popuphtml["Popup document<br/>[plugin_ui.html]"]
end

subgraph group_backend["Model Preparation"]
  node_dataset["Phishing dataset<br/>[dataset.arff]"]
  node_preprocess["Dataset preprocessing<br/>[preprocess.py]"]
  node_training["Forest training<br/>[training.py]"]
  node_exporter["Tree JSON exporter<br/>[dump.py]"]
  node_testdata["Test data export<br/>[testdata.json]"]
end

node_user(("Browser user"))
node_page["Visited page"]
node_modelhost["GitHub raw model"]

node_user -->|"visits"| node_page
node_page -->|"provides DOM"| node_features
node_features -->|"sends features"| node_background
node_background -->|"reads cache"| node_storage
node_background -->|"writes cache"| node_storage
node_background -.->|"fetches model"| node_modelhost
node_modelhost -.->|"returns model"| node_background
node_model -->|"cached model data"| node_background
node_background -->|"calls predict"| node_predictor
node_predictor -->|"returns classification"| node_background
node_background -->|"sends warning"| node_features
node_background -->|"exposes results"| node_popup
node_user -->|"opens popup"| node_popuphtml
node_popuphtml -->|"loads script"| node_popup
node_popup -->|"reads tab result"| node_background
node_dataset -->|"input data"| node_preprocess
node_preprocess -->|"writes training splits"| node_training
node_preprocess -->|"writes test export"| node_testdata
node_training -->|"exports forest"| node_exporter
node_exporter -->|"serializes model"| node_model

click node_features "https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/features.js"
click node_background "https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/background.js"
click node_predictor "https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/classifier.js"
click node_model "https://github.com/axd99999/phishing-detection-extension/blob/main/static/classifier.json"
click node_popup "https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/plugin_ui.js"
click node_popuphtml "https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/plugin_ui.html"
click node_dataset "https://github.com/axd99999/phishing-detection-extension/blob/main/backend/dataset/dataset.arff"
click node_preprocess "https://github.com/axd99999/phishing-detection-extension/blob/main/backend/dataset/preprocess.py"
click node_training "https://github.com/axd99999/phishing-detection-extension/blob/main/backend/classifier/training.py"
click node_exporter "https://github.com/axd99999/phishing-detection-extension/blob/main/backend/classifier/dump.py"
click node_testdata "https://github.com/axd99999/phishing-detection-extension/blob/main/static/testdata.json"

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_features,node_background,node_predictor,node_storage,node_model,node_user toneBlue
class node_popup,node_popuphtml toneAmber
class node_dataset,node_preprocess,node_training,node_exporter,node_testdata toneMint
class node_page,node_modelhost toneIndigo
```

## Components

### Browser Detection

- [Feature extraction](https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/features.js): `frontend/js/features.js`
- [Message and classify](https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/background.js): `frontend/js/background.js`
- [Forest predictor](https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/classifier.js): `frontend/js/classifier.js`
- **Chrome local storage**
- [Exported classifier](https://github.com/axd99999/phishing-detection-extension/blob/main/static/classifier.json): `static/classifier.json`

### Extension UI

- [Popup interface](https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/js/plugin_ui.js): `frontend/js/plugin_ui.js`
- [Popup document](https://github.com/axd99999/phishing-detection-extension/blob/main/frontend/plugin_ui.html): `frontend/plugin_ui.html`

### Model Preparation

- [Phishing dataset](https://github.com/axd99999/phishing-detection-extension/blob/main/backend/dataset/dataset.arff): `backend/dataset/dataset.arff`
- [Dataset preprocessing](https://github.com/axd99999/phishing-detection-extension/blob/main/backend/dataset/preprocess.py): `backend/dataset/preprocess.py`
- [Forest training](https://github.com/axd99999/phishing-detection-extension/blob/main/backend/classifier/training.py): `backend/classifier/training.py`
- [Tree JSON exporter](https://github.com/axd99999/phishing-detection-extension/blob/main/backend/classifier/dump.py): `backend/classifier/dump.py`
- [Test data export](https://github.com/axd99999/phishing-detection-extension/blob/main/static/testdata.json): `static/testdata.json`

### Other components

- **Browser user**
- **Visited page**
- **GitHub raw model**

## Connections

- Browser user → Visited page: visits
- Visited page → Feature extraction: provides DOM
- Feature extraction → Message and classify: sends features
- Message and classify → Chrome local storage: reads cache
- Message and classify → Chrome local storage: writes cache
- Message and classify → GitHub raw model: fetches model
- GitHub raw model → Message and classify: returns model
- Exported classifier → Message and classify: cached model data
- Message and classify → Forest predictor: calls predict
- Forest predictor → Message and classify: returns classification
- Message and classify → Feature extraction: sends warning
- Message and classify → Popup interface: exposes results
- Browser user → Popup document: opens popup
- Popup document → Popup interface: loads script
- Popup interface → Message and classify: reads tab result
- Phishing dataset → Dataset preprocessing: input data
- Dataset preprocessing → Forest training: writes training splits
- Dataset preprocessing → Test data export: writes test export
- Forest training → Tree JSON exporter: exports forest
- Tree JSON exporter → Exported classifier: serializes model
