# aaarya2117/phishnet-classifier architecture

> Architecture diagram of the GitHub repository aaarya2117/phishnet-classifier, 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/aaarya2117/phishnet-classifier
- Repository: https://github.com/aaarya2117/phishnet-classifier

## Overview

PhishNet is a multi-label phishing-email classifier with model training, evaluation, REST/CLI inference, analyst feedback retraining, and optional Microsoft 365 inbox quarantine. The primary workflow is email submission to inference and threat labels/quarantine status; the O365 scanner invokes that API and acts on its result. Training and retraining prepare data, fit BERT, and save model artifacts. Edges reflect the sampled Python calls and README-documented capabilities; unsampled deployment details are omitted.

Main entry points: [`src/predict.py`](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/predict.py) (Inference API and CLI), [`src/retrain.py`](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/retrain.py) (Feedback retraining), [`src/o365_integration.py`](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/o365_integration.py) (Inbox scanner), [`src/train.py`](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/train.py) (BERT training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model_lifecycle["Model lifecycle"]
  node_preprocess["Dataset preparation<br/>[preprocess.py]"]
  node_training["BERT training<br/>[train.py]"]
  node_evaluation["Model evaluation<br/>[evaluate.py]"]
  node_model_store["Saved model"]
end

subgraph group_classification["Classification"]
  node_inference_api["Inference API and CLI<br/>[predict.py]"]
  node_classification_result["Labels and decision"]
end

subgraph group_feedback["Feedback learning"]
  node_retraining["Feedback retraining<br/>[retrain.py]"]
  node_feedback_buffer["Feedback buffer"]
end

subgraph group_mail_security["Mail security"]
  node_o365_scanner["Inbox scanner"]
  node_scan_log["Scan audit log"]
end

node_analyst(("Security analyst"))
node_mail_sender(("Email sender"))
node_dataset[("Hugging Face dataset")]
node_bert_source["Pretrained BERT"]
node_graph_service["Microsoft Graph"]

node_preprocess -->|"loads"| node_dataset
node_training -->|"prepares data"| node_preprocess
node_training -->|"loads pretrained model"| node_bert_source
node_training -->|"saves model"| node_model_store
node_evaluation -->|"prepares data"| node_preprocess
node_evaluation -->|"loads model"| node_model_store
node_evaluation -->|"writes metrics"| node_classification_result
node_analyst -->|"submits email"| node_inference_api
node_inference_api -->|"loads model"| node_model_store
node_inference_api -->|"returns labels"| node_classification_result
node_analyst -->|"submits corrections"| node_inference_api
node_inference_api -->|"appends feedback"| node_feedback_buffer
node_retraining -->|"reads and clears"| node_feedback_buffer
node_retraining -->|"prepares data"| node_preprocess
node_retraining -->|"uses training helpers"| node_training
node_retraining -->|"backs up and saves"| node_model_store
node_retraining -->|"loads original data"| node_dataset
node_mail_sender -.->|"delivers email"| node_graph_service
node_o365_scanner -->|"fetches and moves mail"| node_graph_service
node_o365_scanner -->|"submits email"| node_inference_api
node_o365_scanner -->|"marks processed"| node_graph_service
node_o365_scanner -->|"appends scan results"| node_scan_log

click node_preprocess "https://github.com/aaarya2117/phishnet-classifier/blob/main/src/preprocess.py"
click node_training "https://github.com/aaarya2117/phishnet-classifier/blob/main/src/train.py"
click node_evaluation "https://github.com/aaarya2117/phishnet-classifier/blob/main/src/evaluate.py"
click node_retraining "https://github.com/aaarya2117/phishnet-classifier/blob/main/src/retrain.py"
click node_inference_api "https://github.com/aaarya2117/phishnet-classifier/blob/main/src/predict.py"
click node_o365_scanner "https://github.com/aaarya2117/phishnet-classifier/blob/main/src/o365_integration.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_preprocess,node_training,node_evaluation,node_model_store toneBlue
class node_inference_api,node_classification_result,node_dataset toneAmber
class node_retraining,node_feedback_buffer toneMint
class node_o365_scanner,node_scan_log toneRose
class node_analyst,node_mail_sender,node_bert_source,node_graph_service toneIndigo
```

## Components

### Model lifecycle

- [Dataset preparation](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/preprocess.py): `src/preprocess.py`
- [BERT training](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/train.py): `src/train.py`
- [Model evaluation](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/evaluate.py): `src/evaluate.py`
- **Saved model**

### Classification

- [Inference API and CLI](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/predict.py): `src/predict.py`
- **Labels and decision**

### Feedback learning

- [Feedback retraining](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/retrain.py): `src/retrain.py`
- **Feedback buffer**

### Mail security

- [Inbox scanner](https://github.com/aaarya2117/phishnet-classifier/blob/main/src/o365_integration.py): `src/o365_integration.py`
- **Scan audit log**

### Other components

- **Security analyst**
- **Email sender**
- **Hugging Face dataset**
- **Pretrained BERT**
- **Microsoft Graph**

## Connections

- Dataset preparation → Hugging Face dataset: loads
- BERT training → Dataset preparation: prepares data
- BERT training → Pretrained BERT: loads pretrained model
- BERT training → Saved model: saves model
- Model evaluation → Dataset preparation: prepares data
- Model evaluation → Saved model: loads model
- Model evaluation → Labels and decision: writes metrics
- Security analyst → Inference API and CLI: submits email
- Inference API and CLI → Saved model: loads model
- Inference API and CLI → Labels and decision: returns labels
- Security analyst → Inference API and CLI: submits corrections
- Inference API and CLI → Feedback buffer: appends feedback
- Feedback retraining → Feedback buffer: reads and clears
- Feedback retraining → Dataset preparation: prepares data
- Feedback retraining → BERT training: uses training helpers
- Feedback retraining → Saved model: backs up and saves
- Feedback retraining → Hugging Face dataset: loads original data
- Email sender → Microsoft Graph: delivers email
- Inbox scanner → Microsoft Graph: fetches and moves mail
- Inbox scanner → Inference API and CLI: submits email
- Inbox scanner → Microsoft Graph: marks processed
- Inbox scanner → Scan audit log: appends scan results
