# 07mickey/phishtrace architecture

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

- Interactive diagram: https://gitdiagram.com/07mickey/phishtrace
- Repository: https://github.com/07mickey/phishtrace

## Overview

PhishTrace is a passive URL-forensics product: a user submits a URL in the browser, the Flask API validates and analyzes its text, a native C++ engine supplies detection evidence, and the interface presents an explainable assessment. The graph also includes authentication and guest limits, local scan history, algorithm learning tools, and the interactive visualization. Relationships are based on excerpts, SOURCE INDEX references, and README statements; unsampled details are represented only where the README documents the capability.

Main entry points: [`PhishTrace_Backend/backend/routes/scan.py`](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/routes/scan.py) (Scan endpoint), [`engine/src/main.cpp`](https://github.com/07mickey/phishtrace/blob/main/engine/src/main.cpp) (Engine input and dispatch), [`frontend/src/js/scanner.js`](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/scanner.js) (Scan interaction), [`frontend/src/js/main.js`](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/main.js) (App bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["App bootstrap<br/>[main.js]"]
  node_scanner["Scan interaction<br/>[scanner.js]"]
  node_webapi["API client<br/>[api.js]"]
  node_report["Scan report<br/>[scanReport.js]"]
  node_history["Scan history<br/>[history.js]"]
  node_authui["Account interface<br/>[auth.js]"]
  node_navigation["Navigation<br/>[navigation.js]"]
  node_motion["UI motion utilities<br/>[motion.js]"]
end

subgraph group_api["Backend API"]
  node_flask["Flask application<br/>[app.py]"]
  node_scanroute["Scan endpoint<br/>[scan.py]"]
  node_validator["URL validation<br/>[url_validator.py]"]
  node_features["Feature extraction"]
  node_assessment["Assessment policy"]
  node_bridge["Engine bridge"]
end

subgraph group_engine["Detection engine"]
  node_engineentry["Engine input and dispatch<br/>[main.cpp]"]
  node_parser["URL parser<br/>[url_parser.cpp]"]
  node_trie["Trie matching<br/>[trie.cpp]"]
  node_hash["Reference lookup<br/>[hash_lookup.cpp]"]
  node_distance["Lookalike distance<br/>[edit_distance.cpp]"]
  node_json["Engine JSON<br/>[json_helper.h]"]
end

subgraph group_account["Access and storage"]
  node_guest["Guest allowance<br/>[guest_service.py]"]
  node_users["User accounts<br/>[user_service.py]"]
  node_authroute["Authentication routes<br/>[auth.py]"]
  node_rate["Rate limiter<br/>[rate_limiter.py]"]
  node_sqlite[("SQLite persistence<br/>[extensions.py]")]
end

subgraph group_learning["Learning and visualization"]
  node_lab["Algorithm laboratory<br/>[labView.js]"]
  node_simulators["Algorithm simulators<br/>[simulators.js]"]
  node_visualization["Threat visualization<br/>[scene.js]"]
end

node_visitor(("URL investigator"))

node_visitor -->|"submits URL"| node_scanner
node_app -->|"initializes"| node_scanner
node_scanner -->|"requests scan"| node_webapi
node_webapi -.->|"sends API request"| node_scanroute
node_scanroute -->|"validates URL"| node_validator
node_scanroute -->|"extracts features"| node_features
node_scanroute -->|"requests engine analysis"| node_bridge
node_scanroute -->|"applies policy"| node_assessment
node_scanroute -->|"checks allowance"| node_guest
node_bridge -->|"exchanges JSON"| node_engineentry
node_engineentry -->|"parses URL"| node_parser
node_engineentry -->|"matches patterns"| node_trie
node_engineentry -->|"checks references"| node_hash
node_engineentry -->|"checks lookalikes"| node_distance
node_engineentry -->|"formats response"| node_json
node_scanroute -.->|"returns assessment"| node_webapi
node_scanner -->|"renders details"| node_report
node_scanner -->|"updates scans"| node_history
node_history -->|"opens details"| node_report
node_app -->|"initializes"| node_authui
node_authui -->|"calls auth API"| node_webapi
node_authroute -->|"authenticates users"| node_users
node_authroute -->|"limits attempts"| node_rate
node_scanroute -->|"stores scan result"| node_sqlite
node_guest -->|"persists usage"| node_sqlite
node_users -->|"persists accounts"| node_sqlite
node_app -->|"initializes"| node_navigation
node_navigation -->|"opens history"| node_history
node_navigation -->|"opens laboratory"| node_lab
node_lab -->|"uses algorithms"| node_simulators
node_app -->|"initializes scene"| node_visualization
node_authui -->|"uses UI utilities"| node_motion
node_history -->|"uses UI utilities"| node_motion

click node_app "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/main.js"
click node_scanner "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/scanner.js"
click node_webapi "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/api.js"
click node_report "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/scanReport.js"
click node_history "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/history.js"
click node_authui "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/auth.js"
click node_navigation "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/navigation.js"
click node_motion "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/motion.js"
click node_flask "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/app.py"
click node_scanroute "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/routes/scan.py"
click node_validator "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/url_validator.py"
click node_features "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/feature_extractor.py"
click node_assessment "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/assessment_service.py"
click node_bridge "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/dsa_engine_bridge.py"
click node_engineentry "https://github.com/07mickey/phishtrace/blob/main/engine/src/main.cpp"
click node_parser "https://github.com/07mickey/phishtrace/blob/main/engine/src/url_parser.cpp"
click node_trie "https://github.com/07mickey/phishtrace/blob/main/engine/src/trie.cpp"
click node_hash "https://github.com/07mickey/phishtrace/blob/main/engine/src/hash_lookup.cpp"
click node_distance "https://github.com/07mickey/phishtrace/blob/main/engine/src/edit_distance.cpp"
click node_json "https://github.com/07mickey/phishtrace/blob/main/engine/src/json_helper.h"
click node_guest "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/guest_service.py"
click node_users "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/user_service.py"
click node_authroute "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/routes/auth.py"
click node_rate "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/utils/rate_limiter.py"
click node_sqlite "https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/extensions.py"
click node_lab "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/algorithms/labView.js"
click node_simulators "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/algorithms/simulators.js"
click node_visualization "https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/visualization/scene.js"

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_app,node_scanner,node_webapi,node_report,node_history,node_authui,node_navigation,node_motion toneBlue
class node_flask,node_scanroute,node_validator,node_features,node_assessment,node_bridge toneAmber
class node_engineentry,node_parser,node_trie,node_hash,node_distance,node_json toneMint
class node_guest,node_users,node_authroute,node_rate,node_sqlite toneRose
class node_lab,node_simulators,node_visualization,node_visitor toneIndigo
```

## Components

### Web application

- [App bootstrap](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/main.js): `frontend/src/js/main.js`
- [Scan interaction](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/scanner.js): `frontend/src/js/scanner.js`
- [API client](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/api.js): `frontend/src/js/api.js`
- [Scan report](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/scanReport.js): `frontend/src/js/scanReport.js`
- [Scan history](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/history.js): `frontend/src/js/history.js`
- [Account interface](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/auth.js): `frontend/src/js/auth.js`
- [Navigation](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/navigation.js): `frontend/src/js/navigation.js`
- [UI motion utilities](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/motion.js): `frontend/src/js/motion.js`

### Backend API

- [Flask application](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/app.py): `PhishTrace_Backend/backend/app.py`
- [Scan endpoint](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/routes/scan.py): `PhishTrace_Backend/backend/routes/scan.py`
- [URL validation](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/url_validator.py): `PhishTrace_Backend/backend/services/url_validator.py`
- [Feature extraction](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/feature_extractor.py): `PhishTrace_Backend/backend/services/feature_extractor.py`
- [Assessment policy](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/assessment_service.py): `PhishTrace_Backend/backend/services/assessment_service.py`
- [Engine bridge](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/dsa_engine_bridge.py): `PhishTrace_Backend/backend/services/dsa_engine_bridge.py`

### Detection engine

- [Engine input and dispatch](https://github.com/07mickey/phishtrace/blob/main/engine/src/main.cpp): `engine/src/main.cpp`
- [URL parser](https://github.com/07mickey/phishtrace/blob/main/engine/src/url_parser.cpp): `engine/src/url_parser.cpp`
- [Trie matching](https://github.com/07mickey/phishtrace/blob/main/engine/src/trie.cpp): `engine/src/trie.cpp`
- [Reference lookup](https://github.com/07mickey/phishtrace/blob/main/engine/src/hash_lookup.cpp): `engine/src/hash_lookup.cpp`
- [Lookalike distance](https://github.com/07mickey/phishtrace/blob/main/engine/src/edit_distance.cpp): `engine/src/edit_distance.cpp`
- [Engine JSON](https://github.com/07mickey/phishtrace/blob/main/engine/src/json_helper.h): `engine/src/json_helper.h`

### Access and storage

- [Guest allowance](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/guest_service.py): `PhishTrace_Backend/backend/services/guest_service.py`
- [User accounts](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/services/user_service.py): `PhishTrace_Backend/backend/services/user_service.py`
- [Authentication routes](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/routes/auth.py): `PhishTrace_Backend/backend/routes/auth.py`
- [Rate limiter](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/utils/rate_limiter.py): `PhishTrace_Backend/backend/utils/rate_limiter.py`
- [SQLite persistence](https://github.com/07mickey/phishtrace/blob/main/PhishTrace_Backend/backend/extensions.py): `PhishTrace_Backend/backend/extensions.py`

### Learning and visualization

- [Algorithm laboratory](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/algorithms/labView.js): `frontend/src/js/algorithms/labView.js`
- [Algorithm simulators](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/algorithms/simulators.js): `frontend/src/js/algorithms/simulators.js`
- [Threat visualization](https://github.com/07mickey/phishtrace/blob/main/frontend/src/js/visualization/scene.js): `frontend/src/js/visualization/scene.js`

### Other components

- **URL investigator**

## Connections

- URL investigator → Scan interaction: submits URL
- App bootstrap → Scan interaction: initializes (evidence: `frontend/src/js/main.js`)
- Scan interaction → API client: requests scan (evidence: `frontend/src/js/scanner.js`)
- API client → Scan endpoint: sends API request (evidence: `README.md`)
- Scan endpoint → URL validation: validates URL (evidence: `PhishTrace_Backend/backend/routes/scan.py`)
- Scan endpoint → Feature extraction: extracts features (evidence: `PhishTrace_Backend/backend/routes/scan.py`)
- Scan endpoint → Engine bridge: requests engine analysis (evidence: `PhishTrace_Backend/backend/routes/scan.py`)
- Scan endpoint → Assessment policy: applies policy (evidence: `PhishTrace_Backend/backend/routes/scan.py`)
- Scan endpoint → Guest allowance: checks allowance (evidence: `PhishTrace_Backend/backend/routes/scan.py`)
- Engine bridge → Engine input and dispatch: exchanges JSON (evidence: `README.md`)
- Engine input and dispatch → URL parser: parses URL (evidence: `engine/src/main.cpp`)
- Engine input and dispatch → Trie matching: matches patterns (evidence: `engine/src/main.cpp`)
- Engine input and dispatch → Reference lookup: checks references (evidence: `engine/src/main.cpp`)
- Engine input and dispatch → Lookalike distance: checks lookalikes (evidence: `engine/src/main.cpp`)
- Engine input and dispatch → Engine JSON: formats response (evidence: `engine/src/main.cpp`)
- Scan endpoint → API client: returns assessment (evidence: `README.md`)
- Scan interaction → Scan report: renders details (evidence: `frontend/src/js/scanner.js`)
- Scan interaction → Scan history: updates scans (evidence: `frontend/src/js/scanner.js`)
- Scan history → Scan report: opens details (evidence: `frontend/src/js/history.js`)
- App bootstrap → Account interface: initializes (evidence: `frontend/src/js/main.js`)
- Account interface → API client: calls auth API (evidence: `frontend/src/js/auth.js`)
- Authentication routes → User accounts: authenticates users (evidence: `PhishTrace_Backend/backend/routes/auth.py`)
- Authentication routes → Rate limiter: limits attempts (evidence: `PhishTrace_Backend/backend/routes/auth.py`)
- Scan endpoint → SQLite persistence: stores scan result (evidence: `PhishTrace_Backend/backend/extensions.py`)
- Guest allowance → SQLite persistence: persists usage (evidence: `PhishTrace_Backend/backend/services/guest_service.py`)
- User accounts → SQLite persistence: persists accounts (evidence: `PhishTrace_Backend/backend/services/user_service.py`)
- App bootstrap → Navigation: initializes (evidence: `frontend/src/js/main.js`)
- Navigation → Scan history: opens history (evidence: `frontend/src/js/navigation.js`)
- Navigation → Algorithm laboratory: opens laboratory (evidence: `frontend/src/js/navigation.js`)
- Algorithm laboratory → Algorithm simulators: uses algorithms (evidence: `frontend/src/js/algorithms/labView.js`)
- App bootstrap → Threat visualization: initializes scene (evidence: `frontend/src/js/main.js`)
- Account interface → UI motion utilities: uses UI utilities (evidence: `frontend/src/js/auth.js`)
- Scan history → UI motion utilities: uses UI utilities (evidence: `frontend/src/js/history.js`)
