# pujitha1307/adaptive-behavioral-authentication architecture

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

- Interactive diagram: https://gitdiagram.com/pujitha1307/adaptive-behavioral-authentication
- Repository: https://github.com/pujitha1307/adaptive-behavioral-authentication

## Overview

This is a Flask web app for continuous mouse-behavior authentication. The main workflow captures mouse telemetry in the browser, submits evaluation windows to Flask, extracts motion features, scores anomalies, and applies session-based risk thresholds to keep access normal or require OTP or credential re-authentication. Model training and threshold derivation form a separate supporting workflow. The graph also preserves the documented dashboard visualization and audit logging. Some route and template wiring is supported by README or excerpts; unsampled internals are not inferred.

Main entry points: [`app.py`](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py) (Flask routes and session), [`authenticate.py`](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/authenticate.py) (Anomaly scoring), [`static/mouse.js`](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/static/mouse.js) (Mouse tracking and visualizer), [`train_model.py`](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/train_model.py) (Baseline model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_login_ui["Login screen<br/>[login.html]"]
  node_dashboard_ui["Monitoring dashboard<br/>[dashboard.html]"]
  node_telemetry_ui["Mouse tracking and visualizer<br/>[mouse.js]"]
end

subgraph group_session["Session security"]
  node_flask_app["Flask routes and session<br/>[app.py]"]
  node_risk_policy["Risk thresholds and lock states<br/>[app.py]"]
  node_otp["OTP verification<br/>[app.py]"]
  node_reauth["Credential re-auth and audit<br/>[app.py]"]
end

subgraph group_detection["Behavior detection"]
  node_live_telemetry["Session telemetry<br/>[app.py]"]
  node_risk_scoring["Anomaly scoring<br/>[authenticate.py]"]
  node_features["Motion feature extraction"]
end

subgraph group_training["Model training"]
  node_training["Baseline model training<br/>[train_model.py]"]
  node_model_assets[("Model and scaler")]
  node_threshold_assets["Derived thresholds and metrics<br/>[thresholds.json]"]
end

node_user(("User"))

node_user -->|"opens"| node_login_ui
node_login_ui -->|"submits login"| node_flask_app
node_flask_app -->|"renders"| node_dashboard_ui
node_user -->|"moves pointer"| node_telemetry_ui
node_telemetry_ui -->|"posts windows"| node_flask_app
node_flask_app -->|"records points"| node_live_telemetry
node_flask_app -->|"requests score"| node_risk_scoring
node_risk_scoring -->|"extracts features"| node_features
node_features -->|"returns features"| node_risk_scoring
node_risk_scoring -->|"loads and scores"| node_model_assets
node_risk_scoring -->|"loads parameters"| node_threshold_assets
node_flask_app -->|"applies thresholds"| node_risk_policy
node_risk_policy -->|"requires OTP"| node_otp
node_risk_policy -->|"requires re-auth"| node_reauth
node_telemetry_ui -->|"submits OTP"| node_otp
node_telemetry_ui -->|"submits credentials"| node_reauth
node_reauth -->|"records reason"| node_flask_app
node_training -->|"extracts raw features"| node_features
node_training -->|"saves artifacts"| node_model_assets
node_training -->|"writes thresholds"| node_threshold_assets

click node_login_ui "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/templates/login.html"
click node_dashboard_ui "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/templates/dashboard.html"
click node_telemetry_ui "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/static/mouse.js"
click node_flask_app "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py"
click node_risk_policy "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py"
click node_otp "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py"
click node_reauth "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py"
click node_live_telemetry "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py"
click node_risk_scoring "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/authenticate.py"
click node_features "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/extract_features.py"
click node_training "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/train_model.py"
click node_model_assets "https://github.com/pujitha1307/adaptive-behavioral-authentication/tree/main/model"
click node_threshold_assets "https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/model/thresholds.json"

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_ui,node_dashboard_ui,node_telemetry_ui,node_user toneBlue
class node_flask_app,node_risk_policy,node_otp,node_reauth toneAmber
class node_live_telemetry,node_risk_scoring,node_features toneMint
class node_training,node_model_assets,node_threshold_assets toneRose
```

## Components

### Browser experience

- [Login screen](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/templates/login.html): `templates/login.html`
- [Monitoring dashboard](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/templates/dashboard.html): `templates/dashboard.html`
- [Mouse tracking and visualizer](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/static/mouse.js): `static/mouse.js`

### Session security

- [Flask routes and session](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py): `app.py`
- [Risk thresholds and lock states](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py): `app.py`
- [OTP verification](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py): `app.py`
- [Credential re-auth and audit](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py): `app.py`

### Behavior detection

- [Session telemetry](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/app.py): `app.py`
- [Anomaly scoring](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/authenticate.py): `authenticate.py`
- [Motion feature extraction](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/extract_features.py): `extract_features.py`

### Model training

- [Baseline model training](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/train_model.py): `train_model.py`
- [Model and scaler](https://github.com/pujitha1307/adaptive-behavioral-authentication/tree/main/model): `model`
- [Derived thresholds and metrics](https://github.com/pujitha1307/adaptive-behavioral-authentication/blob/main/model/thresholds.json): `model/thresholds.json`

### Other components

- **User**

## Connections

- User → Login screen: opens (evidence: `README.md`)
- Login screen → Flask routes and session: submits login (evidence: `app.py`)
- Flask routes and session → Monitoring dashboard: renders (evidence: `app.py`)
- User → Mouse tracking and visualizer: moves pointer (evidence: `static/mouse.js`)
- Mouse tracking and visualizer → Flask routes and session: posts windows (evidence: `static/mouse.js`)
- Flask routes and session → Session telemetry: records points (evidence: `README.md`)
- Flask routes and session → Anomaly scoring: requests score (evidence: `app.py`)
- Anomaly scoring → Motion feature extraction: extracts features (evidence: `authenticate.py`)
- Motion feature extraction → Anomaly scoring: returns features (evidence: `authenticate.py`)
- Anomaly scoring → Model and scaler: loads and scores (evidence: `authenticate.py`)
- Anomaly scoring → Derived thresholds and metrics: loads parameters (evidence: `authenticate.py`)
- Flask routes and session → Risk thresholds and lock states: applies thresholds (evidence: `app.py`)
- Risk thresholds and lock states → OTP verification: requires OTP (evidence: `app.py`)
- Risk thresholds and lock states → Credential re-auth and audit: requires re-auth (evidence: `README.md`)
- Mouse tracking and visualizer → OTP verification: submits OTP (evidence: `static/mouse.js`)
- Mouse tracking and visualizer → Credential re-auth and audit: submits credentials (evidence: `static/mouse.js`)
- Credential re-auth and audit → Flask routes and session: records reason (evidence: `app.py`)
- Baseline model training → Motion feature extraction: extracts raw features (evidence: `train_model.py`)
- Baseline model training → Model and scaler: saves artifacts (evidence: `train_model.py`)
- Baseline model training → Derived thresholds and metrics: writes thresholds (evidence: `train_model.py`)
