# harsh-2418/kryptic-vision-hub architecture

> Architecture diagram of the GitHub repository harsh-2418/kryptic-vision-hub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harsh-2418/kryptic-vision-hub
- Repository: https://github.com/harsh-2418/kryptic-vision-hub

## Overview

#### Purpose and Runtime
Kryptic Vision Hub is a Flask-based educational cybersecurity analysis platform. It serves server-rendered HTML, rule-based security analysis, user/account workflows, analytics, audit logging, and generated reports. Launch is through `app.py`; application settings and secrets originate in `config.py`.

#### Application Composition
`app.py` is the composition root: it initializes Flask and registers route modules as blueprints. Route handlers form the web/API boundary, render templates, enforce session/account access, invoke scanners, and persist or retrieve application data. Shared UI is template/static-asset based, centered on `templates/base.html` and browser JavaScript under `static/js/`.

#### Authentication, Accounts, and Administration
Authentication and registration enter through `routes/auth.py`. User profile/password/avatar management and UI preferences are isolated in `routes/profile.py` and `routes/settings.py`. Administrative control is separated in `routes/admin.py`, with the documented restricted admin identity. These flows depend on persisted user records and establish the access boundary for dashboard, history, logs, and privileged cleanup operations.

#### Analysis Modules
Each analysis capability has a route adapter and a standalone rule engine:
- URL/phishing scanning: `routes/scanner.py` → `scanner/phishing_detector.py`
- SQL static inspection: `routes/sql_routes.py` → `scanner/sql_analyzer.py`
- XSS static inspection: `routes/xss_routes.py` → `scanner/xss_analyzer.py`
- WiFi configuration simulation: `routes/wifi_routes.py` → `scanner/wifi_detector.py`
- Evil-twin simulation: `routes/evil_twin_routes.py` → `scanner/evil_twin_detector.py`

Inputs are submitted from module pages, evaluated server-side without ML or paid threat APIs, then rendered through unified result-oriented views such as `templates/analysis_result.html`.

#### Persistence, History, and Audit Boundary
SQLite is the system-of-record layer. Schema initialization and parameterized database access reside in `database/db.py`; the local database artifact is `database/database.db`. Scan outcomes feed user history and aggregate metrics; account actions, scans, profile changes, and report exports feed the audit-log surface exposed by `routes/logs.py`. This creates a clear boundary between stateless analysis engines and durable application state.

#### Dashboard and Reporting
`routes/dashboard.py` exposes dashboard data and chart-oriented analytics, rendered in `templates/dashboard.html` and visualized by `static/js/charts.js` using Chart.js. It aggregates users, scans, module usage, safety outcomes, and daily activity from persisted records. `routes/reports.py` generates server-side ReportLab PDF exports; report artifacts are stored under `reports/`, alongside existing JSON output such as `reports/scan_report_2.json`.

#### External Dependencies and Delivery Surface
Material runtime dependencies are Flask/Werkzeug for HTTP and authentication-adjacent utilities, `requests` for URL-related checks, ReportLab for PDF generation, and Chart.js in the browser. The app is a local Flask service, documented at `http://localhost:5000`; it uses local SQLite and filesystem report storage rather than cloud infrastructure or external security APIs.

