# hoanglong-88/predictive_modeling_human_stress architecture

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

- Interactive diagram: https://gitdiagram.com/hoanglong-88/predictive_modeling_human_stress
- Repository: https://github.com/hoanglong-88/predictive_modeling_human_stress

## Overview

Still is a local Flask demo for classifying submitted text as showing stress-related signals, with an optional probability estimate. Its main workflow is browser form submission → input validation → inference using the active serialized model → rendered result. A separate reproducibility workflow reads the documented Dreaddit archive, performs grouped cross-validation and model selection, evaluates the selected model, and writes model and metrics artifacts. The training workflow is grounded in train_model.py; the archive itself is absent from the tree, so its node has no repository path.

Main entry points: [`app.py`](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/app.py) (Request handler), [`train_model.py`](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/train_model.py) (Test evaluation), [`templates/index.html`](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/templates/index.html) (Text form), [`model/stress_model.joblib`](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/model/stress_model.joblib) (Active model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web classification"]
  node_form["Text form<br/>[index.html]"]
  node_handler["Request handler<br/>[app.py]"]
  node_validation["Input validation<br/>[app.py]"]
  node_inference["Text inference<br/>[app.py]"]
  node_result["Rendered result<br/>[index.html]"]
end

subgraph group_training["Model training"]
  node_archive["Dreaddit archive"]
  node_split["Split loading<br/>[train_model.py]"]
  node_grouping["Leakage grouping<br/>[train_model.py]"]
  node_search["Model search<br/>[train_model.py]"]
  node_evaluation["Test evaluation<br/>[train_model.py]"]
end

subgraph group_artifacts["Model artifacts"]
  node_active["Active model"]
  node_baseline["Original model"]
  node_metrics["Audit metrics<br/>[metrics.json]"]
end

node_user(("Text submitter"))

node_user -->|"submits text"| node_form
node_form -->|"posts form"| node_handler
node_handler -->|"validates input"| node_validation
node_handler -->|"requests prediction"| node_inference
node_inference -->|"loads model"| node_active
node_inference -->|"returns prediction"| node_handler
node_handler -->|"renders response"| node_result
node_archive -->|"provides splits"| node_split
node_split -->|"supplies training rows"| node_grouping
node_grouping -->|"supplies fold groups"| node_search
node_split -->|"supplies train data"| node_search
node_search -->|"provides selected model"| node_evaluation
node_evaluation -->|"saves selected model"| node_active
node_evaluation -->|"writes report"| node_metrics
node_baseline -->|"baseline comparison"| node_evaluation

click node_form "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/templates/index.html"
click node_handler "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/app.py"
click node_validation "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/app.py"
click node_inference "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/app.py"
click node_result "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/templates/index.html"
click node_split "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/train_model.py"
click node_grouping "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/train_model.py"
click node_search "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/train_model.py"
click node_evaluation "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/train_model.py"
click node_active "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/model/stress_model.joblib"
click node_baseline "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/model/stress_model.original.joblib"
click node_metrics "https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/model/metrics.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_form,node_handler,node_validation,node_inference,node_result toneBlue
class node_archive,node_split,node_grouping,node_search,node_evaluation toneAmber
class node_active,node_baseline,node_metrics toneMint
class node_user toneIndigo
```

## Components

### Web classification

- [Text form](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/templates/index.html): `templates/index.html`
- [Request handler](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/app.py): `app.py`
- [Input validation](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/app.py): `app.py`
- [Text inference](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/app.py): `app.py`
- [Rendered result](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/templates/index.html): `templates/index.html`

### Model training

- **Dreaddit archive**
- [Split loading](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/train_model.py): `train_model.py`
- [Leakage grouping](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/train_model.py): `train_model.py`
- [Model search](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/train_model.py): `train_model.py`
- [Test evaluation](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/train_model.py): `train_model.py`

### Model artifacts

- [Active model](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/model/stress_model.joblib): `model/stress_model.joblib`
- [Original model](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/model/stress_model.original.joblib): `model/stress_model.original.joblib`
- [Audit metrics](https://github.com/hoanglong-88/predictive_modeling_human_stress/blob/main/model/metrics.json): `model/metrics.json`

### Other components

- **Text submitter**

## Connections

- Text submitter → Text form: submits text (evidence: `README.md`)
- Text form → Request handler: posts form (evidence: `app.py`)
- Request handler → Input validation: validates input (evidence: `app.py`)
- Request handler → Text inference: requests prediction (evidence: `app.py`)
- Text inference → Active model: loads model (evidence: `app.py`)
- Text inference → Request handler: returns prediction (evidence: `app.py`)
- Request handler → Rendered result: renders response (evidence: `app.py`)
- Dreaddit archive → Split loading: provides splits (evidence: `train_model.py`)
- Split loading → Leakage grouping: supplies training rows (evidence: `train_model.py`)
- Leakage grouping → Model search: supplies fold groups (evidence: `train_model.py`)
- Split loading → Model search: supplies train data (evidence: `train_model.py`)
- Model search → Test evaluation: provides selected model (evidence: `train_model.py`)
- Test evaluation → Active model: saves selected model (evidence: `train_model.py`)
- Test evaluation → Audit metrics: writes report (evidence: `train_model.py`)
- Original model → Test evaluation: baseline comparison (evidence: `train_model.py`)
