# priyanshuk17/online-mental-health-support-platform architecture

> Architecture diagram of the GitHub repository priyanshuk17/online-mental-health-support-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priyanshuk17/online-mental-health-support-platform
- Repository: https://github.com/priyanshuk17/online-mental-health-support-platform

## Overview

MindSpace is a full-stack mental-health support platform. Users register or log in, then use mood check-ins and trends, private journaling, an AI companion, and a resource library; crisis-language scanning can surface support resources independently of AI responses. The graph follows the documented client-to-API workflow and sampled server calls. README capabilities retain branches whose implementation was not sampled; edges to those areas are limited to relationships visible in excerpts or documented behavior.

Main entry points: [`client/src/App.jsx`](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/App.jsx) (App routes), [`server/src/index.js`](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/index.js) (Express API), [`client/src/lib/api.js`](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/lib/api.js) (API client), [`server/src/controllers/journalController.js`](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/journalController.js) (Journal operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User experience"]
  node_app["App routes<br/>[App.jsx]"]
  node_authui["Login and register"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_moodui["Mood tracking<br/>[MoodTracker.jsx]"]
  node_journalui["Journal<br/>[Journal.jsx]"]
  node_chatui["AI companion<br/>[AIChat.jsx]"]
  node_resourcesui["Resource library<br/>[Resources.jsx]"]
  node_crisisbutton["Crisis button<br/>[CrisisButton.jsx]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_api["API and identity"]
  node_server["Express API<br/>[index.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_authcontroller["Authentication<br/>[authController.js]"]
  node_protection["JWT protection<br/>[auth.js]"]
end

subgraph group_wellness["Wellness features"]
  node_moodcontroller["Mood operations<br/>[moodController.js]"]
  node_journalcontroller["Journal operations"]
  node_chatcontroller["Chat operations<br/>[chatController.js]"]
  node_resourcecontroller["Resource operations"]
end

subgraph group_safety["Safety and AI"]
  node_crisisevents[("Crisis events<br/>[CrisisEvent.js]")]
  node_crisis["Keyword safety scan<br/>[crisisService.js]"]
  node_aiservice["AI services<br/>[aiService.js]"]
end

subgraph group_data["Persistence"]
  node_mooddata[("Mood records<br/>[MoodEntry.js]")]
  node_journaldata[("Journal records<br/>[JournalEntry.js]")]
  node_chatdata[("Chat sessions<br/>[ChatSession.js]")]
  node_resourcesdata[("Resource records<br/>[Resource.js]")]
  node_users[("User records<br/>[User.js]")]
end

node_user(("User"))
node_openrouter{{"OpenRouter"}}

node_user -->|"uses"| node_app
node_app -->|"routes"| node_authui
node_app -->|"routes"| node_dashboard
node_app -->|"routes"| node_moodui
node_app -->|"routes"| node_journalui
node_app -->|"routes"| node_chatui
node_app -->|"routes"| node_resourcesui
node_authui -.->|"requests"| node_api
node_moodui -.->|"requests"| node_api
node_journalui -.->|"requests"| node_api
node_chatui -.->|"requests"| node_api
node_resourcesui -.->|"requests"| node_api
node_crisisbutton -.->|"offers support"| node_user
node_user -.->|"opens"| node_crisisbutton
node_api -.->|"calls API"| node_server
node_server -->|"mounts"| node_authroutes
node_authroutes -->|"routes to"| node_authcontroller
node_authroutes -->|"protects"| node_protection
node_server -->|"mounts routes"| node_moodcontroller
node_server -->|"mounts routes"| node_journalcontroller
node_server -->|"mounts routes"| node_chatcontroller
node_server -->|"mounts routes"| node_resourcecontroller
node_authcontroller -->|"reads and writes"| node_users
node_protection -->|"loads user"| node_users
node_moodcontroller -->|"reads and writes"| node_mooddata
node_journalcontroller -->|"reads and writes"| node_journaldata
node_chatcontroller -->|"reads and writes"| node_chatdata
node_resourcecontroller -->|"reads resources"| node_resourcesdata
node_moodcontroller -->|"scans notes"| node_crisis
node_journalcontroller -->|"scans entries"| node_crisis
node_chatcontroller -->|"scans messages"| node_crisis
node_moodcontroller -->|"logs flags"| node_crisisevents
node_journalcontroller -->|"logs flags"| node_crisisevents
node_chatcontroller -->|"logs flags"| node_crisisevents
node_chatcontroller -->|"requests reply"| node_aiservice
node_journalcontroller -->|"requests summary"| node_aiservice
node_aiservice -->|"calls model"| node_openrouter

click node_app "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/App.jsx"
click node_authui "https://github.com/priyanshuk17/online-mental-health-support-platform/tree/main/client/src/pages"
click node_dashboard "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/Dashboard.jsx"
click node_moodui "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/MoodTracker.jsx"
click node_journalui "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/Journal.jsx"
click node_chatui "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/AIChat.jsx"
click node_resourcesui "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/Resources.jsx"
click node_crisisbutton "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/components/CrisisButton.jsx"
click node_api "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/lib/api.js"
click node_server "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/index.js"
click node_authroutes "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/routes/authRoutes.js"
click node_authcontroller "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/authController.js"
click node_protection "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/middleware/auth.js"
click node_moodcontroller "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/moodController.js"
click node_journalcontroller "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/journalController.js"
click node_chatcontroller "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/chatController.js"
click node_resourcecontroller "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/resourceController.js"
click node_mooddata "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/MoodEntry.js"
click node_journaldata "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/JournalEntry.js"
click node_chatdata "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/ChatSession.js"
click node_resourcesdata "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/Resource.js"
click node_users "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/User.js"
click node_crisisevents "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/CrisisEvent.js"
click node_crisis "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/services/crisisService.js"
click node_aiservice "https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/services/aiService.js"

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_authui,node_dashboard,node_moodui,node_journalui,node_chatui,node_resourcesui,node_crisisbutton,node_api,node_user toneBlue
class node_server,node_authroutes,node_authcontroller,node_protection toneAmber
class node_moodcontroller,node_journalcontroller,node_chatcontroller,node_resourcecontroller,node_openrouter toneMint
class node_crisisevents,node_crisis,node_aiservice toneRose
class node_mooddata,node_journaldata,node_chatdata,node_resourcesdata,node_users toneIndigo
```

## Components

### User experience

- [App routes](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Login and register](https://github.com/priyanshuk17/online-mental-health-support-platform/tree/main/client/src/pages): `client/src/pages`
- [Dashboard](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/Dashboard.jsx): `client/src/pages/Dashboard.jsx`
- [Mood tracking](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/MoodTracker.jsx): `client/src/pages/MoodTracker.jsx`
- [Journal](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/Journal.jsx): `client/src/pages/Journal.jsx`
- [AI companion](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/AIChat.jsx): `client/src/pages/AIChat.jsx`
- [Resource library](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/pages/Resources.jsx): `client/src/pages/Resources.jsx`
- [Crisis button](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/components/CrisisButton.jsx): `client/src/components/CrisisButton.jsx`
- [API client](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/client/src/lib/api.js): `client/src/lib/api.js`

### API and identity

- [Express API](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/index.js): `server/src/index.js`
- [Auth routes](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/routes/authRoutes.js): `server/src/routes/authRoutes.js`
- [Authentication](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`
- [JWT protection](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/middleware/auth.js): `server/src/middleware/auth.js`

### Wellness features

- [Mood operations](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/moodController.js): `server/src/controllers/moodController.js`
- [Journal operations](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/journalController.js): `server/src/controllers/journalController.js`
- [Chat operations](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/chatController.js): `server/src/controllers/chatController.js`
- [Resource operations](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/controllers/resourceController.js): `server/src/controllers/resourceController.js`

### Safety and AI

- [Crisis events](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/CrisisEvent.js): `server/src/models/CrisisEvent.js`
- [Keyword safety scan](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/services/crisisService.js): `server/src/services/crisisService.js`
- [AI services](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/services/aiService.js): `server/src/services/aiService.js`

### Persistence

- [Mood records](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/MoodEntry.js): `server/src/models/MoodEntry.js`
- [Journal records](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/JournalEntry.js): `server/src/models/JournalEntry.js`
- [Chat sessions](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/ChatSession.js): `server/src/models/ChatSession.js`
- [Resource records](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/Resource.js): `server/src/models/Resource.js`
- [User records](https://github.com/priyanshuk17/online-mental-health-support-platform/blob/main/server/src/models/User.js): `server/src/models/User.js`

### Other components

- **User**
- **OpenRouter**

## Connections

- User → App routes: uses (evidence: `README.md`)
- App routes → Login and register: routes (evidence: `client/src/App.jsx`)
- App routes → Dashboard: routes (evidence: `client/src/App.jsx`)
- App routes → Mood tracking: routes (evidence: `client/src/App.jsx`)
- App routes → Journal: routes (evidence: `client/src/App.jsx`)
- App routes → AI companion: routes (evidence: `client/src/App.jsx`)
- App routes → Resource library: routes (evidence: `client/src/App.jsx`)
- Login and register → API client: requests
- Mood tracking → API client: requests
- Journal → API client: requests
- AI companion → API client: requests
- Resource library → API client: requests
- Crisis button → User: offers support (evidence: `README.md`)
- User → Crisis button: opens (evidence: `README.md`)
- API client → Express API: calls API
- Express API → Auth routes: mounts (evidence: `server/src/index.js`)
- Auth routes → Authentication: routes to (evidence: `server/src/routes/authRoutes.js`)
- Auth routes → JWT protection: protects (evidence: `server/src/routes/authRoutes.js`)
- Express API → Mood operations: mounts routes (evidence: `server/src/index.js`)
- Express API → Journal operations: mounts routes (evidence: `server/src/index.js`)
- Express API → Chat operations: mounts routes (evidence: `server/src/index.js`)
- Express API → Resource operations: mounts routes (evidence: `server/src/index.js`)
- Authentication → User records: reads and writes (evidence: `server/src/controllers/authController.js`)
- JWT protection → User records: loads user (evidence: `server/src/middleware/auth.js`)
- Mood operations → Mood records: reads and writes (evidence: `server/src/controllers/moodController.js`)
- Journal operations → Journal records: reads and writes (evidence: `server/src/controllers/journalController.js`)
- Chat operations → Chat sessions: reads and writes (evidence: `server/src/controllers/chatController.js`)
- Resource operations → Resource records: reads resources (evidence: `server/src/controllers/resourceController.js`)
- Mood operations → Keyword safety scan: scans notes (evidence: `server/src/controllers/moodController.js`)
- Journal operations → Keyword safety scan: scans entries (evidence: `server/src/controllers/journalController.js`)
- Chat operations → Keyword safety scan: scans messages (evidence: `server/src/controllers/chatController.js`)
- Mood operations → Crisis events: logs flags (evidence: `server/src/controllers/moodController.js`)
- Journal operations → Crisis events: logs flags (evidence: `server/src/controllers/journalController.js`)
- Chat operations → Crisis events: logs flags (evidence: `server/src/controllers/chatController.js`)
- Chat operations → AI services: requests reply (evidence: `server/src/controllers/chatController.js`)
- Journal operations → AI services: requests summary (evidence: `server/src/controllers/journalController.js`)
- AI services → OpenRouter: calls model (evidence: `server/src/services/aiService.js`)
