# sarathi377/mindmate architecture

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

- Interactive diagram: https://gitdiagram.com/sarathi377/mindmate
- Repository: https://github.com/sarathi377/mindmate

## Overview

MINDMATE is a mental-health support web app: users access browser features, authenticate, chat for AI-generated support, and can track mood or submit feedback. The main backend is an Express/Mongoose application; a separate SQLite server provides an alternative API. Chat history and user state are persisted in MongoDB, while sentiment analysis is delegated to a Python process. The README documents additional journaling, relaxation, reporting, and crisis-support capabilities, but their implementation links are not established by the sampled source.

Main entry points: [`server.js`](https://github.com/sarathi377/mindmate/blob/main/server.js) (Express application), [`src/routes/chat.js`](https://github.com/sarathi377/mindmate/blob/main/src/routes/chat.js) (Chat and mood API), [`public/js/app.js`](https://github.com/sarathi377/mindmate/blob/main/public/js/app.js) (Browser client), [`src/models/User.js`](https://github.com/sarathi377/mindmate/blob/main/src/models/User.js) (User records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_client["Browser client<br/>[app.js]"]
  node_auth_ui["Authentication UI<br/>[login.js]"]
  node_chat_ui["Chat interface<br/>[chat.js]"]
  node_mood_ui["Mood tracking<br/>[dashboard.js]"]
  node_wellness_ui["Wellness tools<br/>[relaxation.js]"]
  node_journal_ui["Journal<br/>[journal.js]"]
  node_report_ui["Reports<br/>[report.js]"]
end

subgraph group_api["Application API"]
  node_app_server["Express application<br/>[server.js]"]
  node_chat_routes["Chat and mood API<br/>[chat.js]"]
end

subgraph group_support["Support services"]
  node_sentiment["Sentiment analysis"]
  node_gemini["Gemini AI"]
end

subgraph group_persistence["Persistence"]
  node_users[("User records<br/>[User.js]")]
  node_messages[("Chat messages<br/>[Message.js]")]
  node_feedback[("Feedback records<br/>[Feedback.js]")]
  node_moods[("Mood records<br/>[Mood.js]")]
  node_reports[("Progress reports<br/>[Report.js]")]
end

subgraph group_alternate["SQLite alternative"]
  node_sqlite_api["SQLite API<br/>[server.js]"]
  node_sqlite_db[("SQLite database")]
end

node_user(("User"))
node_mongodb[("MongoDB")]

node_user -->|"uses"| node_client
node_user -->|"registers or logs in"| node_auth_ui
node_user -->|"seeks support"| node_chat_ui
node_user -->|"tracks mood"| node_mood_ui
node_user -->|"uses tools"| node_wellness_ui
node_user -->|"journals"| node_journal_ui
node_user -->|"reviews progress"| node_report_ui
node_app_server -->|"serves assets"| node_client
node_app_server -->|"mounts routes"| node_chat_routes
node_app_server -->|"authenticates users"| node_users
node_app_server -->|"stores feedback"| node_feedback
node_app_server -->|"reads admin logs"| node_messages
node_app_server -->|"connects to"| node_mongodb
node_chat_routes -->|"reads and writes"| node_messages
node_chat_routes -->|"updates mood"| node_users
node_chat_routes -->|"analyzes text"| node_sentiment
node_chat_routes -->|"generates replies"| node_gemini
node_sqlite_api -->|"reads and writes"| node_sqlite_db

click node_client "https://github.com/sarathi377/mindmate/blob/main/public/js/app.js"
click node_auth_ui "https://github.com/sarathi377/mindmate/blob/main/public/js/login.js"
click node_chat_ui "https://github.com/sarathi377/mindmate/blob/main/public/js/chat.js"
click node_mood_ui "https://github.com/sarathi377/mindmate/blob/main/public/js/dashboard.js"
click node_wellness_ui "https://github.com/sarathi377/mindmate/blob/main/public/js/relaxation.js"
click node_journal_ui "https://github.com/sarathi377/mindmate/blob/main/public/js/journal.js"
click node_report_ui "https://github.com/sarathi377/mindmate/blob/main/public/js/report.js"
click node_app_server "https://github.com/sarathi377/mindmate/blob/main/server.js"
click node_chat_routes "https://github.com/sarathi377/mindmate/blob/main/src/routes/chat.js"
click node_sentiment "https://github.com/sarathi377/mindmate/blob/main/src/services/sentimentService.js"
click node_users "https://github.com/sarathi377/mindmate/blob/main/src/models/User.js"
click node_messages "https://github.com/sarathi377/mindmate/blob/main/src/models/Message.js"
click node_feedback "https://github.com/sarathi377/mindmate/blob/main/src/models/Feedback.js"
click node_moods "https://github.com/sarathi377/mindmate/blob/main/src/models/Mood.js"
click node_reports "https://github.com/sarathi377/mindmate/blob/main/src/models/Report.js"
click node_sqlite_api "https://github.com/sarathi377/mindmate/blob/main/database/server.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_client,node_auth_ui,node_chat_ui,node_mood_ui,node_wellness_ui,node_journal_ui,node_report_ui,node_user toneBlue
class node_app_server,node_chat_routes,node_mongodb toneAmber
class node_sentiment,node_gemini toneMint
class node_users,node_messages,node_feedback,node_moods,node_reports toneRose
class node_sqlite_api,node_sqlite_db toneIndigo
```

## Components

### Web experience

- [Browser client](https://github.com/sarathi377/mindmate/blob/main/public/js/app.js): `public/js/app.js`
- [Authentication UI](https://github.com/sarathi377/mindmate/blob/main/public/js/login.js): `public/js/login.js`
- [Chat interface](https://github.com/sarathi377/mindmate/blob/main/public/js/chat.js): `public/js/chat.js`
- [Mood tracking](https://github.com/sarathi377/mindmate/blob/main/public/js/dashboard.js): `public/js/dashboard.js`
- [Wellness tools](https://github.com/sarathi377/mindmate/blob/main/public/js/relaxation.js): `public/js/relaxation.js`
- [Journal](https://github.com/sarathi377/mindmate/blob/main/public/js/journal.js): `public/js/journal.js`
- [Reports](https://github.com/sarathi377/mindmate/blob/main/public/js/report.js): `public/js/report.js`

### Application API

- [Express application](https://github.com/sarathi377/mindmate/blob/main/server.js): `server.js`
- [Chat and mood API](https://github.com/sarathi377/mindmate/blob/main/src/routes/chat.js): `src/routes/chat.js`

### Support services

- [Sentiment analysis](https://github.com/sarathi377/mindmate/blob/main/src/services/sentimentService.js): `src/services/sentimentService.js`
- **Gemini AI**

### Persistence

- [User records](https://github.com/sarathi377/mindmate/blob/main/src/models/User.js): `src/models/User.js`
- [Chat messages](https://github.com/sarathi377/mindmate/blob/main/src/models/Message.js): `src/models/Message.js`
- [Feedback records](https://github.com/sarathi377/mindmate/blob/main/src/models/Feedback.js): `src/models/Feedback.js`
- [Mood records](https://github.com/sarathi377/mindmate/blob/main/src/models/Mood.js): `src/models/Mood.js`
- [Progress reports](https://github.com/sarathi377/mindmate/blob/main/src/models/Report.js): `src/models/Report.js`

### SQLite alternative

- [SQLite API](https://github.com/sarathi377/mindmate/blob/main/database/server.js): `database/server.js`
- **SQLite database**

### Other components

- **User**
- **MongoDB**

## Connections

- User → Browser client: uses (evidence: `README.md`)
- User → Authentication UI: registers or logs in (evidence: `README.md`)
- User → Chat interface: seeks support (evidence: `README.md`)
- User → Mood tracking: tracks mood (evidence: `README.md`)
- User → Wellness tools: uses tools (evidence: `README.md`)
- User → Journal: journals (evidence: `README.md`)
- User → Reports: reviews progress (evidence: `README.md`)
- Express application → Browser client: serves assets (evidence: `server.js`)
- Express application → Chat and mood API: mounts routes (evidence: `server.js`)
- Express application → User records: authenticates users (evidence: `server.js`)
- Express application → Feedback records: stores feedback (evidence: `server.js`)
- Express application → Chat messages: reads admin logs (evidence: `server.js`)
- Express application → MongoDB: connects to (evidence: `server.js`)
- Chat and mood API → Chat messages: reads and writes (evidence: `src/routes/chat.js`)
- Chat and mood API → User records: updates mood (evidence: `src/routes/chat.js`)
- Chat and mood API → Sentiment analysis: analyzes text (evidence: `src/routes/chat.js`)
- Chat and mood API → Gemini AI: generates replies (evidence: `src/routes/chat.js`)
- SQLite API → SQLite database: reads and writes (evidence: `database/server.js`)