Main entry points: [`app.py`](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/app.py) (Application composition), [`database/db.py`](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/database/db.py) (Database access and schema), [`routes/scanner.py`](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/scanner.py) (URL scan route), [`routes/sql_routes.py`](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/sql_routes.py) (SQL scan route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Flask web boundary"]
  node_app["Application composition<br/>Flask application<br/>[app.py]"]
  node_account_routes["Account and admin routes<br/>Flask blueprints<br/>[auth.py]"]
  node_scanner_routes["URL scan route<br/>Flask blueprint<br/>[scanner.py]"]
  node_sql_routes["SQL scan route<br/>Flask blueprint<br/>[sql_routes.py]"]
  node_xss_routes["XSS scan route<br/>Flask blueprint<br/>[xss_routes.py]"]
  node_wifi_routes["WiFi simulation route<br/>Flask blueprint<br/>[wifi_routes.py]"]
  node_evil_twin_routes["Evil-twin simulation route<br/>Flask blueprint"]
  node_dashboard["Dashboard analytics<br/>Flask blueprint<br/>[dashboard.py]"]
  node_logs["Audit-log route<br/>Flask blueprint<br/>[logs.py]"]
  node_reports["Report export route<br/>Flask blueprint<br/>[reports.py]"]
  node_ui["Server-rendered UI<br/>templates and browser assets<br/>[base.html]"]
end

subgraph group_analysis["Rule-based analysis"]
  node_phishing_engine{{"Phishing rules<br/>rule engine"}}
  node_sql_engine{{"SQL inspection rules<br/>rule engine<br/>[sql_analyzer.py]"}}
  node_xss_engine{{"XSS inspection rules<br/>rule engine<br/>[xss_analyzer.py]"}}
  node_wifi_engine{{"WiFi simulation rules<br/>rule engine<br/>[wifi_detector.py]"}}
  node_evil_twin_engine{{"Evil-twin rules<br/>rule engine"}}
end

subgraph group_state["State and reporting"]
  node_db_access["Database access and schema<br/>SQLite data layer<br/>[db.py]"]
  node_sqlite[("Application database<br/>SQLite system of record<br/>[database.db]")]
  node_report_storage["Report artifacts<br/>filesystem storage"]
end

node_config["Settings and secrets<br/>configuration<br/>[config.py]"]

node_config -->|"configures"| node_app
node_app -->|"registers"| node_account_routes
node_app -->|"registers"| node_scanner_routes
node_app -->|"registers"| node_sql_routes
node_app -->|"registers"| node_xss_routes
node_app -->|"registers"| node_wifi_routes
node_app -->|"registers"| node_evil_twin_routes
node_app -->|"registers"| node_dashboard
node_app -->|"registers"| node_logs
node_app -->|"registers"| node_reports
node_account_routes -->|"accounts and access"| node_db_access
node_scanner_routes -->|"evaluates URL"| node_phishing_engine
node_sql_routes -->|"inspects SQL"| node_sql_engine
node_xss_routes -->|"inspects XSS"| node_xss_engine
node_wifi_routes -->|"simulates"| node_wifi_engine
node_evil_twin_routes -->|"simulates"| node_evil_twin_engine
node_scanner_routes -->|"persists outcomes"| node_db_access
node_sql_routes -->|"persists outcomes"| node_db_access
node_xss_routes -->|"persists outcomes"| node_db_access
node_wifi_routes -->|"persists outcomes"| node_db_access
node_evil_twin_routes -->|"persists outcomes"| node_db_access
node_dashboard -->|"aggregates metrics"| node_db_access
node_logs -->|"reads audit events"| node_db_access
node_reports -->|"reads report data"| node_db_access
node_reports -->|"writes exports"| node_report_storage
node_db_access -->|"reads and writes"| node_sqlite
node_dashboard -->|"renders dashboard"| node_ui
node_scanner_routes -->|"renders results"| node_ui

click node_config "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/config.py"
click node_app "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/app.py"
click node_account_routes "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/auth.py"
click node_scanner_routes "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/scanner.py"
click node_sql_routes "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/sql_routes.py"
click node_xss_routes "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/xss_routes.py"
click node_wifi_routes "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/wifi_routes.py"
click node_evil_twin_routes "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/evil_twin_routes.py"
click node_dashboard "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/dashboard.py"
click node_logs "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/logs.py"
click node_reports "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/reports.py"
click node_ui "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/templates/base.html"
click node_phishing_engine "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/phishing_detector.py"
click node_sql_engine "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/sql_analyzer.py"
click node_xss_engine "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/xss_analyzer.py"
click node_wifi_engine "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/wifi_detector.py"
click node_evil_twin_engine "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/evil_twin_detector.py"
click node_db_access "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/database/db.py"
click node_sqlite "https://github.com/harsh-2418/kryptic-vision-hub/blob/main/database/database.db"

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_account_routes,node_scanner_routes,node_sql_routes,node_xss_routes,node_wifi_routes,node_evil_twin_routes,node_dashboard,node_logs,node_reports,node_ui toneBlue
class node_phishing_engine,node_sql_engine,node_xss_engine,node_wifi_engine,node_evil_twin_engine toneAmber
class node_db_access,node_sqlite,node_report_storage toneMint
class node_config toneNeutral
```

## Components

### Flask web boundary

- [Application composition](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/app.py): Flask application · Initializes Flask and registers blueprints. · `app.py`
- [Account and admin routes](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/auth.py): Flask blueprints · Authentication, profile, settings, and privileged administration. · `routes/auth.py`
- [URL scan route](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/scanner.py): Flask blueprint · `routes/scanner.py`
- [SQL scan route](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/sql_routes.py): Flask blueprint · `routes/sql_routes.py`
- [XSS scan route](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/xss_routes.py): Flask blueprint · `routes/xss_routes.py`
- [WiFi simulation route](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/wifi_routes.py): Flask blueprint · `routes/wifi_routes.py`
- [Evil-twin simulation route](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/evil_twin_routes.py): Flask blueprint · `routes/evil_twin_routes.py`
- [Dashboard analytics](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/dashboard.py): Flask blueprint · `routes/dashboard.py`
- [Audit-log route](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/logs.py): Flask blueprint · `routes/logs.py`
- [Report export route](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/routes/reports.py): Flask blueprint · Generates PDF exports with ReportLab. · `routes/reports.py`
- [Server-rendered UI](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/templates/base.html): templates and browser assets · Shared layout, analysis results, and dashboard charts. · `templates/base.html`

### Rule-based analysis

- [Phishing rules](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/phishing_detector.py): rule engine · `scanner/phishing_detector.py`
- [SQL inspection rules](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/sql_analyzer.py): rule engine · `scanner/sql_analyzer.py`
- [XSS inspection rules](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/xss_analyzer.py): rule engine · `scanner/xss_analyzer.py`
- [WiFi simulation rules](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/wifi_detector.py): rule engine · `scanner/wifi_detector.py`
- [Evil-twin rules](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/scanner/evil_twin_detector.py): rule engine · `scanner/evil_twin_detector.py`

### State and reporting

- [Database access and schema](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/database/db.py): SQLite data layer · Initializes schema and performs parameterized access. · `database/db.py`
- [Application database](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/database/database.db): SQLite system of record · Stores users, scans, history, metrics, and audit events. · `database/database.db`
- **Report artifacts**: filesystem storage · Stores generated PDFs and JSON outputs.

### Other components

- [Settings and secrets](https://github.com/harsh-2418/kryptic-vision-hub/blob/main/config.py): configuration · `config.py`

## Connections

- Settings and secrets → Application composition: configures
- Application composition → Account and admin routes: registers
- Application composition → URL scan route: registers
- Application composition → SQL scan route: registers
- Application composition → XSS scan route: registers
- Application composition → WiFi simulation route: registers
- Application composition → Evil-twin simulation route: registers
- Application composition → Dashboard analytics: registers
- Application composition → Audit-log route: registers
- Application composition → Report export route: registers
- Account and admin routes → Database access and schema: accounts and access
- URL scan route → Phishing rules: evaluates URL
- SQL scan route → SQL inspection rules: inspects SQL
- XSS scan route → XSS inspection rules: inspects XSS
- WiFi simulation route → WiFi simulation rules: simulates
- Evil-twin simulation route → Evil-twin rules: simulates
- URL scan route → Database access and schema: persists outcomes
- SQL scan route → Database access and schema: persists outcomes
- XSS scan route → Database access and schema: persists outcomes
- WiFi simulation route → Database access and schema: persists outcomes
- Evil-twin simulation route → Database access and schema: persists outcomes
- Dashboard analytics → Database access and schema: aggregates metrics
- Audit-log route → Database access and schema: reads audit events
- Report export route → Database access and schema: reads report data
- Report export route → Report artifacts: writes exports
- Database access and schema → Application database: reads and writes
- Dashboard analytics → Server-rendered UI: renders dashboard
- URL scan route → Server-rendered UI: renders results
