# sanjayk-netizen/protector architecture

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

- Interactive diagram: https://gitdiagram.com/sanjayk-netizen/protector
- Repository: https://github.com/sanjayk-netizen/protector

## Overview

QRShield is a local browser app for inspecting QR payment payloads, explaining matched risk patterns, and supporting synthetic scenario comparisons and consent-based test sessions. The main inspection flow is user input or scanning, local payload parsing, risk assessment, then payment details and a verdict; it does not contact a bank, merchant, or server. The graph also covers session recording, browser history, and CSV export. Some connections rely on the README or SOURCE INDEX because those source excerpts are incomplete.

Main entry points: [`src/App.tsx`](https://github.com/sanjayk-netizen/protector/blob/main/src/App.tsx) (App router), [`src/screens/TestSessionScreen.tsx`](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/TestSessionScreen.tsx) (Test session), [`src/lib/scenarios.ts`](https://github.com/sanjayk-netizen/protector/blob/main/src/lib/scenarios.ts) (Scenario engine), [`src/screens/InspectScreen.tsx`](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/InspectScreen.tsx) (Inspect screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and screens"]
  node_app["App router<br/>[App.tsx]"]
  node_routing["Hash routing<br/>[routing.ts]"]
  node_navigation["Navigation<br/>[AppNavigation.tsx]"]
  node_dashboard["Dashboard"]
  node_limitations["Limitations screen"]
end

subgraph group_inspection["QR inspection"]
  node_inspect["Inspect screen<br/>[InspectScreen.tsx]"]
  node_scanner["Camera and upload scan<br/>[CameraScanner.tsx]"]
  node_parser["UPI payload parser<br/>[upiParser.ts]"]
  node_payment["Payment details<br/>[PaymentCard.tsx]"]
  node_verdict["Verdict display<br/>[VerdictPanel.tsx]"]
  node_badge["Verdict badge<br/>[VerdictBadge.tsx]"]
end

subgraph group_evaluation["Risk and scenarios"]
  node_rules["Risk rules<br/>[riskRules.ts]"]
  node_config["Risk configuration<br/>[config.ts]"]
  node_handles["Known handles<br/>[knownHandles.json]"]
  node_assessment["Mode assessment<br/>[assessment.ts]"]
  node_scenarios["Scenario engine<br/>[scenarios.ts]"]
  node_scenario_data["Synthetic scenarios<br/>[scenarios.json]"]
  node_compare["Compare screen<br/>[CompareScreen.tsx]"]
  node_scenario_screen["Scenario screen<br/>[ScenarioScreen.tsx]"]
end

subgraph group_research["Sessions and history"]
  node_session_screen["Test session"]
  node_start["Session start<br/>[StartScreen.tsx]"]
  node_summary["Session summary<br/>[SummaryScreen.tsx]"]
  node_session["Session planning and records<br/>[session.ts]"]
  node_history_screen["History screen<br/>[HistoryScreen.tsx]"]
  node_history["History store<br/>[history.ts]"]
  node_csv["CSV export<br/>[csv.ts]"]
end

node_user(("User"))
node_browser_store[("Browser local storage")]

node_user -->|"uses"| node_app
node_app -->|"reads route"| node_routing
node_app -->|"renders"| node_navigation
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_inspect
node_app -->|"renders"| node_compare
node_app -->|"renders"| node_session_screen
node_app -->|"renders"| node_history_screen
node_app -->|"renders"| node_limitations
node_inspect -->|"opens scanner"| node_scanner
node_inspect -->|"parses payload"| node_parser
node_inspect -->|"evaluates risk"| node_rules
node_inspect -->|"renders details"| node_payment
node_inspect -->|"renders assessment"| node_verdict
node_parser -->|"supplies payload"| node_rules
node_rules -->|"uses thresholds"| node_config
node_rules -->|"checks handles"| node_handles
node_verdict -->|"renders"| node_badge
node_compare -->|"loads scenarios"| node_scenarios
node_compare -->|"parses payload"| node_parser
node_compare -->|"renders details"| node_payment
node_compare -->|"renders assessment"| node_verdict
node_scenarios -->|"loads cases"| node_scenario_data
node_scenarios -->|"loads handles"| node_handles
node_scenarios -->|"parses cases"| node_parser
node_scenarios -->|"assesses cases"| node_rules
node_session_screen -->|"renders start"| node_start
node_session_screen -->|"renders trials"| node_scenario_screen
node_session_screen -->|"renders summary"| node_summary
node_session_screen -->|"plans and records"| node_session
node_session_screen -->|"assesses QRShield mode"| node_assessment
node_session_screen -->|"uses cases"| node_scenarios
node_session_screen -.->|"appends decisions"| node_history
node_assessment -->|"evaluates payload"| node_rules
node_assessment -->|"uses engine options"| node_scenarios
node_scenario_screen -->|"assesses mode"| node_assessment
node_scenario_screen -->|"renders details"| node_payment
node_scenario_screen -->|"renders assessment"| node_verdict
node_dashboard -->|"reads records"| node_history
node_history_screen -->|"reads records"| node_history
node_history_screen -->|"exports records"| node_csv
node_history -->|"reads and writes"| node_browser_store
node_csv -->|"formats records"| node_history

click node_app "https://github.com/sanjayk-netizen/protector/blob/main/src/App.tsx"
click node_routing "https://github.com/sanjayk-netizen/protector/blob/main/src/lib/routing.ts"
click node_navigation "https://github.com/sanjayk-netizen/protector/blob/main/src/components/AppNavigation.tsx"
click node_dashboard "https://github.com/sanjayk-netizen/protector/blob/main/src/screens/DashboardScreen.tsx"
click node_inspect "https://github.com/sanjayk-netizen/protector/blob/main/src/screens/InspectScreen.tsx"
click node_scanner "https://github.com/sanjayk-netizen/protector/blob/main/src/components/CameraScanner.tsx"
click node_parser "https://github.com/sanjayk-netizen/protector/blob/main/src/lib/upiParser.ts"
click node_payment "https://github.com/sanjayk-netizen/protector/blob/main/src/components/PaymentCard.tsx"
click node_verdict "https://github.com/sanjayk-netizen/protector/blob/main/src/components/VerdictPanel.tsx"
click node_badge "https://github.com/sanjayk-netizen/protector/blob/main/src/components/VerdictBadge.tsx"
click node_rules "https://github.com/sanjayk-netizen/protector/blob/main/src/lib/riskRules.ts"
click node_config "https://github.com/sanjayk-netizen/protector/blob/main/src/config.ts"
click node_handles "https://github.com/sanjayk-netizen/protector/blob/main/src/data/knownHandles.json"
click node_assessment "https://github.com/sanjayk-netizen/protector/blob/main/src/lib/assessment.ts"
click node_scenarios "https://github.com/sanjayk-netizen/protector/blob/main/src/lib/scenarios.ts"
click node_scenario_data "https://github.com/sanjayk-netizen/protector/blob/main/src/data/scenarios.json"
click node_compare "https://github.com/sanjayk-netizen/protector/blob/main/src/screens/CompareScreen.tsx"
click node_scenario_screen "https://github.com/sanjayk-netizen/protector/blob/main/src/screens/ScenarioScreen.tsx"
click node_session_screen "https://github.com/sanjayk-netizen/protector/blob/main/src/screens/TestSessionScreen.tsx"
click node_start "https://github.com/sanjayk-netizen/protector/blob/main/src/screens/StartScreen.tsx"
click node_summary "https://github.com/sanjayk-netizen/protector/blob/main/src/screens/SummaryScreen.tsx"
click node_session "https://github.com/sanjayk-netizen/protector/blob/main/src/lib/session.ts"
click node_history_screen "https://github.com/sanjayk-netizen/protector/blob/main/src/screens/HistoryScreen.tsx"
click node_history "https://github.com/sanjayk-netizen/protector/blob/main/src/lib/history.ts"
click node_csv "https://github.com/sanjayk-netizen/protector/blob/main/src/lib/csv.ts"
click node_limitations "https://github.com/sanjayk-netizen/protector/blob/main/src/screens/LimitationsScreen.tsx"

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_routing,node_navigation,node_dashboard,node_limitations,node_user toneBlue
class node_inspect,node_scanner,node_parser,node_payment,node_verdict,node_badge,node_browser_store toneAmber
class node_rules,node_config,node_handles,node_assessment,node_scenarios,node_scenario_data,node_compare,node_scenario_screen toneMint
class node_session_screen,node_start,node_summary,node_session,node_history_screen,node_history,node_csv toneRose
```

## Components

### App and screens

- [App router](https://github.com/sanjayk-netizen/protector/blob/main/src/App.tsx): `src/App.tsx`
- [Hash routing](https://github.com/sanjayk-netizen/protector/blob/main/src/lib/routing.ts): `src/lib/routing.ts`
- [Navigation](https://github.com/sanjayk-netizen/protector/blob/main/src/components/AppNavigation.tsx): `src/components/AppNavigation.tsx`
- [Dashboard](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/DashboardScreen.tsx): `src/screens/DashboardScreen.tsx`
- [Limitations screen](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/LimitationsScreen.tsx): `src/screens/LimitationsScreen.tsx`

### QR inspection

- [Inspect screen](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/InspectScreen.tsx): `src/screens/InspectScreen.tsx`
- [Camera and upload scan](https://github.com/sanjayk-netizen/protector/blob/main/src/components/CameraScanner.tsx): `src/components/CameraScanner.tsx`
- [UPI payload parser](https://github.com/sanjayk-netizen/protector/blob/main/src/lib/upiParser.ts): `src/lib/upiParser.ts`
- [Payment details](https://github.com/sanjayk-netizen/protector/blob/main/src/components/PaymentCard.tsx): `src/components/PaymentCard.tsx`
- [Verdict display](https://github.com/sanjayk-netizen/protector/blob/main/src/components/VerdictPanel.tsx): `src/components/VerdictPanel.tsx`
- [Verdict badge](https://github.com/sanjayk-netizen/protector/blob/main/src/components/VerdictBadge.tsx): `src/components/VerdictBadge.tsx`

### Risk and scenarios

- [Risk rules](https://github.com/sanjayk-netizen/protector/blob/main/src/lib/riskRules.ts): `src/lib/riskRules.ts`
- [Risk configuration](https://github.com/sanjayk-netizen/protector/blob/main/src/config.ts): `src/config.ts`
- [Known handles](https://github.com/sanjayk-netizen/protector/blob/main/src/data/knownHandles.json): `src/data/knownHandles.json`
- [Mode assessment](https://github.com/sanjayk-netizen/protector/blob/main/src/lib/assessment.ts): `src/lib/assessment.ts`
- [Scenario engine](https://github.com/sanjayk-netizen/protector/blob/main/src/lib/scenarios.ts): `src/lib/scenarios.ts`
- [Synthetic scenarios](https://github.com/sanjayk-netizen/protector/blob/main/src/data/scenarios.json): `src/data/scenarios.json`
- [Compare screen](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/CompareScreen.tsx): `src/screens/CompareScreen.tsx`
- [Scenario screen](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/ScenarioScreen.tsx): `src/screens/ScenarioScreen.tsx`

### Sessions and history

- [Test session](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/TestSessionScreen.tsx): `src/screens/TestSessionScreen.tsx`
- [Session start](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/StartScreen.tsx): `src/screens/StartScreen.tsx`
- [Session summary](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/SummaryScreen.tsx): `src/screens/SummaryScreen.tsx`
- [Session planning and records](https://github.com/sanjayk-netizen/protector/blob/main/src/lib/session.ts): `src/lib/session.ts`
- [History screen](https://github.com/sanjayk-netizen/protector/blob/main/src/screens/HistoryScreen.tsx): `src/screens/HistoryScreen.tsx`
- [History store](https://github.com/sanjayk-netizen/protector/blob/main/src/lib/history.ts): `src/lib/history.ts`
- [CSV export](https://github.com/sanjayk-netizen/protector/blob/main/src/lib/csv.ts): `src/lib/csv.ts`

### Other components

- **User**
- **Browser local storage**

## Connections

- User → App router: uses (evidence: `README.md`)
- App router → Hash routing: reads route (evidence: `src/App.tsx`)
- App router → Navigation: renders (evidence: `src/App.tsx`)
- App router → Dashboard: renders (evidence: `src/App.tsx`)
- App router → Inspect screen: renders (evidence: `src/App.tsx`)
- App router → Compare screen: renders (evidence: `src/App.tsx`)
- App router → Test session: renders (evidence: `src/App.tsx`)
- App router → History screen: renders (evidence: `src/App.tsx`)
- App router → Limitations screen: renders (evidence: `src/App.tsx`)
- Inspect screen → Camera and upload scan: opens scanner (evidence: `src/screens/InspectScreen.tsx`)
- Inspect screen → UPI payload parser: parses payload (evidence: `src/screens/InspectScreen.tsx`)
- Inspect screen → Risk rules: evaluates risk (evidence: `src/screens/InspectScreen.tsx`)
- Inspect screen → Payment details: renders details (evidence: `src/screens/InspectScreen.tsx`)
- Inspect screen → Verdict display: renders assessment (evidence: `src/screens/InspectScreen.tsx`)
- UPI payload parser → Risk rules: supplies payload (evidence: `src/lib/riskRules.ts`)
- Risk rules → Risk configuration: uses thresholds (evidence: `src/lib/riskRules.ts`)
- Risk rules → Known handles: checks handles (evidence: `src/lib/riskRules.ts`)
- Verdict display → Verdict badge: renders (evidence: `src/components/VerdictPanel.tsx`)
- Compare screen → Scenario engine: loads scenarios (evidence: `src/screens/CompareScreen.tsx`)
- Compare screen → UPI payload parser: parses payload (evidence: `src/screens/CompareScreen.tsx`)
- Compare screen → Payment details: renders details (evidence: `src/screens/CompareScreen.tsx`)
- Compare screen → Verdict display: renders assessment (evidence: `src/screens/CompareScreen.tsx`)
- Scenario engine → Synthetic scenarios: loads cases (evidence: `src/lib/scenarios.ts`)
- Scenario engine → Known handles: loads handles (evidence: `src/lib/scenarios.ts`)
- Scenario engine → UPI payload parser: parses cases (evidence: `src/lib/scenarios.ts`)
- Scenario engine → Risk rules: assesses cases (evidence: `src/lib/scenarios.ts`)
- Test session → Session start: renders start (evidence: `src/screens/TestSessionScreen.tsx`)
- Test session → Scenario screen: renders trials (evidence: `src/screens/TestSessionScreen.tsx`)
- Test session → Session summary: renders summary (evidence: `src/screens/TestSessionScreen.tsx`)
- Test session → Session planning and records: plans and records (evidence: `src/screens/TestSessionScreen.tsx`)
- Test session → Mode assessment: assesses QRShield mode (evidence: `src/screens/TestSessionScreen.tsx`)
- Test session → Scenario engine: uses cases (evidence: `src/screens/TestSessionScreen.tsx`)
- Test session → History store: appends decisions (evidence: `src/screens/TestSessionScreen.tsx`)
- Mode assessment → Risk rules: evaluates payload (evidence: `src/lib/assessment.ts`)
- Mode assessment → Scenario engine: uses engine options (evidence: `src/lib/assessment.ts`)
- Scenario screen → Mode assessment: assesses mode (evidence: `src/screens/ScenarioScreen.tsx`)
- Scenario screen → Payment details: renders details (evidence: `src/screens/ScenarioScreen.tsx`)
- Scenario screen → Verdict display: renders assessment (evidence: `src/screens/ScenarioScreen.tsx`)
- Dashboard → History store: reads records (evidence: `src/screens/DashboardScreen.tsx`)
- History screen → History store: reads records (evidence: `src/screens/HistoryScreen.tsx`)
- History screen → CSV export: exports records (evidence: `src/screens/HistoryScreen.tsx`)
- History store → Browser local storage: reads and writes (evidence: `src/lib/history.ts`)
- CSV export → History store: formats records (evidence: `src/lib/csv.ts`)
