# akinztech/ph9-depression-study architecture

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

- Interactive diagram: https://gitdiagram.com/akinztech/ph9-depression-study
- Repository: https://github.com/akinztech/ph9-depression-study

## Overview

PH9-Depression-Study is a student PHQ-9 screening and research-analytics application. A student completes consent, demographics, and PHQ-9 responses in the web client; the API validates the submission, calculates severity and intervention flags, predicts demographic risk with trained models, and persists the response. Separate analytics endpoints support dashboard statistics, response browsing, and research export. The graph also shows the documented frontend pages and backend startup/import responsibilities. Edges reflect sampled code and SOURCE INDEX references; unsampled page behavior is not inferred.

Main entry points: [`PH9-Depression-Study/frontend/src/App.jsx`](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/App.jsx) (App routes), [`PH9-Depression-Study/backend/app/models/survey_routes.py`](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/models/survey_routes.py) (Survey endpoints), [`PH9-Depression-Study/backend/app/services/data_service.py`](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/services/data_service.py) (Data service), [`PH9-Depression-Study/backend/app/main.py`](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/main.py) (Flask application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app_ui["App routes<br/>[App.jsx]"]
  node_home["Home page<br/>[HomePage.jsx]"]
  node_survey_ui["Survey page<br/>[SurveyPage.jsx]"]
  node_dashboard["Dashboard page<br/>[DashboardPage.jsx]"]
  node_resources["Resources page<br/>[ResourcesPage.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_footer["Footer<br/>[Footer.jsx]"]
  node_result_card["Screening results<br/>[ResultCard.jsx]"]
  node_frontend_api["API client<br/>[api.js]"]
end

subgraph group_api["API and routing"]
  node_flask_app["Flask application<br/>[main.py]"]
  node_survey_routes["Survey endpoints<br/>[survey_routes.py]"]
  node_analytics_routes["Analytics endpoints"]
end

subgraph group_assessment["Assessment and prediction"]
  node_validators["Input validation<br/>[validators.py]"]
  node_scoring["PHQ-9 scoring<br/>[phq9_scorer.py]"]
  node_predictor["Risk prediction<br/>[risk_predictor.py]"]
  node_models["Trained models"]
end

subgraph group_research["Research data"]
  node_data_service["Data service<br/>[data_service.py]"]
  node_database[("Response database<br/>[phq9_database.db]")]
  node_dataset["Research dataset"]
end

node_student(("Student"))

node_student -->|"completes screening"| node_survey_ui
node_app_ui -->|"routes to"| node_home
node_app_ui -->|"routes to"| node_survey_ui
node_app_ui -->|"routes to"| node_dashboard
node_app_ui -->|"routes to"| node_resources
node_app_ui -->|"renders"| node_navbar
node_app_ui -->|"renders"| node_footer
node_survey_ui -->|"submits via"| node_frontend_api
node_survey_ui -->|"renders"| node_result_card
node_dashboard -->|"requests data"| node_frontend_api
node_frontend_api -->|"posts survey"| node_survey_routes
node_frontend_api -->|"requests analytics"| node_analytics_routes
node_flask_app -->|"registers"| node_survey_routes
node_flask_app -->|"registers"| node_analytics_routes
node_flask_app -->|"initializes and imports"| node_data_service
node_flask_app -->|"initializes"| node_predictor
node_survey_routes -->|"validates with"| node_validators
node_survey_routes -->|"scores with"| node_scoring
node_survey_routes -->|"requests predictions"| node_predictor
node_survey_routes -->|"saves response"| node_data_service
node_analytics_routes -->|"queries data"| node_data_service
node_predictor -->|"loads models"| node_models
node_data_service -->|"reads and writes"| node_database
node_data_service -->|"imports CSV"| node_dataset
node_scoring -.->|"supplies scoring fields"| node_database

click node_app_ui "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/App.jsx"
click node_home "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/pages/HomePage.jsx"
click node_survey_ui "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/pages/SurveyPage.jsx"
click node_dashboard "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/pages/DashboardPage.jsx"
click node_resources "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/pages/ResourcesPage.jsx"
click node_navbar "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/components/Navbar.jsx"
click node_footer "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/components/Footer.jsx"
click node_result_card "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/components/ResultCard.jsx"
click node_frontend_api "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/services/api.js"
click node_flask_app "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/main.py"
click node_survey_routes "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/models/survey_routes.py"
click node_analytics_routes "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/models/analytics_routes.py"
click node_validators "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/utils/validators.py"
click node_scoring "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/ml/phq9_scorer.py"
click node_predictor "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/ml/risk_predictor.py"
click node_models "https://github.com/akinztech/ph9-depression-study/tree/main/PH9-Depression-Study/backend/app/ml/saved_models"
click node_data_service "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/services/data_service.py"
click node_database "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/data/phq9_database.db"
click node_dataset "https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/data/phq9_student_dataset.csv"

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_ui,node_home,node_survey_ui,node_dashboard,node_resources,node_navbar,node_footer,node_result_card,node_frontend_api toneBlue
class node_flask_app,node_survey_routes,node_analytics_routes toneAmber
class node_validators,node_scoring,node_predictor,node_models toneMint
class node_data_service,node_database,node_dataset toneRose
class node_student toneIndigo
```

## Components

### Web application

- [App routes](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/App.jsx): `PH9-Depression-Study/frontend/src/App.jsx`
- [Home page](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/pages/HomePage.jsx): `PH9-Depression-Study/frontend/src/pages/HomePage.jsx`
- [Survey page](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/pages/SurveyPage.jsx): `PH9-Depression-Study/frontend/src/pages/SurveyPage.jsx`
- [Dashboard page](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/pages/DashboardPage.jsx): `PH9-Depression-Study/frontend/src/pages/DashboardPage.jsx`
- [Resources page](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/pages/ResourcesPage.jsx): `PH9-Depression-Study/frontend/src/pages/ResourcesPage.jsx`
- [Navigation](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/components/Navbar.jsx): `PH9-Depression-Study/frontend/src/components/Navbar.jsx`
- [Footer](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/components/Footer.jsx): `PH9-Depression-Study/frontend/src/components/Footer.jsx`
- [Screening results](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/components/ResultCard.jsx): `PH9-Depression-Study/frontend/src/components/ResultCard.jsx`
- [API client](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/frontend/src/services/api.js): `PH9-Depression-Study/frontend/src/services/api.js`

### API and routing

- [Flask application](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/main.py): `PH9-Depression-Study/backend/app/main.py`
- [Survey endpoints](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/models/survey_routes.py): `PH9-Depression-Study/backend/app/models/survey_routes.py`
- [Analytics endpoints](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/models/analytics_routes.py): `PH9-Depression-Study/backend/app/models/analytics_routes.py`

### Assessment and prediction

- [Input validation](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/utils/validators.py): `PH9-Depression-Study/backend/app/utils/validators.py`
- [PHQ-9 scoring](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/ml/phq9_scorer.py): `PH9-Depression-Study/backend/app/ml/phq9_scorer.py`
- [Risk prediction](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/ml/risk_predictor.py): `PH9-Depression-Study/backend/app/ml/risk_predictor.py`
- [Trained models](https://github.com/akinztech/ph9-depression-study/tree/main/PH9-Depression-Study/backend/app/ml/saved_models): `PH9-Depression-Study/backend/app/ml/saved_models`

### Research data

- [Data service](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/app/services/data_service.py): `PH9-Depression-Study/backend/app/services/data_service.py`
- [Response database](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/data/phq9_database.db): `PH9-Depression-Study/backend/data/phq9_database.db`
- [Research dataset](https://github.com/akinztech/ph9-depression-study/blob/main/PH9-Depression-Study/backend/data/phq9_student_dataset.csv): `PH9-Depression-Study/backend/data/phq9_student_dataset.csv`

### Other components

- **Student**

## Connections

- Student → Survey page: completes screening (evidence: `PH9-Depression-Study/frontend/src/pages/SurveyPage.jsx`)
- App routes → Home page: routes to (evidence: `PH9-Depression-Study/frontend/src/App.jsx`)
- App routes → Survey page: routes to (evidence: `PH9-Depression-Study/frontend/src/App.jsx`)
- App routes → Dashboard page: routes to (evidence: `PH9-Depression-Study/frontend/src/App.jsx`)
- App routes → Resources page: routes to (evidence: `PH9-Depression-Study/frontend/src/App.jsx`)
- App routes → Navigation: renders (evidence: `PH9-Depression-Study/frontend/src/App.jsx`)
- App routes → Footer: renders (evidence: `PH9-Depression-Study/frontend/src/App.jsx`)
- Survey page → API client: submits via (evidence: `PH9-Depression-Study/frontend/src/pages/SurveyPage.jsx`)
- Survey page → Screening results: renders (evidence: `PH9-Depression-Study/frontend/src/pages/SurveyPage.jsx`)
- Dashboard page → API client: requests data (evidence: `PH9-Depression-Study/frontend/src/pages/DashboardPage.jsx`)
- API client → Survey endpoints: posts survey (evidence: `PH9-Depression-Study/frontend/src/services/api.js`)
- API client → Analytics endpoints: requests analytics (evidence: `PH9-Depression-Study/frontend/src/services/api.js`)
- Flask application → Survey endpoints: registers (evidence: `PH9-Depression-Study/backend/app/main.py`)
- Flask application → Analytics endpoints: registers (evidence: `PH9-Depression-Study/backend/app/main.py`)
- Flask application → Data service: initializes and imports (evidence: `PH9-Depression-Study/backend/app/main.py`)
- Flask application → Risk prediction: initializes (evidence: `PH9-Depression-Study/backend/app/main.py`)
- Survey endpoints → Input validation: validates with (evidence: `PH9-Depression-Study/backend/app/models/survey_routes.py`)
- Survey endpoints → PHQ-9 scoring: scores with (evidence: `PH9-Depression-Study/backend/app/models/survey_routes.py`)
- Survey endpoints → Risk prediction: requests predictions (evidence: `PH9-Depression-Study/backend/app/models/survey_routes.py`)
- Survey endpoints → Data service: saves response (evidence: `PH9-Depression-Study/backend/app/models/survey_routes.py`)
- Analytics endpoints → Data service: queries data (evidence: `PH9-Depression-Study/backend/app/models/analytics_routes.py`)
- Risk prediction → Trained models: loads models (evidence: `PH9-Depression-Study/backend/app/ml/risk_predictor.py`)
- Data service → Response database: reads and writes (evidence: `PH9-Depression-Study/backend/app/services/data_service.py`)
- Data service → Research dataset: imports CSV (evidence: `PH9-Depression-Study/backend/app/services/data_service.py`)
- PHQ-9 scoring → Response database: supplies scoring fields
