# aleem-ghafoor/phishguard architecture

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

- Interactive diagram: https://gitdiagram.com/aleem-ghafoor/phishguard
- Repository: https://github.com/aleem-ghafoor/phishguard

## Overview

PhishGuard is a Django URL-risk detection app. A browser submits a URL; scanner views validate it, call the prediction service, and return a prediction with phishing probability. Authenticated scans are saved and can be retrieved as history. Separate capabilities cover account management, the dashboard, and offline dataset preparation and model training. The graph follows the supplied README and excerpts; unshown dashboard internals and some offline data-stage connections are represented only where their paths are supported.

Main entry points: [`scanner/views.py`](https://github.com/aleem-ghafoor/phishguard/blob/main/scanner/views.py) (Scan endpoints), [`datasets/raw`](https://github.com/aleem-ghafoor/phishguard/tree/main/datasets/raw) (Prepared datasets), [`PhishGuard/urls.py`](https://github.com/aleem-ghafoor/phishguard/blob/main/PhishGuard/urls.py) (Django application), [`ml_engine/predictor.py`](https://github.com/aleem-ghafoor/phishguard/blob/main/ml_engine/predictor.py) (URL predictor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_django["Django application<br/>[urls.py]"]
  node_dashboard["Dashboard<br/>[views.py]"]
end

subgraph group_accounts["Accounts"]
  node_account_views["Account handlers<br/>[views.py]"]
  node_account_forms["Account forms<br/>[form.py]"]
  node_user_model[("User model<br/>[models.py]")]
end

subgraph group_scanning["URL scanning"]
  node_scan_views["Scan endpoints<br/>[views.py]"]
  node_validation["URL validation<br/>[validation.py]"]
  node_scan_service["Scan service<br/>[services.py]"]
  node_history_model[("Scan history<br/>[models.py]")]
end

subgraph group_ml["Machine learning"]
  node_predictor["URL predictor<br/>[predictor.py]"]
  node_features["URL features"]
  node_trained_model[("Random Forest artifact")]
  node_training["Model training<br/>[train.py]"]
  node_evaluation["Model evaluation<br/>[evaluation.py]"]
end

subgraph group_data["Dataset preparation"]
  node_dataset_clean["Dataset cleaning<br/>[data_cleaning.py]"]
  node_dataset_inspect["Dataset inspection<br/>[data_inspection.py]"]
  node_dataset_features["Dataset features"]
  node_dataset_preprocess["Dataset preprocessing<br/>[preprocessing.py]"]
  node_dataset_store[("Prepared datasets")]
end

node_browser(("User / browser"))

node_browser -->|"uses"| node_django
node_django -->|"routes to"| node_dashboard
node_django -->|"routes to"| node_account_views
node_django -->|"routes to"| node_scan_views
node_browser -->|"submits URL"| node_scan_views
node_scan_views -->|"validates"| node_validation
node_scan_views -->|"calls"| node_scan_service
node_scan_service -->|"calls"| node_predictor
node_predictor -->|"extracts features"| node_features
node_predictor -.->|"loads model"| node_trained_model
node_scan_views -->|"writes scans"| node_history_model
node_scan_views -->|"reads history"| node_history_model
node_account_views -->|"uses forms"| node_account_forms
node_account_forms -->|"creates users"| node_user_model
node_training -->|"evaluates"| node_evaluation
node_training -->|"reads prepared data"| node_dataset_store
node_dataset_clean -.->|"prepares data"| node_dataset_store
node_dataset_inspect -.->|"inspects data"| node_dataset_store
node_dataset_features -.->|"extracts features"| node_dataset_store
node_dataset_preprocess -.->|"preprocesses"| node_dataset_store

click node_django "https://github.com/aleem-ghafoor/phishguard/blob/main/PhishGuard/urls.py"
click node_dashboard "https://github.com/aleem-ghafoor/phishguard/blob/main/PhishGuard/views.py"
click node_account_views "https://github.com/aleem-ghafoor/phishguard/blob/main/accounts/views.py"
click node_account_forms "https://github.com/aleem-ghafoor/phishguard/blob/main/accounts/form.py"
click node_user_model "https://github.com/aleem-ghafoor/phishguard/blob/main/accounts/models.py"
click node_scan_views "https://github.com/aleem-ghafoor/phishguard/blob/main/scanner/views.py"
click node_validation "https://github.com/aleem-ghafoor/phishguard/blob/main/scanner/validation.py"
click node_scan_service "https://github.com/aleem-ghafoor/phishguard/blob/main/scanner/services.py"
click node_history_model "https://github.com/aleem-ghafoor/phishguard/blob/main/scanner/models.py"
click node_predictor "https://github.com/aleem-ghafoor/phishguard/blob/main/ml_engine/predictor.py"
click node_features "https://github.com/aleem-ghafoor/phishguard/blob/main/ml_engine/feature_extractor.py"
click node_trained_model "https://github.com/aleem-ghafoor/phishguard/tree/main/ml_engine/model"
click node_training "https://github.com/aleem-ghafoor/phishguard/blob/main/ml_engine/train.py"
click node_evaluation "https://github.com/aleem-ghafoor/phishguard/blob/main/ml_engine/evaluation.py"
click node_dataset_clean "https://github.com/aleem-ghafoor/phishguard/blob/main/datasets/raw/scripts/data_cleaning.py"
click node_dataset_inspect "https://github.com/aleem-ghafoor/phishguard/blob/main/datasets/raw/scripts/data_inspection.py"
click node_dataset_features "https://github.com/aleem-ghafoor/phishguard/blob/main/datasets/raw/scripts/feature_extraction.py"
click node_dataset_preprocess "https://github.com/aleem-ghafoor/phishguard/blob/main/datasets/raw/scripts/preprocessing.py"
click node_dataset_store "https://github.com/aleem-ghafoor/phishguard/tree/main/datasets/raw"

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_django,node_dashboard,node_browser toneBlue
class node_account_views,node_account_forms,node_user_model toneAmber
class node_scan_views,node_validation,node_scan_service,node_history_model toneMint
class node_predictor,node_features,node_trained_model,node_training,node_evaluation toneRose
class node_dataset_clean,node_dataset_inspect,node_dataset_features,node_dataset_preprocess,node_dataset_store toneIndigo
```

## Components

### Web application

- [Django application](https://github.com/aleem-ghafoor/phishguard/blob/main/PhishGuard/urls.py): `PhishGuard/urls.py`
- [Dashboard](https://github.com/aleem-ghafoor/phishguard/blob/main/PhishGuard/views.py): `PhishGuard/views.py`

### Accounts

- [Account handlers](https://github.com/aleem-ghafoor/phishguard/blob/main/accounts/views.py): `accounts/views.py`
- [Account forms](https://github.com/aleem-ghafoor/phishguard/blob/main/accounts/form.py): `accounts/form.py`
- [User model](https://github.com/aleem-ghafoor/phishguard/blob/main/accounts/models.py): `accounts/models.py`

### URL scanning

- [Scan endpoints](https://github.com/aleem-ghafoor/phishguard/blob/main/scanner/views.py): `scanner/views.py`
- [URL validation](https://github.com/aleem-ghafoor/phishguard/blob/main/scanner/validation.py): `scanner/validation.py`
- [Scan service](https://github.com/aleem-ghafoor/phishguard/blob/main/scanner/services.py): `scanner/services.py`
- [Scan history](https://github.com/aleem-ghafoor/phishguard/blob/main/scanner/models.py): `scanner/models.py`

### Machine learning

- [URL predictor](https://github.com/aleem-ghafoor/phishguard/blob/main/ml_engine/predictor.py): `ml_engine/predictor.py`
- [URL features](https://github.com/aleem-ghafoor/phishguard/blob/main/ml_engine/feature_extractor.py): `ml_engine/feature_extractor.py`
- [Random Forest artifact](https://github.com/aleem-ghafoor/phishguard/tree/main/ml_engine/model): `ml_engine/model`
- [Model training](https://github.com/aleem-ghafoor/phishguard/blob/main/ml_engine/train.py): `ml_engine/train.py`
- [Model evaluation](https://github.com/aleem-ghafoor/phishguard/blob/main/ml_engine/evaluation.py): `ml_engine/evaluation.py`

### Dataset preparation

- [Dataset cleaning](https://github.com/aleem-ghafoor/phishguard/blob/main/datasets/raw/scripts/data_cleaning.py): `datasets/raw/scripts/data_cleaning.py`
- [Dataset inspection](https://github.com/aleem-ghafoor/phishguard/blob/main/datasets/raw/scripts/data_inspection.py): `datasets/raw/scripts/data_inspection.py`
- [Dataset features](https://github.com/aleem-ghafoor/phishguard/blob/main/datasets/raw/scripts/feature_extraction.py): `datasets/raw/scripts/feature_extraction.py`
- [Dataset preprocessing](https://github.com/aleem-ghafoor/phishguard/blob/main/datasets/raw/scripts/preprocessing.py): `datasets/raw/scripts/preprocessing.py`
- [Prepared datasets](https://github.com/aleem-ghafoor/phishguard/tree/main/datasets/raw): `datasets/raw`

### Other components

- **User / browser**

## Connections

- User / browser → Django application: uses (evidence: `README.md`)
- Django application → Dashboard: routes to (evidence: `PhishGuard/urls.py`)
- Django application → Account handlers: routes to (evidence: `PhishGuard/urls.py`)
- Django application → Scan endpoints: routes to (evidence: `PhishGuard/urls.py`)
- User / browser → Scan endpoints: submits URL (evidence: `README.md`)
- Scan endpoints → URL validation: validates (evidence: `scanner/views.py`)
- Scan endpoints → Scan service: calls (evidence: `scanner/views.py`)
- Scan service → URL predictor: calls (evidence: `scanner/services.py`)
- URL predictor → URL features: extracts features (evidence: `ml_engine/predictor.py`)
- URL predictor → Random Forest artifact: loads model
- Scan endpoints → Scan history: writes scans (evidence: `scanner/views.py`)
- Scan endpoints → Scan history: reads history (evidence: `scanner/views.py`)
- Account handlers → Account forms: uses forms (evidence: `accounts/views.py`)
- Account forms → User model: creates users (evidence: `accounts/form.py`)
- Model training → Model evaluation: evaluates (evidence: `ml_engine/train.py`)
- Model training → Prepared datasets: reads prepared data (evidence: `ml_engine/train.py`)
- Dataset cleaning → Prepared datasets: prepares data
- Dataset inspection → Prepared datasets: inspects data
- Dataset features → Prepared datasets: extracts features
- Dataset preprocessing → Prepared datasets: preprocesses
