# swethamagesh05/anti-burnout-keyboard architecture

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

- Interactive diagram: https://gitdiagram.com/swethamagesh05/anti-burnout-keyboard
- Repository: https://github.com/swethamagesh05/anti-burnout-keyboard

## Overview

This is a keystroke-based burnout/stress estimation app. In the main workflow, a user types in the React interface; it tracks keystroke timing and live WPM, assembles session features, and posts them to FastAPI, which predicts a stress class using a loaded Random Forest model. The interface displays the result, a percentage visualization, and a recommendation. Separate scripts support synthetic dataset generation, model training, and offline keystroke logging and prediction. The sampled sources show these flows; the dataset and model files are represented as artifacts.

Main entry points: [`frontend/src/App.jsx`](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/frontend/src/App.jsx) (Typing and results), [`backend/models/stress_model.pkl`](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/models/stress_model.pkl) (Stress model), [`backend/app/api/main.py`](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/app/api/main.py) (Prediction API), [`backend/data/dataset.csv`](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/data/dataset.csv) (Training dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Typing interface"]
  node_mount["React entry<br/>[main.jsx]"]
  node_typing["Typing and results<br/>[App.jsx]"]
end

subgraph group_runtime["Live prediction"]
  node_api["Prediction API<br/>[main.py]"]
  node_model["Stress model<br/>[stress_model.pkl]"]
end

subgraph group_modeling["Model preparation"]
  node_generator["Dataset generator"]
  node_dataset["Training dataset<br/>[dataset.csv]"]
  node_trainer["Model trainer<br/>[train_model.py]"]
end

subgraph group_offline["Offline analysis"]
  node_logger["Keystroke logger<br/>[keyboard_logger.py]"]
  node_keystrokes["Keystroke records<br/>[keystrokes.csv]"]
  node_extractor["Feature extractor"]
  node_offlinepredict["Session predictor<br/>[predict_stree.py]"]
  node_datasetpredict["Dataset predictor<br/>[predict.py]"]
end

node_user(("User"))

node_user -->|"types and requests"| node_typing
node_mount -->|"renders"| node_typing
node_typing -->|"posts features"| node_api
node_api -->|"loads and predicts"| node_model
node_api -->|"returns stress class"| node_typing
node_generator -->|"writes"| node_dataset
node_trainer -->|"reads"| node_dataset
node_trainer -->|"saves"| node_model
node_logger -->|"records"| node_keystrokes
node_extractor -->|"reads"| node_keystrokes
node_offlinepredict -->|"reads"| node_keystrokes
node_offlinepredict -->|"loads and predicts"| node_model
node_datasetpredict -->|"reads"| node_dataset
node_datasetpredict -->|"loads and predicts"| node_model

click node_mount "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/frontend/src/main.jsx"
click node_typing "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/frontend/src/App.jsx"
click node_api "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/app/api/main.py"
click node_model "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/models/stress_model.pkl"
click node_generator "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/generate_dataset.py"
click node_dataset "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/data/dataset.csv"
click node_trainer "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/train_model.py"
click node_logger "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/keyboard_logger.py"
click node_keystrokes "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/data/keystrokes.csv"
click node_extractor "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/feature_extractor.py"
click node_offlinepredict "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/predict_stree.py"
click node_datasetpredict "https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/predict.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_mount,node_typing,node_user toneBlue
class node_api,node_model toneAmber
class node_generator,node_dataset,node_trainer toneMint
class node_logger,node_keystrokes,node_extractor,node_offlinepredict,node_datasetpredict toneRose
```

## Components

### Typing interface

- [React entry](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Typing and results](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### Live prediction

- [Prediction API](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/app/api/main.py): `backend/app/api/main.py`
- [Stress model](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/models/stress_model.pkl): `backend/models/stress_model.pkl`

### Model preparation

- [Dataset generator](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/generate_dataset.py): `backend/generate_dataset.py`
- [Training dataset](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/data/dataset.csv): `backend/data/dataset.csv`
- [Model trainer](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/train_model.py): `backend/train_model.py`

### Offline analysis

- [Keystroke logger](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/keyboard_logger.py): `backend/keyboard_logger.py`
- [Keystroke records](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/data/keystrokes.csv): `backend/data/keystrokes.csv`
- [Feature extractor](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/feature_extractor.py): `backend/feature_extractor.py`
- [Session predictor](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/predict_stree.py): `backend/predict_stree.py`
- [Dataset predictor](https://github.com/swethamagesh05/anti-burnout-keyboard/blob/main/backend/predict.py): `backend/predict.py`

### Other components

- **User**

## Connections

- User → Typing and results: types and requests (evidence: `frontend/src/App.jsx`)
- React entry → Typing and results: renders (evidence: `frontend/src/main.jsx`)
- Typing and results → Prediction API: posts features (evidence: `frontend/src/App.jsx`)
- Prediction API → Stress model: loads and predicts (evidence: `backend/app/api/main.py`)
- Prediction API → Typing and results: returns stress class (evidence: `frontend/src/App.jsx`)
- Dataset generator → Training dataset: writes (evidence: `backend/generate_dataset.py`)
- Model trainer → Training dataset: reads (evidence: `backend/train_model.py`)
- Model trainer → Stress model: saves (evidence: `backend/train_model.py`)
- Keystroke logger → Keystroke records: records (evidence: `backend/keyboard_logger.py`)
- Feature extractor → Keystroke records: reads (evidence: `backend/feature_extractor.py`)
- Session predictor → Keystroke records: reads (evidence: `backend/predict_stree.py`)
- Session predictor → Stress model: loads and predicts (evidence: `backend/predict_stree.py`)
- Dataset predictor → Training dataset: reads (evidence: `backend/predict.py`)
- Dataset predictor → Stress model: loads and predicts (evidence: `backend/predict.py`)
