# uzukhai/malicious-url-detection-using-machine-learning-algorithm architecture

> Architecture diagram of the GitHub repository uzukhai/malicious-url-detection-using-machine-learning-algorithm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm
- Repository: https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm

## Overview

This repository provides a Flask interface for submitting a URL and viewing a malicious/benign classification. The request handler launches the prediction script; prediction validates the URL, extracts features, loads the trained Random Forest and label encoder, then prints the predicted label for the results page. A separate training workflow builds and saves those model artifacts. The archive is documented as containing the model and dataset. Feature extraction is shown; templates and archive contents are not sampled, so their internal details are omitted.

Main entry points: [`predict.py`](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/predict.py) (Prediction CLI), [`train.py`](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/train.py) (Model training), [`app.py`](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/app.py) (Flask request handler), [`extract.py`](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/extract.py) (URL feature extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_webapp["Flask request handler<br/>[app.py]"]
  node_resultsview["Results page<br/>[app.py]"]
end

subgraph group_classification["URL classification"]
  node_predict["Prediction CLI<br/>[predict.py]"]
  node_extract["URL feature extraction<br/>[extract.py]"]
  node_features["URL features<br/>[extract.py]"]
  node_result["Classification label<br/>[predict.py]"]
end

subgraph group_training["Model training"]
  node_trainer["Model training<br/>[train.py]"]
end

subgraph group_artifacts["Model artifacts"]
  node_model[("Random Forest")]
  node_encoder[("Label encoder")]
  node_dataset[("URL dataset")]
end

node_visitor(("URL submitter"))

node_visitor -->|"submits URL"| node_webapp
node_webapp -->|"launches CLI"| node_predict
node_predict -->|"extracts features"| node_extract
node_extract -->|"produces"| node_features
node_predict -->|"loads and predicts"| node_model
node_predict -->|"decodes label"| node_encoder
node_predict -->|"prints label"| node_result
node_webapp -->|"renders result"| node_resultsview
node_trainer -->|"reads dataset"| node_dataset
node_trainer -->|"extracts features"| node_extract
node_trainer -->|"trains and saves"| node_model
node_trainer -->|"fits and saves"| node_encoder

click node_webapp "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/app.py"
click node_predict "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/predict.py"
click node_extract "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/extract.py"
click node_features "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/extract.py"
click node_model "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/model%20and%20dataset.zip"
click node_encoder "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/model%20and%20dataset.zip"
click node_trainer "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/train.py"
click node_dataset "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/model%20and%20dataset.zip"
click node_result "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/predict.py"
click node_resultsview "https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/app.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_webapp,node_resultsview toneBlue
class node_predict,node_extract,node_features,node_result toneAmber
class node_trainer toneMint
class node_model,node_encoder,node_dataset toneRose
class node_visitor toneIndigo
```

## Components

### Web interface

- [Flask request handler](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/app.py): `app.py`
- [Results page](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/app.py): `app.py`

### URL classification

- [Prediction CLI](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/predict.py): `predict.py`
- [URL feature extraction](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/extract.py): `extract.py`
- [URL features](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/extract.py): `extract.py`
- [Classification label](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/predict.py): `predict.py`

### Model training

- [Model training](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/train.py): `train.py`

### Model artifacts

- [Random Forest](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/model%20and%20dataset.zip): `model and dataset.zip`
- [Label encoder](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/model%20and%20dataset.zip): `model and dataset.zip`
- [URL dataset](https://github.com/uzukhai/malicious-url-detection-using-machine-learning-algorithm/blob/main/model%20and%20dataset.zip): `model and dataset.zip`

### Other components

- **URL submitter**

## Connections

- URL submitter → Flask request handler: submits URL (evidence: `app.py`)
- Flask request handler → Prediction CLI: launches CLI (evidence: `app.py`)
- Prediction CLI → URL feature extraction: extracts features (evidence: `predict.py`)
- URL feature extraction → URL features: produces (evidence: `extract.py`)
- Prediction CLI → Random Forest: loads and predicts (evidence: `predict.py`)
- Prediction CLI → Label encoder: decodes label (evidence: `predict.py`)
- Prediction CLI → Classification label: prints label (evidence: `predict.py`)
- Flask request handler → Results page: renders result (evidence: `app.py`)
- Model training → URL dataset: reads dataset (evidence: `train.py`)
- Model training → URL feature extraction: extracts features (evidence: `train.py`)
- Model training → Random Forest: trains and saves (evidence: `train.py`)
- Model training → Label encoder: fits and saves (evidence: `train.py`)
