# sammy12357/safescan-qr architecture

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

- Interactive diagram: https://gitdiagram.com/sammy12357/safescan-qr
- Repository: https://github.com/sammy12357/safescan-qr

## Overview

Sqafe is a QR inspection website and scanner. Its main workflow accepts a QR image or decoded content, analyzes supported destinations for risk signals, and returns a verdict with any incomplete checks identified. The graph includes the documented camera, upload, and paste inputs, plus the backend analysis and persistence layers. It also preserves the website’s account, administration, and page-route subsystems. Some frontend and QR-decoding details are unsampled, so their connections are shown only where documented or indexed.

Main entry points: [`hackabull/pipeline.py`](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/pipeline.py) (Risk analysis), [`hackabull/routes_api.py`](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_api.py) (Scan API routes), [`hackabull/app_module.py`](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/app_module.py) (Web application), [`hackabull/auth.py`](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/auth.py) (Sessions and access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_scan["Scanning and analysis"]
  node_scanner_ui["Scanner interface<br/>[app-core.js]"]
  node_api_routes["Scan API routes<br/>[routes_api.py]"]
  node_qr_decode["QR decoding<br/>[qr_decode.py]"]
  node_analysis["Risk analysis<br/>[pipeline.py]"]
  node_allowlist["Domain allowlist"]
  node_signals["Risk signals<br/>[heuristics.py]"]
  node_redirects["Redirect checks<br/>[redirects.py]"]
  node_reputation["Reputation checks<br/>[reputation.py]"]
  node_scoring["Verdict scoring<br/>[scoring.py]"]
  node_calibration["Model calibration<br/>[decision.py]"]
end

subgraph group_web["Website and access"]
  node_account_routes["Account routes<br/>[routes_account.py]"]
  node_scan_auth_routes["Scan authentication"]
  node_admin_routes["Admin routes<br/>[routes_admin.py]"]
  node_admin_data["Admin operations<br/>[admin_data.py]"]
  node_page_routes["Page routes<br/>[routes_pages.py]"]
  node_app["Web application<br/>[app_module.py]"]
  node_auth["Sessions and access<br/>[auth.py]"]
end

subgraph group_state["Data and persistence"]
  node_history["Scan history<br/>[history.py]"]
  node_database[("SQLite database<br/>[db.py]")]
  node_blob_store[("Image storage<br/>[storage.py]")]
end

node_visitor(("Scanner user"))

node_visitor -.->|"provides input"| node_scanner_ui
node_scanner_ui -.->|"submits scan"| node_api_routes
node_api_routes -->|"decodes QR"| node_qr_decode
node_api_routes -->|"requests analysis"| node_analysis
node_analysis -->|"checks domains"| node_allowlist
node_analysis -->|"uses heuristics"| node_signals
node_analysis -->|"checks redirects"| node_redirects
node_analysis -->|"checks reputation"| node_reputation
node_analysis -->|"scores signals"| node_scoring
node_analysis -->|"calibrates model"| node_calibration
node_api_routes -->|"records scans"| node_history
node_history -->|"writes history"| node_database
node_api_routes -.->|"stores uploads"| node_blob_store
node_account_routes -->|"checks access"| node_auth
node_scan_auth_routes -->|"uses sessions"| node_auth
node_admin_routes -->|"checks access"| node_auth
node_admin_routes -->|"dispatches operations"| node_admin_data
node_page_routes -->|"checks access"| node_auth
node_app -.->|"registers routes"| node_account_routes
node_app -.->|"registers routes"| node_api_routes
node_app -.->|"registers routes"| node_admin_routes
node_app -.->|"registers routes"| node_page_routes
node_app -.->|"registers routes"| node_scan_auth_routes

click node_scanner_ui "https://github.com/sammy12357/safescan-qr/blob/main/static/app-core.js"
click node_api_routes "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_api.py"
click node_qr_decode "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/qr_decode.py"
click node_analysis "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/pipeline.py"
click node_allowlist "https://github.com/sammy12357/safescan-qr/blob/main/safescan_allowlist.py"
click node_signals "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/heuristics.py"
click node_redirects "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/redirects.py"
click node_reputation "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/reputation.py"
click node_scoring "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/scoring.py"
click node_calibration "https://github.com/sammy12357/safescan-qr/blob/main/safescan_model_calibration/decision.py"
click node_account_routes "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_account.py"
click node_scan_auth_routes "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_scan_auth.py"
click node_admin_routes "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_admin.py"
click node_admin_data "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/admin_data.py"
click node_page_routes "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_pages.py"
click node_app "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/app_module.py"
click node_auth "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/auth.py"
click node_history "https://github.com/sammy12357/safescan-qr/blob/main/hackabull/history.py"
click node_database "https://github.com/sammy12357/safescan-qr/blob/main/db.py"
click node_blob_store "https://github.com/sammy12357/safescan-qr/blob/main/storage.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_scanner_ui,node_api_routes,node_qr_decode,node_analysis,node_allowlist,node_signals,node_redirects,node_reputation,node_scoring,node_calibration,node_visitor toneBlue
class node_account_routes,node_scan_auth_routes,node_admin_routes,node_admin_data,node_page_routes,node_app,node_auth toneAmber
class node_history,node_database,node_blob_store toneMint
```

## Components

### Scanning and analysis

- [Scanner interface](https://github.com/sammy12357/safescan-qr/blob/main/static/app-core.js): `static/app-core.js`
- [Scan API routes](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_api.py): `hackabull/routes_api.py`
- [QR decoding](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/qr_decode.py): `hackabull/qr_decode.py`
- [Risk analysis](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/pipeline.py): `hackabull/pipeline.py`
- [Domain allowlist](https://github.com/sammy12357/safescan-qr/blob/main/safescan_allowlist.py): `safescan_allowlist.py`
- [Risk signals](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/heuristics.py): `hackabull/heuristics.py`
- [Redirect checks](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/redirects.py): `hackabull/redirects.py`
- [Reputation checks](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/reputation.py): `hackabull/reputation.py`
- [Verdict scoring](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/scoring.py): `hackabull/scoring.py`
- [Model calibration](https://github.com/sammy12357/safescan-qr/blob/main/safescan_model_calibration/decision.py): `safescan_model_calibration/decision.py`

### Website and access

- [Account routes](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_account.py): `hackabull/routes_account.py`
- [Scan authentication](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_scan_auth.py): `hackabull/routes_scan_auth.py`
- [Admin routes](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_admin.py): `hackabull/routes_admin.py`
- [Admin operations](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/admin_data.py): `hackabull/admin_data.py`
- [Page routes](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/routes_pages.py): `hackabull/routes_pages.py`
- [Web application](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/app_module.py): `hackabull/app_module.py`
- [Sessions and access](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/auth.py): `hackabull/auth.py`

### Data and persistence

- [Scan history](https://github.com/sammy12357/safescan-qr/blob/main/hackabull/history.py): `hackabull/history.py`
- [SQLite database](https://github.com/sammy12357/safescan-qr/blob/main/db.py): `db.py`
- [Image storage](https://github.com/sammy12357/safescan-qr/blob/main/storage.py): `storage.py`

### Other components

- **Scanner user**

## Connections

- Scanner user → Scanner interface: provides input
- Scanner interface → Scan API routes: submits scan
- Scan API routes → QR decoding: decodes QR (evidence: `hackabull/routes_api.py`)
- Scan API routes → Risk analysis: requests analysis (evidence: `hackabull/routes_api.py`)
- Risk analysis → Domain allowlist: checks domains (evidence: `hackabull/pipeline.py`)
- Risk analysis → Risk signals: uses heuristics (evidence: `hackabull/pipeline.py`)
- Risk analysis → Redirect checks: checks redirects (evidence: `hackabull/pipeline.py`)
- Risk analysis → Reputation checks: checks reputation (evidence: `hackabull/pipeline.py`)
- Risk analysis → Verdict scoring: scores signals (evidence: `hackabull/pipeline.py`)
- Risk analysis → Model calibration: calibrates model (evidence: `hackabull/pipeline.py`)
- Scan API routes → Scan history: records scans (evidence: `hackabull/routes_api.py`)
- Scan history → SQLite database: writes history (evidence: `hackabull/history.py`)
- Scan API routes → Image storage: stores uploads (evidence: `hackabull/routes_api.py`)
- Account routes → Sessions and access: checks access (evidence: `hackabull/routes_account.py`)
- Scan authentication → Sessions and access: uses sessions (evidence: `hackabull/routes_scan_auth.py`)
- Admin routes → Sessions and access: checks access (evidence: `hackabull/routes_admin.py`)
- Admin routes → Admin operations: dispatches operations (evidence: `hackabull/routes_admin.py`)
- Page routes → Sessions and access: checks access (evidence: `hackabull/routes_pages.py`)
- Web application → Account routes: registers routes (evidence: `hackabull/routes_account.py`)
- Web application → Scan API routes: registers routes (evidence: `hackabull/routes_api.py`)
- Web application → Admin routes: registers routes (evidence: `hackabull/routes_admin.py`)
- Web application → Page routes: registers routes (evidence: `hackabull/routes_pages.py`)
- Web application → Scan authentication: registers routes (evidence: `hackabull/routes_scan_auth.py`)
