# edda1011/cyberfish architecture

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

- Interactive diagram: https://gitdiagram.com/edda1011/cyberfish
- Repository: https://github.com/edda1011/cyberfish

## Overview

CyberFish is a phishing-analysis web app. Users submit a URL or email for server-side analysis, or decode a QR image locally and optionally send its decoded HTTP(S) link for URL analysis. The URL endpoint combines local checks with DNS, registration-age, and reputation results; the email endpoint combines local text, header, and attachment findings, with optional Gemini assistance. Results show a risk score, evidence, and recommended actions. The graph follows documented routes and sampled imports/calls; unsampled implementations are represented only where README capabilities establish their role.

Main entry points: [`app/api/analyze/url/route.ts`](https://github.com/edda1011/cyberfish/blob/main/app/api/analyze/url/route.ts) (URL endpoint), [`app/api/analyze/email/route.ts`](https://github.com/edda1011/cyberfish/blob/main/app/api/analyze/email/route.ts) (Email endpoint), [`app/components/email-analyzer.tsx`](https://github.com/edda1011/cyberfish/blob/main/app/components/email-analyzer.tsx) (Email analyzer), [`app/components/analyzer-switcher.tsx`](https://github.com/edda1011/cyberfish/blob/main/app/components/analyzer-switcher.tsx) (Analyzer switcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["User interface"]
  node_switcher["Analyzer switcher"]
  node_email_ui["Email analyzer<br/>[email-analyzer.tsx]"]
  node_url_ui["URL analyzer<br/>[url-analyzer.tsx]"]
  node_qr_ui["QR analyzer<br/>[qr-analyzer.tsx]"]
  node_qr_decode["QR decoder<br/>[qr-image.ts]"]
  node_results["Results view"]
end

subgraph group_email["Email analysis"]
  node_email_api["Email endpoint<br/>[route.ts]"]
  node_email_local["Local email rules<br/>[analyze-email.ts]"]
  node_eml["EML parser<br/>[eml-file.ts]"]
  node_headers["Header analysis"]
  node_attachments["Attachment assessment"]
  node_email_ai["AI result merge<br/>[email-ai.ts]"]
  node_gemini["Gemini analysis<br/>[gemini-email.ts]"]
end

subgraph group_url["URL analysis"]
  node_url_api["URL endpoint<br/>[route.ts]"]
  node_url_local["Local URL rules<br/>[analyze-url.ts]"]
  node_dns["DNS safety<br/>[dns-safety.ts]"]
  node_registration["Domain registration<br/>[rdap.ts]"]
  node_reputation["Safe Browsing"]
  node_merge_dns["DNS result merge"]
  node_merge_registration["Registration merge"]
  node_merge_reputation["Reputation merge"]
end

subgraph group_support["Shared services"]
  node_rate_limit["Rate limiting<br/>[rate-limit.ts]"]
  node_security_log["Security logging<br/>[security-log.ts]"]
end

node_user(("User"))
node_google["Google Safe Browsing"]
node_gemini_service["Google Gemini"]

node_user -->|"chooses analyzer"| node_switcher
node_switcher -->|"shows"| node_email_ui
node_switcher -->|"shows"| node_url_ui
node_switcher -->|"shows"| node_qr_ui
node_email_ui -->|"parses file"| node_eml
node_email_ui -->|"assesses metadata"| node_attachments
node_email_ui -->|"submits email"| node_email_api
node_url_ui -->|"submits URL"| node_url_api
node_qr_ui -->|"decodes locally"| node_qr_decode
node_qr_ui -->|"submits chosen link"| node_url_api
node_email_api -->|"runs local analysis"| node_email_local
node_email_api -->|"requests optional AI"| node_gemini
node_email_api -->|"merges AI result"| node_email_ai
node_email_local -->|"checks extracted links"| node_url_local
node_email_local -->|"analyzes signals"| node_headers
node_email_local -->|"analyzes metadata"| node_attachments
node_eml -->|"extracts signals"| node_headers
node_eml -->|"extracts metadata"| node_attachments
node_gemini -.->|"calls provider"| node_gemini_service
node_url_api -->|"runs local analysis"| node_url_local
node_url_api -->|"checks hostname"| node_dns
node_url_api -->|"checks domain"| node_registration
node_url_api -->|"checks URL"| node_reputation
node_url_api -->|"merges DNS result"| node_merge_dns
node_url_api -->|"merges registration"| node_merge_registration
node_url_api -->|"merges reputation"| node_merge_reputation
node_reputation -->|"queries reputation"| node_google
node_email_api -->|"limits requests"| node_rate_limit
node_email_api -->|"logs outcomes"| node_security_log
node_url_api -->|"limits requests"| node_rate_limit
node_url_api -->|"logs outcomes"| node_security_log
node_email_ui -->|"renders findings"| node_results
node_url_ui -->|"renders findings"| node_results
node_qr_ui -->|"renders link findings"| node_results

click node_switcher "https://github.com/edda1011/cyberfish/blob/main/app/components/analyzer-switcher.tsx"
click node_email_ui "https://github.com/edda1011/cyberfish/blob/main/app/components/email-analyzer.tsx"
click node_url_ui "https://github.com/edda1011/cyberfish/blob/main/app/components/url-analyzer.tsx"
click node_qr_ui "https://github.com/edda1011/cyberfish/blob/main/app/components/qr-analyzer.tsx"
click node_qr_decode "https://github.com/edda1011/cyberfish/blob/main/lib/qr-image.ts"
click node_results "https://github.com/edda1011/cyberfish/blob/main/app/components/analysis-result.tsx"
click node_email_api "https://github.com/edda1011/cyberfish/blob/main/app/api/analyze/email/route.ts"
click node_email_local "https://github.com/edda1011/cyberfish/blob/main/lib/analyze-email.ts"
click node_eml "https://github.com/edda1011/cyberfish/blob/main/lib/eml-file.ts"
click node_headers "https://github.com/edda1011/cyberfish/blob/main/lib/email-header-analysis.ts"
click node_attachments "https://github.com/edda1011/cyberfish/blob/main/lib/attachment-analysis.ts"
click node_email_ai "https://github.com/edda1011/cyberfish/blob/main/lib/email-ai.ts"
click node_gemini "https://github.com/edda1011/cyberfish/blob/main/lib/gemini-email.ts"
click node_url_api "https://github.com/edda1011/cyberfish/blob/main/app/api/analyze/url/route.ts"
click node_url_local "https://github.com/edda1011/cyberfish/blob/main/lib/analyze-url.ts"
click node_dns "https://github.com/edda1011/cyberfish/blob/main/lib/dns-safety/dns-safety.ts"
click node_registration "https://github.com/edda1011/cyberfish/blob/main/lib/domain-registration/rdap.ts"
click node_reputation "https://github.com/edda1011/cyberfish/blob/main/lib/threat-intelligence/google-safe-browsing.ts"
click node_merge_dns "https://github.com/edda1011/cyberfish/blob/main/lib/merge-dns-safety.ts"
click node_merge_registration "https://github.com/edda1011/cyberfish/blob/main/lib/merge-domain-registration.ts"
click node_merge_reputation "https://github.com/edda1011/cyberfish/blob/main/lib/merge-threat-intelligence.ts"
click node_rate_limit "https://github.com/edda1011/cyberfish/blob/main/lib/rate-limit.ts"
click node_security_log "https://github.com/edda1011/cyberfish/blob/main/lib/security-log.ts"

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_switcher,node_email_ui,node_url_ui,node_qr_ui,node_qr_decode,node_results,node_user toneBlue
class node_email_api,node_email_local,node_eml,node_headers,node_attachments,node_email_ai,node_gemini toneAmber
class node_url_api,node_url_local,node_dns,node_registration,node_reputation,node_merge_dns,node_merge_registration,node_merge_reputation toneMint
class node_rate_limit,node_security_log toneRose
class node_google,node_gemini_service toneIndigo
```

## Components

### User interface

- [Analyzer switcher](https://github.com/edda1011/cyberfish/blob/main/app/components/analyzer-switcher.tsx): `app/components/analyzer-switcher.tsx`
- [Email analyzer](https://github.com/edda1011/cyberfish/blob/main/app/components/email-analyzer.tsx): `app/components/email-analyzer.tsx`
- [URL analyzer](https://github.com/edda1011/cyberfish/blob/main/app/components/url-analyzer.tsx): `app/components/url-analyzer.tsx`
- [QR analyzer](https://github.com/edda1011/cyberfish/blob/main/app/components/qr-analyzer.tsx): `app/components/qr-analyzer.tsx`
- [QR decoder](https://github.com/edda1011/cyberfish/blob/main/lib/qr-image.ts): `lib/qr-image.ts`
- [Results view](https://github.com/edda1011/cyberfish/blob/main/app/components/analysis-result.tsx): `app/components/analysis-result.tsx`

### Email analysis

- [Email endpoint](https://github.com/edda1011/cyberfish/blob/main/app/api/analyze/email/route.ts): `app/api/analyze/email/route.ts`
- [Local email rules](https://github.com/edda1011/cyberfish/blob/main/lib/analyze-email.ts): `lib/analyze-email.ts`
- [EML parser](https://github.com/edda1011/cyberfish/blob/main/lib/eml-file.ts): `lib/eml-file.ts`
- [Header analysis](https://github.com/edda1011/cyberfish/blob/main/lib/email-header-analysis.ts): `lib/email-header-analysis.ts`
- [Attachment assessment](https://github.com/edda1011/cyberfish/blob/main/lib/attachment-analysis.ts): `lib/attachment-analysis.ts`
- [AI result merge](https://github.com/edda1011/cyberfish/blob/main/lib/email-ai.ts): `lib/email-ai.ts`
- [Gemini analysis](https://github.com/edda1011/cyberfish/blob/main/lib/gemini-email.ts): `lib/gemini-email.ts`

### URL analysis

- [URL endpoint](https://github.com/edda1011/cyberfish/blob/main/app/api/analyze/url/route.ts): `app/api/analyze/url/route.ts`
- [Local URL rules](https://github.com/edda1011/cyberfish/blob/main/lib/analyze-url.ts): `lib/analyze-url.ts`
- [DNS safety](https://github.com/edda1011/cyberfish/blob/main/lib/dns-safety/dns-safety.ts): `lib/dns-safety/dns-safety.ts`
- [Domain registration](https://github.com/edda1011/cyberfish/blob/main/lib/domain-registration/rdap.ts): `lib/domain-registration/rdap.ts`
- [Safe Browsing](https://github.com/edda1011/cyberfish/blob/main/lib/threat-intelligence/google-safe-browsing.ts): `lib/threat-intelligence/google-safe-browsing.ts`
- [DNS result merge](https://github.com/edda1011/cyberfish/blob/main/lib/merge-dns-safety.ts): `lib/merge-dns-safety.ts`
- [Registration merge](https://github.com/edda1011/cyberfish/blob/main/lib/merge-domain-registration.ts): `lib/merge-domain-registration.ts`
- [Reputation merge](https://github.com/edda1011/cyberfish/blob/main/lib/merge-threat-intelligence.ts): `lib/merge-threat-intelligence.ts`

### Shared services

- [Rate limiting](https://github.com/edda1011/cyberfish/blob/main/lib/rate-limit.ts): `lib/rate-limit.ts`
- [Security logging](https://github.com/edda1011/cyberfish/blob/main/lib/security-log.ts): `lib/security-log.ts`

### Other components

- **User**
- **Google Safe Browsing**
- **Google Gemini**

## Connections

- User → Analyzer switcher: chooses analyzer
- Analyzer switcher → Email analyzer: shows (evidence: `app/components/analyzer-switcher.tsx`)
- Analyzer switcher → URL analyzer: shows (evidence: `app/components/analyzer-switcher.tsx`)
- Analyzer switcher → QR analyzer: shows (evidence: `app/components/analyzer-switcher.tsx`)
- Email analyzer → EML parser: parses file (evidence: `app/components/email-analyzer.tsx`)
- Email analyzer → Attachment assessment: assesses metadata (evidence: `app/components/email-analyzer.tsx`)
- Email analyzer → Email endpoint: submits email (evidence: `README.md`)
- URL analyzer → URL endpoint: submits URL (evidence: `README.md`)
- QR analyzer → QR decoder: decodes locally (evidence: `app/components/qr-analyzer.tsx`)
- QR analyzer → URL endpoint: submits chosen link (evidence: `app/components/qr-analyzer.tsx`)
- Email endpoint → Local email rules: runs local analysis (evidence: `app/api/analyze/email/route.ts`)
- Email endpoint → Gemini analysis: requests optional AI (evidence: `app/api/analyze/email/route.ts`)
- Email endpoint → AI result merge: merges AI result (evidence: `app/api/analyze/email/route.ts`)
- Local email rules → Local URL rules: checks extracted links (evidence: `lib/analyze-email.ts`)
- Local email rules → Header analysis: analyzes signals (evidence: `lib/analyze-email.ts`)
- Local email rules → Attachment assessment: analyzes metadata (evidence: `lib/analyze-email.ts`)
- EML parser → Header analysis: extracts signals (evidence: `lib/eml-file.ts`)
- EML parser → Attachment assessment: extracts metadata (evidence: `lib/eml-file.ts`)
- Gemini analysis → Google Gemini: calls provider
- URL endpoint → Local URL rules: runs local analysis (evidence: `app/api/analyze/url/route.ts`)
- URL endpoint → DNS safety: checks hostname (evidence: `app/api/analyze/url/route.ts`)
- URL endpoint → Domain registration: checks domain (evidence: `app/api/analyze/url/route.ts`)
- URL endpoint → Safe Browsing: checks URL (evidence: `app/api/analyze/url/route.ts`)
- URL endpoint → DNS result merge: merges DNS result (evidence: `app/api/analyze/url/route.ts`)
- URL endpoint → Registration merge: merges registration (evidence: `app/api/analyze/url/route.ts`)
- URL endpoint → Reputation merge: merges reputation (evidence: `app/api/analyze/url/route.ts`)
- Safe Browsing → Google Safe Browsing: queries reputation (evidence: `README.md`)
- Email endpoint → Rate limiting: limits requests (evidence: `app/api/analyze/email/route.ts`)
- Email endpoint → Security logging: logs outcomes (evidence: `app/api/analyze/email/route.ts`)
- URL endpoint → Rate limiting: limits requests (evidence: `app/api/analyze/url/route.ts`)
- URL endpoint → Security logging: logs outcomes (evidence: `app/api/analyze/url/route.ts`)
- Email analyzer → Results view: renders findings (evidence: `app/components/email-analyzer.tsx`)
- URL analyzer → Results view: renders findings (evidence: `app/components/url-analyzer.tsx`)
- QR analyzer → Results view: renders link findings (evidence: `app/components/qr-analyzer.tsx`)
