# harshithaj79/phishsynth-ai architecture

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

- Interactive diagram: https://gitdiagram.com/harshithaj79/phishsynth-ai
- Repository: https://github.com/harshithaj79/phishsynth-ai

## Overview

PhishSynth AI is a defensive synthetic-email generation and phishing-detection workbench. Users configure samples in the browser, generate them through the Flask API using Groq or offline templates, apply safety checks, and optionally save them to a deduplicated dataset. The same dataset supports quality analysis, refinement, export, model training and evaluation; users can also classify pasted email or evaluate a labelled CSV. The graph combines README-described capabilities with sampled source relationships; some route-level wiring is documented but not fully excerpted.

Main entry points: [`app.py`](https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py) (Flask API), [`static/js/main.js`](https://github.com/harshithaj79/phishsynth-ai/blob/main/static/js/main.js) (Browser UI), [`core/ml.py`](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py) (Model training), [`core/store.py`](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/store.py) (Dataset store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_generation["Safe generation"]
  node_taxonomy["Categories and styles<br/>[taxonomy.py]"]
  node_prompt["Prompt construction<br/>[app.py]"]
  node_groq["Groq model"]
  node_offline["Template generator<br/>[offline.py]"]
  node_safety["Safety checks<br/>[safety.py]"]
end

subgraph group_dataset["Dataset management"]
  node_datasetbuild["Bulk dataset builder<br/>[app.py]"]
  node_store[("Dataset store<br/>[store.py]")]
  node_quality["Quality analysis<br/>[ml.py]"]
  node_refine["Near-duplicate refinement<br/>[ml.py]"]
  node_export["Dataset export<br/>[app.py]"]
end

subgraph group_detection["Detection and evaluation"]
  node_features["Feature engineering<br/>[ml.py]"]
  node_training["Model training<br/>[ml.py]"]
  node_evaluation["Model evaluation<br/>[ml.py]"]
  node_livecheck["Live email detector<br/>[app.py]"]
  node_uploadcheck["CSV evaluation<br/>[app.py]"]
end

subgraph group_experience["Web experience"]
  node_browser["Browser UI<br/>[main.js]"]
  node_webpage["Application page<br/>[index.html]"]
  node_flask["Flask API<br/>[app.py]"]
end

node_user(("Security researcher"))

node_user -->|"uses"| node_browser
node_webpage -->|"hosts"| node_browser
node_browser -->|"sends JSON"| node_flask
node_flask -->|"builds prompts"| node_prompt
node_prompt -->|"uses categories"| node_taxonomy
node_prompt -->|"requests samples"| node_groq
node_prompt -.->|"falls back"| node_offline
node_flask -->|"sanitizes and validates"| node_safety
node_offline -->|"uses categories"| node_taxonomy
node_flask -->|"handles build requests"| node_datasetbuild
node_datasetbuild -->|"generates samples"| node_offline
node_datasetbuild -->|"adds rows"| node_store
node_flask -->|"stores generated rows"| node_store
node_flask -->|"requests summary"| node_quality
node_flask -->|"requests deduplication"| node_refine
node_refine -->|"replaces rows"| node_store
node_flask -->|"serves downloads"| node_export
node_store -->|"provides dataset"| node_export
node_browser -->|"shows summary"| node_quality
node_browser -->|"requests refinement"| node_refine
node_browser -->|"downloads dataset"| node_export
node_flask -->|"trains model"| node_training
node_store -->|"provides dataset"| node_training
node_training -->|"builds features"| node_features
node_training -->|"evaluates model"| node_evaluation
node_browser -->|"requests training"| node_training
node_flask -->|"handles predictions"| node_livecheck
node_livecheck -->|"uses trained model"| node_training
node_browser -->|"submits email"| node_livecheck
node_flask -->|"scores uploaded CSV"| node_uploadcheck
node_uploadcheck -.->|"computes metrics"| node_evaluation
node_browser -->|"uploads labelled CSV"| node_uploadcheck

click node_browser "https://github.com/harshithaj79/phishsynth-ai/blob/main/static/js/main.js"
click node_webpage "https://github.com/harshithaj79/phishsynth-ai/blob/main/templates/index.html"
click node_flask "https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py"
click node_taxonomy "https://github.com/harshithaj79/phishsynth-ai/blob/main/core/taxonomy.py"
click node_prompt "https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py"
click node_offline "https://github.com/harshithaj79/phishsynth-ai/blob/main/core/offline.py"
click node_safety "https://github.com/harshithaj79/phishsynth-ai/blob/main/core/safety.py"
click node_datasetbuild "https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py"
click node_store "https://github.com/harshithaj79/phishsynth-ai/blob/main/core/store.py"
click node_quality "https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py"
click node_refine "https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py"
click node_export "https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py"
click node_features "https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py"
click node_training "https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py"
click node_evaluation "https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py"
click node_livecheck "https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py"
click node_uploadcheck "https://github.com/harshithaj79/phishsynth-ai/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_taxonomy,node_prompt,node_groq,node_offline,node_safety toneBlue
class node_datasetbuild,node_store,node_quality,node_refine,node_export toneAmber
class node_features,node_training,node_evaluation,node_livecheck,node_uploadcheck toneMint
class node_browser,node_webpage,node_flask toneRose
class node_user toneIndigo
```

## Components

### Safe generation

- [Categories and styles](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/taxonomy.py): `core/taxonomy.py`
- [Prompt construction](https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py): `app.py`
- **Groq model**
- [Template generator](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/offline.py): `core/offline.py`
- [Safety checks](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/safety.py): `core/safety.py`

### Dataset management

- [Bulk dataset builder](https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py): `app.py`
- [Dataset store](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/store.py): `core/store.py`
- [Quality analysis](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py): `core/ml.py`
- [Near-duplicate refinement](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py): `core/ml.py`
- [Dataset export](https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py): `app.py`

### Detection and evaluation

- [Feature engineering](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py): `core/ml.py`
- [Model training](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py): `core/ml.py`
- [Model evaluation](https://github.com/harshithaj79/phishsynth-ai/blob/main/core/ml.py): `core/ml.py`
- [Live email detector](https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py): `app.py`
- [CSV evaluation](https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py): `app.py`

### Web experience

- [Browser UI](https://github.com/harshithaj79/phishsynth-ai/blob/main/static/js/main.js): `static/js/main.js`
- [Application page](https://github.com/harshithaj79/phishsynth-ai/blob/main/templates/index.html): `templates/index.html`
- [Flask API](https://github.com/harshithaj79/phishsynth-ai/blob/main/app.py): `app.py`

### Other components

- **Security researcher**

## Connections

- Security researcher → Browser UI: uses (evidence: `README.md`)
- Application page → Browser UI: hosts (evidence: `README.md`)
- Browser UI → Flask API: sends JSON (evidence: `static/js/main.js`)
- Flask API → Prompt construction: builds prompts (evidence: `README.md`)
- Prompt construction → Categories and styles: uses categories (evidence: `README.md`)
- Prompt construction → Groq model: requests samples (evidence: `README.md`)
- Prompt construction → Template generator: falls back (evidence: `README.md`)
- Flask API → Safety checks: sanitizes and validates (evidence: `app.py`)
- Template generator → Categories and styles: uses categories (evidence: `core/offline.py`)
- Flask API → Bulk dataset builder: handles build requests (evidence: `README.md`)
- Bulk dataset builder → Template generator: generates samples (evidence: `README.md`)
- Bulk dataset builder → Dataset store: adds rows (evidence: `README.md`)
- Flask API → Dataset store: stores generated rows (evidence: `README.md`)
- Flask API → Quality analysis: requests summary (evidence: `README.md`)
- Flask API → Near-duplicate refinement: requests deduplication (evidence: `README.md`)
- Near-duplicate refinement → Dataset store: replaces rows (evidence: `README.md`)
- Flask API → Dataset export: serves downloads (evidence: `README.md`)
- Dataset store → Dataset export: provides dataset (evidence: `README.md`)
- Browser UI → Quality analysis: shows summary (evidence: `static/js/main.js`)
- Browser UI → Near-duplicate refinement: requests refinement (evidence: `static/js/main.js`)
- Browser UI → Dataset export: downloads dataset (evidence: `README.md`)
- Flask API → Model training: trains model (evidence: `README.md`)
- Dataset store → Model training: provides dataset (evidence: `README.md`)
- Model training → Feature engineering: builds features (evidence: `core/ml.py`)
- Model training → Model evaluation: evaluates model (evidence: `core/ml.py`)
- Browser UI → Model training: requests training (evidence: `static/js/main.js`)
- Flask API → Live email detector: handles predictions (evidence: `README.md`)
- Live email detector → Model training: uses trained model (evidence: `README.md`)
- Browser UI → Live email detector: submits email (evidence: `static/js/main.js`)
- Flask API → CSV evaluation: scores uploaded CSV (evidence: `README.md`)
- CSV evaluation → Model evaluation: computes metrics (evidence: `app.py`)
- Browser UI → CSV evaluation: uploads labelled CSV (evidence: `static/js/main.js`)
