# vani0goel0/muscle-fatigue architecture

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

- Interactive diagram: https://gitdiagram.com/vani0goel0/muscle-fatigue
- Repository: https://github.com/vani0goel0/muscle-fatigue

## Overview

This is a prototype for classifying muscle fatigue as low, moderate, or high from EMG, force, motion, and resistance features. The principal workflow trains and evaluates a Random Forest using a synthetic dataset, saves the model, then lets a user enter feature values in a Streamlit interface and view a prediction, confidence, and class probabilities. The README describes sensor feature engineering, but no sensor-processing implementation is present in the sampled source; the app takes already-derived features as input.

Main entry points: [`train_model.py`](https://github.com/vani0goel0/muscle-fatigue/blob/main/train_model.py) (Train and evaluate), [`app.py`](https://github.com/vani0goel0/muscle-fatigue/blob/main/app.py) (Streamlit interface), [`models/muscle_fatigue_model.joblib`](https://github.com/vani0goel0/muscle-fatigue/blob/main/models/muscle_fatigue_model.joblib) (Saved model), [`predict_sample.py`](https://github.com/vani0goel0/muscle-fatigue/blob/main/predict_sample.py) (Sample prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training and evaluation"]
  node_training_pipeline["Train and evaluate<br/>[train_model.py]"]
  node_classifier["Random Forest<br/>[train_model.py]"]
  node_evaluation["Metrics and matrix<br/>[train_model.py]"]
end

subgraph group_prediction["Prediction experience"]
  node_streamlit_app["Streamlit interface<br/>[app.py]"]
  node_feature_entry["Feature entry<br/>[app.py]"]
  node_inference["Fatigue inference<br/>[app.py]"]
  node_result_view["Prediction results<br/>[app.py]"]
  node_sample_predictor["Sample prediction<br/>[predict_sample.py]"]
end

subgraph group_assets["Project assets"]
  node_dataset[("Synthetic dataset")]
  node_model_artifact[("Saved model")]
  node_confusion_output["Confusion matrix"]
end

node_user(("User"))

node_user -->|"opens"| node_streamlit_app
node_streamlit_app -->|"loads ranges"| node_dataset
node_streamlit_app -->|"loads model"| node_model_artifact
node_streamlit_app -->|"renders controls"| node_feature_entry
node_feature_entry -->|"submits values"| node_inference
node_inference -->|"displays prediction"| node_result_view
node_user -->|"runs example"| node_sample_predictor
node_sample_predictor -->|"loads model"| node_model_artifact
node_training_pipeline -->|"reads data"| node_dataset
node_training_pipeline -->|"fits model"| node_classifier
node_training_pipeline -->|"evaluates model"| node_evaluation
node_training_pipeline -->|"saves model"| node_model_artifact
node_training_pipeline -->|"writes matrix"| node_confusion_output

click node_training_pipeline "https://github.com/vani0goel0/muscle-fatigue/blob/main/train_model.py"
click node_classifier "https://github.com/vani0goel0/muscle-fatigue/blob/main/train_model.py"
click node_evaluation "https://github.com/vani0goel0/muscle-fatigue/blob/main/train_model.py"
click node_streamlit_app "https://github.com/vani0goel0/muscle-fatigue/blob/main/app.py"
click node_feature_entry "https://github.com/vani0goel0/muscle-fatigue/blob/main/app.py"
click node_inference "https://github.com/vani0goel0/muscle-fatigue/blob/main/app.py"
click node_result_view "https://github.com/vani0goel0/muscle-fatigue/blob/main/app.py"
click node_sample_predictor "https://github.com/vani0goel0/muscle-fatigue/blob/main/predict_sample.py"
click node_dataset "https://github.com/vani0goel0/muscle-fatigue/blob/main/data/synthetic_muscle_fatigue_dataset.xlsx"
click node_model_artifact "https://github.com/vani0goel0/muscle-fatigue/blob/main/models/muscle_fatigue_model.joblib"
click node_confusion_output "https://github.com/vani0goel0/muscle-fatigue/tree/main/results"

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_training_pipeline,node_classifier,node_evaluation,node_user toneBlue
class node_streamlit_app,node_feature_entry,node_inference,node_result_view,node_sample_predictor toneAmber
class node_dataset,node_model_artifact,node_confusion_output toneMint
```

## Components

### Training and evaluation

- [Train and evaluate](https://github.com/vani0goel0/muscle-fatigue/blob/main/train_model.py): `train_model.py`
- [Random Forest](https://github.com/vani0goel0/muscle-fatigue/blob/main/train_model.py): `train_model.py`
- [Metrics and matrix](https://github.com/vani0goel0/muscle-fatigue/blob/main/train_model.py): `train_model.py`

### Prediction experience

- [Streamlit interface](https://github.com/vani0goel0/muscle-fatigue/blob/main/app.py): `app.py`
- [Feature entry](https://github.com/vani0goel0/muscle-fatigue/blob/main/app.py): `app.py`
- [Fatigue inference](https://github.com/vani0goel0/muscle-fatigue/blob/main/app.py): `app.py`
- [Prediction results](https://github.com/vani0goel0/muscle-fatigue/blob/main/app.py): `app.py`
- [Sample prediction](https://github.com/vani0goel0/muscle-fatigue/blob/main/predict_sample.py): `predict_sample.py`

### Project assets

- [Synthetic dataset](https://github.com/vani0goel0/muscle-fatigue/blob/main/data/synthetic_muscle_fatigue_dataset.xlsx): `data/synthetic_muscle_fatigue_dataset.xlsx`
- [Saved model](https://github.com/vani0goel0/muscle-fatigue/blob/main/models/muscle_fatigue_model.joblib): `models/muscle_fatigue_model.joblib`
- [Confusion matrix](https://github.com/vani0goel0/muscle-fatigue/tree/main/results): `results`

### Other components

- **User**

## Connections

- User → Streamlit interface: opens (evidence: `README.md`)
- Streamlit interface → Synthetic dataset: loads ranges (evidence: `app.py`)
- Streamlit interface → Saved model: loads model (evidence: `app.py`)
- Streamlit interface → Feature entry: renders controls (evidence: `app.py`)
- Feature entry → Fatigue inference: submits values (evidence: `app.py`)
- Fatigue inference → Prediction results: displays prediction (evidence: `app.py`)
- User → Sample prediction: runs example (evidence: `README.md`)
- Sample prediction → Saved model: loads model (evidence: `predict_sample.py`)
- Train and evaluate → Synthetic dataset: reads data (evidence: `train_model.py`)
- Train and evaluate → Random Forest: fits model (evidence: `train_model.py`)
- Train and evaluate → Metrics and matrix: evaluates model (evidence: `train_model.py`)
- Train and evaluate → Saved model: saves model (evidence: `train_model.py`)
- Train and evaluate → Confusion matrix: writes matrix (evidence: `train_model.py`)
