# vinay-ops/mental-health-chatbot-chat-voice- architecture

> Architecture diagram of the GitHub repository vinay-ops/mental-health-chatbot-chat-voice-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vinay-ops/mental-health-chatbot-chat-voice-
- Repository: https://github.com/vinay-ops/mental-health-chatbot-chat-voice-

## Overview

MindCare Navigator is a Flask-based mental-health support app. Users reach its pages and APIs through the Flask entry point; the main interaction is submitting a chat message, which the chat route prepares, sends through the AI fallback dispatcher, and can turn into voice using TTS. Other documented capabilities include authentication, multilingual support, community posts, psychologist discovery, and user–psychologist messaging. The database layer persists account, chat, community, and messaging data. Some UI-to-API wiring and unsampled route behavior are not shown, so those connections are omitted rather than inferred.

Main entry points: [`backend/routes/chat.py`](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/chat.py) (AI chat routes), [`backend/database/db.py`](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/database/db.py) (Database operations), [`backend/routes/__init__.py`](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/__init__.py) (Blueprint registry), [`app.py`](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/app.py) (Flask application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_pages["Page templates"]
  node_chatjs["Chat interaction<br/>[chat.js]"]
  node_translations["Language translations<br/>[translations.js]"]
end

subgraph group_api["Application routes"]
  node_flask["Flask application<br/>[app.py]"]
  node_blueprints["Blueprint registry<br/>[__init__.py]"]
  node_auth["Authentication routes<br/>[auth.py]"]
  node_chat["AI chat routes<br/>[chat.py]"]
  node_community["Community routes<br/>[community.py]"]
  node_psychologist["Psychologist routes<br/>[psychologist.py]"]
end

subgraph group_support["Support services"]
  node_config["Configuration<br/>[config.py]"]
  node_helpers["Auth and text helpers<br/>[helpers.py]"]
  node_ai["AI provider fallback<br/>[providers.py]"]
  node_tts["Voice synthesis<br/>[tts.py]"]
end

subgraph group_data["Persistence"]
  node_db["Database operations<br/>[db.py]"]
  node_supabase[("PostgreSQL client<br/>[supabase_client.py]")]
end

node_user(("Visitor"))
node_postgres[("Supabase PostgreSQL")]
node_ai_providers{{"AI provider services"}}
node_fish{{"Fish Audio"}}
node_osm{{"OpenStreetMap"}}

node_user -.->|"uses"| node_flask
node_flask -->|"registers"| node_blueprints
node_blueprints -->|"imports"| node_auth
node_blueprints -->|"imports"| node_chat
node_blueprints -->|"imports"| node_community
node_blueprints -->|"imports"| node_psychologist
node_flask -->|"renders"| node_pages
node_flask -->|"initializes"| node_db
node_auth -->|"reads and writes"| node_db
node_auth -->|"hashes and signs"| node_helpers
node_chat -->|"generates replies"| node_ai
node_chat -->|"synthesizes speech"| node_tts
node_chat -->|"loads history"| node_db
node_chat -->|"formats replies"| node_helpers
node_chat -->|"reads settings"| node_config
node_community -->|"reads and writes"| node_db
node_community -->|"extracts identity"| node_helpers
node_psychologist -->|"reads and writes"| node_db
node_psychologist -->|"checks tokens"| node_helpers
node_psychologist -->|"searches locations"| node_osm
node_db -->|"uses client"| node_supabase
node_supabase -->|"connects to"| node_postgres
node_ai -->|"calls providers"| node_ai_providers
node_tts -->|"sends synthesis"| node_fish

click node_flask "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/app.py"
click node_blueprints "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/__init__.py"
click node_auth "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/auth.py"
click node_chat "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/chat.py"
click node_community "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/community.py"
click node_psychologist "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/psychologist.py"
click node_pages "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/tree/main/templates"
click node_chatjs "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/static/js/chat.js"
click node_translations "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/static/js/translations.js"
click node_config "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/config.py"
click node_helpers "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/helpers.py"
click node_ai "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/ai/providers.py"
click node_tts "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/services/tts.py"
click node_db "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/database/db.py"
click node_supabase "https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/database/supabase_client.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_pages,node_chatjs,node_translations toneBlue
class node_flask,node_blueprints,node_auth,node_chat,node_community,node_psychologist,node_postgres toneAmber
class node_config,node_helpers,node_ai,node_tts toneMint
class node_db,node_supabase toneRose
class node_user,node_ai_providers,node_fish,node_osm toneIndigo
```

## Components

### Web interface

- [Page templates](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/tree/main/templates): `templates`
- [Chat interaction](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/static/js/chat.js): `static/js/chat.js`
- [Language translations](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/static/js/translations.js): `static/js/translations.js`

### Application routes

- [Flask application](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/app.py): `app.py`
- [Blueprint registry](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/__init__.py): `backend/routes/__init__.py`
- [Authentication routes](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/auth.py): `backend/routes/auth.py`
- [AI chat routes](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/chat.py): `backend/routes/chat.py`
- [Community routes](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/community.py): `backend/routes/community.py`
- [Psychologist routes](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/routes/psychologist.py): `backend/routes/psychologist.py`

### Support services

- [Configuration](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/config.py): `backend/config.py`
- [Auth and text helpers](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/helpers.py): `backend/helpers.py`
- [AI provider fallback](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/ai/providers.py): `backend/ai/providers.py`
- [Voice synthesis](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/services/tts.py): `backend/services/tts.py`

### Persistence

- [Database operations](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/database/db.py): `backend/database/db.py`
- [PostgreSQL client](https://github.com/vinay-ops/mental-health-chatbot-chat-voice-/blob/main/backend/database/supabase_client.py): `backend/database/supabase_client.py`

### Other components

- **Visitor**
- **Supabase PostgreSQL**
- **AI provider services**
- **Fish Audio**
- **OpenStreetMap**

## Connections

- Visitor → Flask application: uses (evidence: `README.md`)
- Flask application → Blueprint registry: registers (evidence: `app.py`)
- Blueprint registry → Authentication routes: imports (evidence: `backend/routes/__init__.py`)
- Blueprint registry → AI chat routes: imports (evidence: `backend/routes/__init__.py`)
- Blueprint registry → Community routes: imports (evidence: `backend/routes/__init__.py`)
- Blueprint registry → Psychologist routes: imports (evidence: `backend/routes/__init__.py`)
- Flask application → Page templates: renders (evidence: `app.py`)
- Flask application → Database operations: initializes (evidence: `app.py`)
- Authentication routes → Database operations: reads and writes (evidence: `backend/routes/auth.py`)
- Authentication routes → Auth and text helpers: hashes and signs (evidence: `backend/routes/auth.py`)
- AI chat routes → AI provider fallback: generates replies (evidence: `backend/routes/chat.py`)
- AI chat routes → Voice synthesis: synthesizes speech (evidence: `backend/routes/chat.py`)
- AI chat routes → Database operations: loads history (evidence: `backend/routes/chat.py`)
- AI chat routes → Auth and text helpers: formats replies (evidence: `backend/routes/chat.py`)
- AI chat routes → Configuration: reads settings (evidence: `backend/routes/chat.py`)
- Community routes → Database operations: reads and writes (evidence: `backend/routes/community.py`)
- Community routes → Auth and text helpers: extracts identity (evidence: `backend/routes/community.py`)
- Psychologist routes → Database operations: reads and writes (evidence: `backend/routes/psychologist.py`)
- Psychologist routes → Auth and text helpers: checks tokens (evidence: `backend/routes/psychologist.py`)
- Psychologist routes → OpenStreetMap: searches locations (evidence: `backend/routes/psychologist.py`)
- Database operations → PostgreSQL client: uses client (evidence: `backend/database/db.py`)
- PostgreSQL client → Supabase PostgreSQL: connects to (evidence: `backend/database/supabase_client.py`)
- AI provider fallback → AI provider services: calls providers (evidence: `backend/ai/providers.py`)
- Voice synthesis → Fish Audio: sends synthesis (evidence: `backend/services/tts.py`)
