# niraj-kumbhar-18/psychhealth architecture

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

- Interactive diagram: https://gitdiagram.com/niraj-kumbhar-18/psychhealth
- Repository: https://github.com/niraj-kumbhar-18/psychhealth

## Overview

PsychHealth is a student wellness web app for stress assessment, habit tracking, and guided behavior experiments. A student enters through the browser UI, completes profile and assessment screens, and receives a scored PSS result, contributing factors, and tailored recommendations. The app also supports viewing progress, logging habits, running experiments, and exploring hypothetical changes with a what-if simulator. The frontend maintains client state and can sync with a lightweight HTTP server backed by SQLite. Relationships are limited to those shown in excerpts; other capabilities are represented without inferred wiring.

Main entry points: [`frontend/js/state.js`](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/state.js) (Student state), [`frontend/js/api.js`](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/api.js) (API service), [`frontend/js/app.js`](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/app.js) (App controller), [`frontend/js/screens.js`](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/screens.js) (Screen rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Student experience"]
  node_app["App controller<br/>[app.js]"]
  node_screens["Screen rendering<br/>[screens.js]"]
  node_state["Student state<br/>[state.js]"]
  node_api["API service<br/>[api.js]"]
end

subgraph group_wellness["Assessment and guidance"]
  node_questionnaire["Questionnaire definitions<br/>[data.js]"]
  node_pss["PSS scoring<br/>[pss.js]"]
  node_recommendations["Wellness recommendations<br/>[recommendations.js]"]
end

subgraph group_engagement["Progress and behavior"]
  node_dashboard["Progress visualizations<br/>[charts.js]"]
  node_simulator["What-if simulator<br/>[simulator.js]"]
  node_habittracking["Habit tracking<br/>[tracking.js]"]
end

subgraph group_persistence["Backend and persistence"]
  node_server["HTTP API server<br/>[server.py]"]
  node_database[("Student records<br/>[database.py]")]
  node_sqlite[("SQLite database<br/>[psychhealth.db]")]
end

node_student(("Student"))

node_student -->|"uses"| node_app
node_app -.->|"renders"| node_screens
node_app -->|"updates"| node_state
node_screens -.->|"reads"| node_state
node_screens -->|"uses"| node_questionnaire
node_api -->|"updates"| node_state
node_api -->|"scores"| node_pss
node_api -->|"generates"| node_recommendations
node_state -->|"syncs"| node_server
node_server -->|"calls"| node_database
node_server -.->|"serves data"| node_student
node_database -.->|"reads and writes"| node_sqlite
node_dashboard -.->|"reads progress"| node_state
node_simulator -->|"gets stress level"| node_pss
node_habittracking -.->|"logs habits"| node_state

click node_app "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/app.js"
click node_screens "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/screens.js"
click node_state "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/state.js"
click node_api "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/api.js"
click node_questionnaire "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/data.js"
click node_pss "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/pss.js"
click node_recommendations "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/recommendations.js"
click node_dashboard "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/charts.js"
click node_simulator "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/simulator.js"
click node_habittracking "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/tracking.js"
click node_server "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/backend/server.py"
click node_database "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/backend/database.py"
click node_sqlite "https://github.com/niraj-kumbhar-18/psychhealth/blob/master/backend/psychhealth.db"

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_app,node_screens,node_state,node_api toneBlue
class node_questionnaire,node_pss,node_recommendations toneAmber
class node_dashboard,node_simulator,node_habittracking toneMint
class node_server,node_database,node_sqlite toneRose
class node_student toneIndigo
```

## Components

### Student experience

- [App controller](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/app.js): `frontend/js/app.js`
- [Screen rendering](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/screens.js): `frontend/js/screens.js`
- [Student state](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/state.js): `frontend/js/state.js`
- [API service](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/api.js): `frontend/js/api.js`

### Assessment and guidance

- [Questionnaire definitions](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/data.js): `frontend/js/data.js`
- [PSS scoring](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/pss.js): `frontend/js/pss.js`
- [Wellness recommendations](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/recommendations.js): `frontend/js/recommendations.js`

### Progress and behavior

- [Progress visualizations](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/charts.js): `frontend/js/charts.js`
- [What-if simulator](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/simulator.js): `frontend/js/simulator.js`
- [Habit tracking](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/frontend/js/tracking.js): `frontend/js/tracking.js`

### Backend and persistence

- [HTTP API server](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/backend/server.py): `backend/server.py`
- [Student records](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/backend/database.py): `backend/database.py`
- [SQLite database](https://github.com/niraj-kumbhar-18/psychhealth/blob/master/backend/psychhealth.db): `backend/psychhealth.db`

### Other components

- **Student**

## Connections

- Student → App controller: uses
- App controller → Screen rendering: renders
- App controller → Student state: updates (evidence: `frontend/js/app.js`)
- Screen rendering → Student state: reads
- Screen rendering → Questionnaire definitions: uses (evidence: `frontend/js/screens.js`)
- API service → Student state: updates (evidence: `frontend/js/api.js`)
- API service → PSS scoring: scores (evidence: `frontend/js/api.js`)
- API service → Wellness recommendations: generates (evidence: `frontend/js/api.js`)
- Student state → HTTP API server: syncs (evidence: `frontend/js/state.js`)
- HTTP API server → Student records: calls (evidence: `backend/server.py`)
- HTTP API server → Student: serves data
- Student records → SQLite database: reads and writes
- Progress visualizations → Student state: reads progress
- What-if simulator → PSS scoring: gets stress level (evidence: `frontend/js/simulator.js`)
- Habit tracking → Student state: logs habits
