# nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost architecture

> Architecture diagram of the GitHub repository nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost
- Repository: https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost

## Overview

This Flask application supports two user workflows: submit URLs for current-threat detection or future-risk prediction, then view results and dashboard history. The backend extracts URL features, applies XGBoost and detection heuristics, and persists scan data in SQLite. Model training is a separate capability that produces the detection and prediction artifacts. The README also describes dataset uploads and classification reasons; the sampled browser code confirms single and batch URL submission, while backend routing and template wiring are only partly shown, so uncertain links are omitted.

Main entry points: [`backend/app.py`](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py) (Flask API and pages), [`backend/train_models.py`](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/train_models.py) (Model training), [`backend/static/js/detection.js`](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/detection.js) (Detection UI), [`backend/static/js/prediction.js`](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/prediction.js) (Prediction UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_login["Demo login<br/>[auth.js]"]
  node_detection_ui["Detection UI<br/>[detection.js]"]
  node_prediction_ui["Prediction UI<br/>[prediction.js]"]
  node_dashboards["Dashboards<br/>[dashboard.js]"]
  node_browser_history["Browser history<br/>[prediction.js]"]
end

subgraph group_analysis["URL analysis"]
  node_flask["Flask API and pages<br/>[app.py]"]
  node_features["URL features<br/>[app.py]"]
  node_detection["Threat detection<br/>[app.py]"]
  node_prediction["Risk prediction<br/>[app.py]"]
  node_decision["Threat scoring<br/>[app.py]"]
end

subgraph group_persistence["History and stats"]
  node_history[("Scan history")]
end

subgraph group_modeling["Model training"]
  node_models["Trained model artifacts"]
  node_training["Model training<br/>[train_models.py]"]
  node_keyword_data["Keyword dataset"]
  node_url_data["URL training dataset"]
end

node_user(("Security user"))

node_user -->|"signs in"| node_login
node_user -->|"submits URLs"| node_detection_ui
node_user -->|"submits URLs"| node_prediction_ui
node_detection_ui -->|"POST /api/detect"| node_flask
node_prediction_ui -->|"POST /api/predict"| node_flask
node_flask -->|"extracts features"| node_features
node_flask -.->|"dispatches detection"| node_detection
node_flask -.->|"dispatches prediction"| node_prediction
node_detection -->|"scores threats"| node_decision
node_detection -.->|"uses model"| node_models
node_prediction -.->|"uses model"| node_models
node_flask -->|"reads and writes"| node_history
node_dashboards -.->|"loads dashboard data"| node_flask
node_detection_ui -->|"stores results"| node_browser_history
node_prediction_ui -->|"stores results"| node_browser_history
node_training -->|"loads dataset"| node_url_data
node_training -.->|"loads keywords"| node_keyword_data
node_training -->|"saves models"| node_models

click node_login "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/auth.js"
click node_detection_ui "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/detection.js"
click node_prediction_ui "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/prediction.js"
click node_dashboards "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/dashboard.js"
click node_flask "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py"
click node_features "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py"
click node_detection "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py"
click node_prediction "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py"
click node_decision "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py"
click node_models "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/tree/main/backend/models"
click node_training "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/train_models.py"
click node_keyword_data "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/suspicious_keywords_500.csv"
click node_url_data "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/url_dataset_100k.csv"
click node_history "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/security_analytics.db"
click node_browser_history "https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/prediction.js"

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_login,node_detection_ui,node_prediction_ui,node_dashboards,node_browser_history,node_user toneBlue
class node_flask,node_features,node_detection,node_prediction,node_decision toneAmber
class node_history toneMint
class node_models,node_training,node_keyword_data,node_url_data toneRose
```

## Components

### Web interface

- [Demo login](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/auth.js): `backend/static/js/auth.js`
- [Detection UI](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/detection.js): `backend/static/js/detection.js`
- [Prediction UI](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/prediction.js): `backend/static/js/prediction.js`
- [Dashboards](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/dashboard.js): `backend/static/js/dashboard.js`
- [Browser history](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/static/js/prediction.js): `backend/static/js/prediction.js`

### URL analysis

- [Flask API and pages](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py): `backend/app.py`
- [URL features](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py): `backend/app.py`
- [Threat detection](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py): `backend/app.py`
- [Risk prediction](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py): `backend/app.py`
- [Threat scoring](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/app.py): `backend/app.py`

### History and stats

- [Scan history](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/security_analytics.db): `backend/security_analytics.db`

### Model training

- [Trained model artifacts](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/tree/main/backend/models): `backend/models`
- [Model training](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/train_models.py): `backend/train_models.py`
- [Keyword dataset](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/suspicious_keywords_500.csv): `backend/suspicious_keywords_500.csv`
- [URL training dataset](https://github.com/nathesh6/cyber-hacking-breach-detection-predication-using-xg-boost/blob/main/backend/url_dataset_100k.csv): `backend/url_dataset_100k.csv`

### Other components

- **Security user**

## Connections

- Security user → Demo login: signs in (evidence: `backend/static/js/auth.js`)
- Security user → Detection UI: submits URLs (evidence: `backend/static/js/detection.js`)
- Security user → Prediction UI: submits URLs (evidence: `backend/static/js/prediction.js`)
- Detection UI → Flask API and pages: POST /api/detect (evidence: `backend/static/js/detection.js`)
- Prediction UI → Flask API and pages: POST /api/predict (evidence: `backend/static/js/prediction.js`)
- Flask API and pages → URL features: extracts features (evidence: `backend/app.py`)
- Flask API and pages → Threat detection: dispatches detection (evidence: `backend/app.py`)
- Flask API and pages → Risk prediction: dispatches prediction (evidence: `backend/app.py`)
- Threat detection → Threat scoring: scores threats (evidence: `backend/app.py`)
- Threat detection → Trained model artifacts: uses model
- Risk prediction → Trained model artifacts: uses model
- Flask API and pages → Scan history: reads and writes (evidence: `backend/app.py`)
- Dashboards → Flask API and pages: loads dashboard data
- Detection UI → Browser history: stores results (evidence: `backend/static/js/detection.js`)
- Prediction UI → Browser history: stores results (evidence: `backend/static/js/prediction.js`)
- Model training → URL training dataset: loads dataset (evidence: `backend/train_models.py`)
- Model training → Keyword dataset: loads keywords
- Model training → Trained model artifacts: saves models (evidence: `backend/train_models.py`)
