# diyasarvaiya12/intelligent-phishing-detection architecture

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

- Interactive diagram: https://gitdiagram.com/diyasarvaiya12/intelligent-phishing-detection
- Repository: https://github.com/diyasarvaiya12/intelligent-phishing-detection

## Overview

This is a web-based phishing URL analyzer. A user submits a URL through the dashboard; the Flask API normalizes it, extracts lexical features, evaluates the trained classifier, and returns a risk verdict with feature details for display. The dashboard also requests health and training metrics. A separate training workflow consumes the dataset and produces model and metrics artifacts. The main inference and training relationships are supported by excerpts; dashboard-to-API links are evidenced by its fetch calls. The HTML layout and styling are not mapped as separate runtime components.

Main entry points: [`backend/app.py`](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/app.py) (Flask API), [`frontend/script.js`](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/frontend/script.js) (Dashboard UI), [`backend/train_model.py`](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/train_model.py) (Training Workflow), [`backend/feature_extraction.py`](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/feature_extraction.py) (Lexical Features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Dashboard"]
  node_dashboard["Dashboard UI<br/>[script.js]"]
end

subgraph group_api["Analysis API"]
  node_api_service["Flask API<br/>[app.py]"]
  node_feature_extractor["Lexical Features"]
end

subgraph group_ml["Detection Model"]
  node_model_artifact["Trained Model<br/>[model.pkl]"]
  node_fallback_forest["Python Forest<br/>[rf_engine.py]"]
  node_metrics_artifact["Evaluation Metrics<br/>[model_metrics.json]"]
end

subgraph group_training["Model Training"]
  node_training_job["Training Workflow<br/>[train_model.py]"]
  node_dataset["Phishing Dataset"]
end

node_user(("User"))

node_user -->|"submits URL"| node_dashboard
node_dashboard -->|"requests scan"| node_api_service
node_api_service -->|"extracts features"| node_feature_extractor
node_api_service -->|"loads and predicts"| node_model_artifact
node_api_service -->|"loads metrics"| node_metrics_artifact
node_api_service -->|"imports fallback"| node_fallback_forest
node_api_service -->|"serves dashboard"| node_dashboard
node_dashboard -->|"checks health"| node_api_service
node_dashboard -->|"requests metrics"| node_api_service
node_api_service -->|"returns analysis"| node_dashboard
node_training_job -->|"reads data"| node_dataset
node_training_job -->|"uses feature schema"| node_feature_extractor
node_training_job -->|"trains fallback"| node_fallback_forest
node_training_job -->|"writes model"| node_model_artifact
node_training_job -->|"writes metrics"| node_metrics_artifact

click node_dashboard "https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/frontend/script.js"
click node_api_service "https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/app.py"
click node_feature_extractor "https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/feature_extraction.py"
click node_model_artifact "https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/model.pkl"
click node_fallback_forest "https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/rf_engine.py"
click node_metrics_artifact "https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/model_metrics.json"
click node_training_job "https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/train_model.py"
click node_dataset "https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/data/phishing_dataset.csv"

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_dashboard,node_user toneBlue
class node_api_service,node_feature_extractor toneAmber
class node_model_artifact,node_fallback_forest,node_metrics_artifact toneMint
class node_training_job,node_dataset toneRose
```

## Components

### Dashboard

- [Dashboard UI](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/frontend/script.js): `frontend/script.js`

### Analysis API

- [Flask API](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/app.py): `backend/app.py`
- [Lexical Features](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/feature_extraction.py): `backend/feature_extraction.py`

### Detection Model

- [Trained Model](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/model.pkl): `backend/model.pkl`
- [Python Forest](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/rf_engine.py): `backend/rf_engine.py`
- [Evaluation Metrics](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/model_metrics.json): `backend/model_metrics.json`

### Model Training

- [Training Workflow](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/backend/train_model.py): `backend/train_model.py`
- [Phishing Dataset](https://github.com/diyasarvaiya12/intelligent-phishing-detection/blob/main/data/phishing_dataset.csv): `data/phishing_dataset.csv`

### Other components

- **User**

## Connections

- User → Dashboard UI: submits URL (evidence: `README.md`)
- Dashboard UI → Flask API: requests scan (evidence: `frontend/script.js`)
- Flask API → Lexical Features: extracts features (evidence: `backend/app.py`)
- Flask API → Trained Model: loads and predicts (evidence: `backend/app.py`)
- Flask API → Evaluation Metrics: loads metrics (evidence: `backend/app.py`)
- Flask API → Python Forest: imports fallback (evidence: `backend/app.py`)
- Flask API → Dashboard UI: serves dashboard (evidence: `backend/app.py`)
- Dashboard UI → Flask API: checks health (evidence: `frontend/script.js`)
- Dashboard UI → Flask API: requests metrics (evidence: `frontend/script.js`)
- Flask API → Dashboard UI: returns analysis (evidence: `backend/app.py`)
- Training Workflow → Phishing Dataset: reads data (evidence: `backend/train_model.py`)
- Training Workflow → Lexical Features: uses feature schema (evidence: `backend/train_model.py`)
- Training Workflow → Python Forest: trains fallback (evidence: `backend/train_model.py`)
- Training Workflow → Trained Model: writes model (evidence: `backend/train_model.py`)
- Training Workflow → Evaluation Metrics: writes metrics (evidence: `backend/train_model.py`)
