# piyush0108maurya/url-sms-detector architecture

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

- Interactive diagram: https://gitdiagram.com/piyush0108maurya/url-sms-detector
- Repository: https://github.com/piyush0108maurya/url-sms-detector

## Overview

PhishGuard Edge is a local web app for scanning URLs and SMS text, individually or via CSV, and returning phishing classifications, confidence, and URL indicators. The workflow runs from the React interface to the FastAPI endpoint, which normalizes input and invokes a locally loaded DistilBERT model; batch results return to the interface for review and CSV download. Separate data preparation, model training, and Snapdragon export/profiling support the product lifecycle. Runtime links are based on shown calls; README documents on-device privacy and the NPU optimization goal.

Main entry points: [`backend/main.py`](https://github.com/piyush0108maurya/url-sms-detector/blob/main/backend/main.py) (REST API), [`model/export_and_compile.py`](https://github.com/piyush0108maurya/url-sms-detector/blob/main/model/export_and_compile.py) (ONNX export and compile), [`frontend/src/App.jsx`](https://github.com/piyush0108maurya/url-sms-detector/blob/main/frontend/src/App.jsx) (Scan UI), [`model/train.py`](https://github.com/piyush0108maurya/url-sms-detector/blob/main/model/train.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Scanning interface"]
  node_frontend["Scan UI<br/>[App.jsx]"]
  node_boot["React entry<br/>[main.jsx]"]
end

subgraph group_service["Local inference API"]
  node_api["REST API<br/>[main.py]"]
  node_normalize_runtime["Input normalization<br/>[main.py]"]
  node_indicators["URL indicators<br/>[main.py]"]
  node_classifier["DistilBERT classifier"]
  node_metrics["Model metrics<br/>[model_metrics.json]"]
  node_benchmark["Snapdragon benchmark"]
end

subgraph group_modeling["Model lifecycle"]
  node_training["Model training<br/>[train.py]"]
  node_model_artifact["Trained model"]
  node_compile["ONNX export and compile"]
  node_onnx["ONNX model<br/>[phishing.onnx]"]
end

subgraph group_data["Dataset preparation"]
  node_data_prep["Dataset preparation<br/>[prepare_data.py]"]
  node_shared_normalize["Shared URL normalization<br/>[normalize.py]"]
end

node_user(("Scanner"))
node_aihub["Qualcomm AI Hub"]

node_user -->|"scans"| node_frontend
node_boot -->|"renders"| node_frontend
node_frontend -->|"posts scans"| node_api
node_api -->|"loads model"| node_classifier
node_api -->|"normalizes input"| node_normalize_runtime
node_api -->|"extracts indicators"| node_indicators
node_api -->|"runs inference"| node_classifier
node_api -->|"reads metrics"| node_metrics
node_api -->|"reads benchmark"| node_benchmark
node_data_prep -->|"normalizes data"| node_shared_normalize
node_training -->|"saves model"| node_model_artifact
node_compile -->|"loads model"| node_model_artifact
node_compile -->|"exports model"| node_onnx
node_compile -->|"submits compile and profile"| node_aihub
node_training -.->|"uses prepared splits"| node_data_prep

click node_frontend "https://github.com/piyush0108maurya/url-sms-detector/blob/main/frontend/src/App.jsx"
click node_boot "https://github.com/piyush0108maurya/url-sms-detector/blob/main/frontend/src/main.jsx"
click node_api "https://github.com/piyush0108maurya/url-sms-detector/blob/main/backend/main.py"
click node_normalize_runtime "https://github.com/piyush0108maurya/url-sms-detector/blob/main/backend/main.py"
click node_indicators "https://github.com/piyush0108maurya/url-sms-detector/blob/main/backend/main.py"
click node_classifier "https://github.com/piyush0108maurya/url-sms-detector/tree/main/model/phishing-distilbert"
click node_metrics "https://github.com/piyush0108maurya/url-sms-detector/blob/main/docs/model_metrics.json"
click node_benchmark "https://github.com/piyush0108maurya/url-sms-detector/blob/main/docs/snapdragon_performance.json"
click node_data_prep "https://github.com/piyush0108maurya/url-sms-detector/blob/main/data/prepare_data.py"
click node_shared_normalize "https://github.com/piyush0108maurya/url-sms-detector/blob/main/common/normalize.py"
click node_training "https://github.com/piyush0108maurya/url-sms-detector/blob/main/model/train.py"
click node_model_artifact "https://github.com/piyush0108maurya/url-sms-detector/tree/main/model/phishing-distilbert"
click node_compile "https://github.com/piyush0108maurya/url-sms-detector/blob/main/model/export_and_compile.py"
click node_onnx "https://github.com/piyush0108maurya/url-sms-detector/blob/main/model/phishing.onnx"

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_frontend,node_boot toneBlue
class node_api,node_normalize_runtime,node_indicators,node_classifier,node_metrics,node_benchmark toneAmber
class node_training,node_model_artifact,node_compile,node_onnx toneMint
class node_data_prep,node_shared_normalize toneRose
class node_user,node_aihub toneIndigo
```

## Components

### Scanning interface

- [Scan UI](https://github.com/piyush0108maurya/url-sms-detector/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [React entry](https://github.com/piyush0108maurya/url-sms-detector/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### Local inference API

- [REST API](https://github.com/piyush0108maurya/url-sms-detector/blob/main/backend/main.py): `backend/main.py`
- [Input normalization](https://github.com/piyush0108maurya/url-sms-detector/blob/main/backend/main.py): `backend/main.py`
- [URL indicators](https://github.com/piyush0108maurya/url-sms-detector/blob/main/backend/main.py): `backend/main.py`
- [DistilBERT classifier](https://github.com/piyush0108maurya/url-sms-detector/tree/main/model/phishing-distilbert): `model/phishing-distilbert`
- [Model metrics](https://github.com/piyush0108maurya/url-sms-detector/blob/main/docs/model_metrics.json): `docs/model_metrics.json`
- [Snapdragon benchmark](https://github.com/piyush0108maurya/url-sms-detector/blob/main/docs/snapdragon_performance.json): `docs/snapdragon_performance.json`

### Model lifecycle

- [Model training](https://github.com/piyush0108maurya/url-sms-detector/blob/main/model/train.py): `model/train.py`
- [Trained model](https://github.com/piyush0108maurya/url-sms-detector/tree/main/model/phishing-distilbert): `model/phishing-distilbert`
- [ONNX export and compile](https://github.com/piyush0108maurya/url-sms-detector/blob/main/model/export_and_compile.py): `model/export_and_compile.py`
- [ONNX model](https://github.com/piyush0108maurya/url-sms-detector/blob/main/model/phishing.onnx): `model/phishing.onnx`

### Dataset preparation

- [Dataset preparation](https://github.com/piyush0108maurya/url-sms-detector/blob/main/data/prepare_data.py): `data/prepare_data.py`
- [Shared URL normalization](https://github.com/piyush0108maurya/url-sms-detector/blob/main/common/normalize.py): `common/normalize.py`

### Other components

- **Scanner**
- **Qualcomm AI Hub**

## Connections

- Scanner → Scan UI: scans (evidence: `README.md`)
- React entry → Scan UI: renders (evidence: `frontend/src/main.jsx`)
- Scan UI → REST API: posts scans (evidence: `frontend/src/App.jsx`)
- REST API → DistilBERT classifier: loads model (evidence: `backend/main.py`)
- REST API → Input normalization: normalizes input (evidence: `backend/main.py`)
- REST API → URL indicators: extracts indicators (evidence: `backend/main.py`)
- REST API → DistilBERT classifier: runs inference (evidence: `backend/main.py`)
- REST API → Model metrics: reads metrics (evidence: `backend/main.py`)
- REST API → Snapdragon benchmark: reads benchmark (evidence: `backend/main.py`)
- Dataset preparation → Shared URL normalization: normalizes data (evidence: `data/prepare_data.py`)
- Model training → Trained model: saves model (evidence: `model/train.py`)
- ONNX export and compile → Trained model: loads model (evidence: `model/export_and_compile.py`)
- ONNX export and compile → ONNX model: exports model (evidence: `model/export_and_compile.py`)
- ONNX export and compile → Qualcomm AI Hub: submits compile and profile (evidence: `model/export_and_compile.py`)
- Model training → Dataset preparation: uses prepared splits
