# farhanhussain02/lightning-guard-prototype architecture

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

- Interactive diagram: https://gitdiagram.com/farhanhussain02/lightning-guard-prototype
- Repository: https://github.com/farhanhussain02/lightning-guard-prototype

## Overview

Lightning Guard is a web threat-analysis product. A user enters text or attaches documents/images in the React analyzer; it submits text or files to the Node backend, which uses Gemini and, for supported files, OCR or DOCX parsing. The interface presents a classification, confidence, findings, recommendations, and reporting services. Frontend request/response handling is excerpted; backend internals and the reporting implementation were not sampled, so those relationships rely on README statements.

Main entry points: [`src/components/ThreatAnalyzer.tsx`](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/components/ThreatAnalyzer.tsx) (Input and results), [`backend/server.js`](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/backend/server.js) (Analysis API), [`src/pages/Index.tsx`](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/pages/Index.tsx) (Analyzer page), [`src/components/ui`](https://github.com/farhanhussain02/lightning-guard-prototype/tree/main/src/components/ui) (UI component library)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_app["React app and routes<br/>[App.tsx]"]
  node_landing["Analyzer page<br/>[Index.tsx]"]
  node_analyzer["Input and results<br/>[ThreatAnalyzer.tsx]"]
  node_lightning["Lightning backdrop"]
  node_waves["Wave backdrop<br/>[WaveBackground.tsx]"]
  node_reports["Threat reports<br/>[ThreatAnalyzer.tsx]"]
end

subgraph group_backend["Analysis service"]
  node_backend["Analysis API<br/>[server.js]"]
end

subgraph group_integrations["Analysis integrations"]
  node_gemini["Threat intelligence"]
  node_ocr["Image text OCR"]
  node_docx["DOCX parsing"]
end

subgraph group_presentation["Interface support"]
  node_ui["UI component library"]
  node_toast["Toast state<br/>[use-toast.ts]"]
  node_utils["Style utilities<br/>[utils.ts]"]
end

node_user(("User"))

node_user -->|"enters or uploads"| node_analyzer
node_app -->|"routes to"| node_landing
node_landing -->|"renders"| node_analyzer
node_landing -->|"renders"| node_lightning
node_landing -->|"renders"| node_waves
node_analyzer -->|"posts text or files"| node_backend
node_backend -->|"requests analysis"| node_gemini
node_backend -->|"extracts image text"| node_ocr
node_backend -->|"parses DOCX"| node_docx
node_backend -->|"returns analysis"| node_analyzer
node_analyzer -->|"presents report services"| node_reports
node_analyzer -->|"renders with"| node_ui
node_analyzer -->|"notifies through"| node_toast
node_ui -->|"merges styles"| node_utils

click node_app "https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/App.tsx"
click node_landing "https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/pages/Index.tsx"
click node_analyzer "https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/components/ThreatAnalyzer.tsx"
click node_lightning "https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/components/LightningBackground.tsx"
click node_waves "https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/components/WaveBackground.tsx"
click node_backend "https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/backend/server.js"
click node_reports "https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/components/ThreatAnalyzer.tsx"
click node_ui "https://github.com/farhanhussain02/lightning-guard-prototype/tree/main/src/components/ui"
click node_toast "https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/hooks/use-toast.ts"
click node_utils "https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/lib/utils.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_app,node_landing,node_analyzer,node_lightning,node_waves,node_reports,node_user toneBlue
class node_backend toneAmber
class node_gemini,node_ocr,node_docx toneMint
class node_ui,node_toast,node_utils toneRose
```

## Components

### Web interface

- [React app and routes](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/App.tsx): `src/App.tsx`
- [Analyzer page](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/pages/Index.tsx): `src/pages/Index.tsx`
- [Input and results](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/components/ThreatAnalyzer.tsx): `src/components/ThreatAnalyzer.tsx`
- [Lightning backdrop](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/components/LightningBackground.tsx): `src/components/LightningBackground.tsx`
- [Wave backdrop](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/components/WaveBackground.tsx): `src/components/WaveBackground.tsx`
- [Threat reports](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/components/ThreatAnalyzer.tsx): `src/components/ThreatAnalyzer.tsx`

### Analysis service

- [Analysis API](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/backend/server.js): `backend/server.js`

### Analysis integrations

- **Threat intelligence**
- **Image text OCR**
- **DOCX parsing**

### Interface support

- [UI component library](https://github.com/farhanhussain02/lightning-guard-prototype/tree/main/src/components/ui): `src/components/ui`
- [Toast state](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/hooks/use-toast.ts): `src/hooks/use-toast.ts`
- [Style utilities](https://github.com/farhanhussain02/lightning-guard-prototype/blob/main/src/lib/utils.ts): `src/lib/utils.ts`

### Other components

- **User**

## Connections

- User → Input and results: enters or uploads (evidence: `src/components/ThreatAnalyzer.tsx`)
- React app and routes → Analyzer page: routes to (evidence: `src/App.tsx`)
- Analyzer page → Input and results: renders (evidence: `src/pages/Index.tsx`)
- Analyzer page → Lightning backdrop: renders (evidence: `src/pages/Index.tsx`)
- Analyzer page → Wave backdrop: renders (evidence: `src/pages/Index.tsx`)
- Input and results → Analysis API: posts text or files (evidence: `src/components/ThreatAnalyzer.tsx`)
- Analysis API → Threat intelligence: requests analysis
- Analysis API → Image text OCR: extracts image text
- Analysis API → DOCX parsing: parses DOCX
- Analysis API → Input and results: returns analysis (evidence: `src/components/ThreatAnalyzer.tsx`)
- Input and results → Threat reports: presents report services (evidence: `src/components/ThreatAnalyzer.tsx`)
- Input and results → UI component library: renders with (evidence: `src/components/ThreatAnalyzer.tsx`)
- Input and results → Toast state: notifies through (evidence: `src/components/ThreatAnalyzer.tsx`)
- UI component library → Style utilities: merges styles (evidence: `src/components/ui/button.tsx`)
