# koradajnaneswara-tech/stress-detector architecture

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

- Interactive diagram: https://gitdiagram.com/koradajnaneswara-tech/stress-detector
- Repository: https://github.com/koradajnaneswara-tech/stress-detector

## Overview

MindGuard estimates stress from video, audio, and keyboard/mouse signals, falling back through three modality tiers. Its main workflow is sensor feature extraction, tiered score fusion, local explanation/intervention generation, and presentation with session history. It has two front ends: the documented browser dashboard served by FastAPI and an alternative Streamlit app. SQLite persistence and an accuracy benchmark are additional capabilities. Some storage and dashboard wiring is unsampled, so those relationships are shown only where the excerpts, README, or source index support them.

Main entry points: [`server.py`](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/server.py) (FastAPI service), [`fusion_module.py`](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/fusion_module.py) (Tiered stress fusion), [`app.py`](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/app.py) (Streamlit interface), [`llm_module.py`](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/llm_module.py) (Local explanations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensing["Signal extraction"]
  node_video["Video features<br/>[video_module.py]"]
  node_audio["Audio features<br/>[audio_module.py]"]
  node_behavior["Behavioral features"]
  node_browser_inputs["Browser signal bridge<br/>[server.py]"]
end

subgraph group_analysis["Scoring and insights"]
  node_fusion["Tiered stress fusion<br/>[fusion_module.py]"]
  node_llm["Local explanations<br/>[llm_module.py]"]
end

subgraph group_interfaces["Interfaces and history"]
  node_api["FastAPI service<br/>[server.py]"]
  node_dashboard["Browser dashboard<br/>[dashboard.html]"]
  node_streamlit["Streamlit interface<br/>[app.py]"]
  node_storage[("Session history<br/>[storage_module.py]")]
end

subgraph group_evaluation["Evaluation"]
  node_benchmark["Accuracy benchmark"]
end

node_user(("User"))
node_ollama["Ollama phi3:mini"]

node_user -->|"uses"| node_streamlit
node_user -->|"uses"| node_dashboard
node_video -->|"provides features"| node_fusion
node_audio -->|"provides features"| node_fusion
node_behavior -->|"provides features"| node_fusion
node_fusion -->|"returns state"| node_streamlit
node_streamlit -->|"reads history"| node_storage
node_streamlit -->|"gets insights"| node_llm
node_user -->|"syncs signals"| node_api
node_api -->|"updates features"| node_browser_inputs
node_browser_inputs -.->|"provides features"| node_fusion
node_behavior -->|"provides features"| node_api
node_api -->|"requests state"| node_fusion
node_api -->|"records history"| node_storage
node_api -->|"requests insight"| node_llm
node_llm -->|"calls locally"| node_ollama
node_api -->|"runs benchmark"| node_benchmark
node_dashboard -.->|"communicates with"| node_api

click node_video "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/video_module.py"
click node_audio "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/audio_module.py"
click node_behavior "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/behavioral_module.py"
click node_browser_inputs "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/server.py"
click node_fusion "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/fusion_module.py"
click node_llm "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/llm_module.py"
click node_api "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/server.py"
click node_dashboard "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/dashboard.html"
click node_streamlit "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/app.py"
click node_storage "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/storage_module.py"
click node_benchmark "https://github.com/koradajnaneswara-tech/stress-detector/blob/main/evaluate_accuracy.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_video,node_audio,node_behavior,node_browser_inputs,node_user toneBlue
class node_fusion,node_llm toneAmber
class node_api,node_dashboard,node_streamlit,node_storage toneMint
class node_benchmark toneRose
class node_ollama toneIndigo
```

## Components

### Signal extraction

- [Video features](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/video_module.py): `video_module.py`
- [Audio features](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/audio_module.py): `audio_module.py`
- [Behavioral features](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/behavioral_module.py): `behavioral_module.py`
- [Browser signal bridge](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/server.py): `server.py`

### Scoring and insights

- [Tiered stress fusion](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/fusion_module.py): `fusion_module.py`
- [Local explanations](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/llm_module.py): `llm_module.py`

### Interfaces and history

- [FastAPI service](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/server.py): `server.py`
- [Browser dashboard](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/dashboard.html): `dashboard.html`
- [Streamlit interface](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/app.py): `app.py`
- [Session history](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/storage_module.py): `storage_module.py`

### Evaluation

- [Accuracy benchmark](https://github.com/koradajnaneswara-tech/stress-detector/blob/main/evaluate_accuracy.py): `evaluate_accuracy.py`

### Other components

- **User**
- **Ollama phi3:mini**

## Connections

- User → Streamlit interface: uses (evidence: `README.md`)
- User → Browser dashboard: uses (evidence: `README.md`)
- Video features → Tiered stress fusion: provides features (evidence: `app.py`)
- Audio features → Tiered stress fusion: provides features (evidence: `app.py`)
- Behavioral features → Tiered stress fusion: provides features (evidence: `app.py`)
- Tiered stress fusion → Streamlit interface: returns state (evidence: `app.py`)
- Streamlit interface → Session history: reads history (evidence: `app.py`)
- Streamlit interface → Local explanations: gets insights (evidence: `app.py`)
- User → FastAPI service: syncs signals (evidence: `server.py`)
- FastAPI service → Browser signal bridge: updates features (evidence: `server.py`)
- Browser signal bridge → Tiered stress fusion: provides features (evidence: `server.py`)
- Behavioral features → FastAPI service: provides features (evidence: `server.py`)
- FastAPI service → Tiered stress fusion: requests state (evidence: `server.py`)
- FastAPI service → Session history: records history (evidence: `server.py`)
- FastAPI service → Local explanations: requests insight (evidence: `server.py`)
- Local explanations → Ollama phi3:mini: calls locally (evidence: `llm_module.py`)
- FastAPI service → Accuracy benchmark: runs benchmark (evidence: `server.py`)
- Browser dashboard → FastAPI service: communicates with
