# rishav822/care-connect architecture

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

- Interactive diagram: https://gitdiagram.com/rishav822/care-connect
- Repository: https://github.com/rishav822/care-connect

## Overview

Care Connect is a Flask-based health-information chatbot. Its main workflow accepts a chat message, classifies intent using NLP and a saved neural network, applies conversation-state logic, and returns a response. The app also supports a profile API backed by MongoDB and a guided BMI flow. The README documents a browser chat interface and model-training workflow, though frontend files are absent from the tree. Training and frontend links are based on README statements; runtime links are grounded in the app excerpt.

Main entry points: [`app.py`](https://github.com/rishav822/care-connect/blob/main/app.py) (Conversation flow), [`train_model.py`](https://github.com/rishav822/care-connect/blob/main/train_model.py) (Model training), [`intents.json`](https://github.com/rishav822/care-connect/blob/main/intents.json) (Intent patterns), [`chatbot_model.h5`](https://github.com/rishav822/care-connect/blob/main/chatbot_model.h5) (Neural model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Chat interface"]
  node_chat_ui["Web chat"]
end

subgraph group_application["Flask application"]
  node_flask_api["Flask routes<br/>[app.py]"]
  node_conversation["Conversation flow<br/>[app.py]"]
  node_bmi["BMI calculation<br/>[app.py]"]
  node_profile_api["Profile API<br/>[app.py]"]
end

subgraph group_intelligence["NLP and intent"]
  node_nlp["Text preprocessing<br/>[app.py]"]
  node_intent_model["Intent prediction<br/>[app.py]"]
  node_response_select["Response selection<br/>[app.py]"]
  node_trainer["Model training<br/>[train_model.py]"]
end

subgraph group_data["Model and profile data"]
  node_intent_data["Intent patterns<br/>[intents.json]"]
  node_saved_model["Neural model<br/>[chatbot_model.h5]"]
  node_vocabulary["Vocabulary classes<br/>[words.pkl]"]
  node_mongo[("MongoDB profiles")]
end

node_user(("Chat user"))

node_user -->|"enters message"| node_chat_ui
node_chat_ui -->|"posts JSON"| node_flask_api
node_flask_api -->|"dispatches message"| node_conversation
node_conversation -->|"predicts intent"| node_intent_model
node_intent_model -->|"vectorizes text"| node_nlp
node_intent_model -->|"runs inference"| node_saved_model
node_intent_model -->|"uses classes"| node_vocabulary
node_conversation -->|"selects reply"| node_response_select
node_response_select -->|"matches response"| node_intent_data
node_conversation -->|"calculates BMI"| node_bmi
node_flask_api -->|"routes profile"| node_profile_api
node_profile_api -->|"reads and writes"| node_mongo
node_trainer -->|"trains from"| node_intent_data
node_trainer -->|"saves model"| node_saved_model
node_trainer -->|"saves vocabulary"| node_vocabulary

click node_flask_api "https://github.com/rishav822/care-connect/blob/main/app.py"
click node_conversation "https://github.com/rishav822/care-connect/blob/main/app.py"
click node_bmi "https://github.com/rishav822/care-connect/blob/main/app.py"
click node_profile_api "https://github.com/rishav822/care-connect/blob/main/app.py"
click node_nlp "https://github.com/rishav822/care-connect/blob/main/app.py"
click node_intent_model "https://github.com/rishav822/care-connect/blob/main/app.py"
click node_response_select "https://github.com/rishav822/care-connect/blob/main/app.py"
click node_trainer "https://github.com/rishav822/care-connect/blob/main/train_model.py"
click node_intent_data "https://github.com/rishav822/care-connect/blob/main/intents.json"
click node_saved_model "https://github.com/rishav822/care-connect/blob/main/chatbot_model.h5"
click node_vocabulary "https://github.com/rishav822/care-connect/blob/main/words.pkl"

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_chat_ui,node_user toneBlue
class node_flask_api,node_conversation,node_bmi,node_profile_api toneAmber
class node_nlp,node_intent_model,node_response_select,node_trainer toneMint
class node_intent_data,node_saved_model,node_vocabulary,node_mongo toneRose
```

## Components

### Chat interface

- **Web chat**

### Flask application

- [Flask routes](https://github.com/rishav822/care-connect/blob/main/app.py): `app.py`
- [Conversation flow](https://github.com/rishav822/care-connect/blob/main/app.py): `app.py`
- [BMI calculation](https://github.com/rishav822/care-connect/blob/main/app.py): `app.py`
- [Profile API](https://github.com/rishav822/care-connect/blob/main/app.py): `app.py`

### NLP and intent

- [Text preprocessing](https://github.com/rishav822/care-connect/blob/main/app.py): `app.py`
- [Intent prediction](https://github.com/rishav822/care-connect/blob/main/app.py): `app.py`
- [Response selection](https://github.com/rishav822/care-connect/blob/main/app.py): `app.py`
- [Model training](https://github.com/rishav822/care-connect/blob/main/train_model.py): `train_model.py`

### Model and profile data

- [Intent patterns](https://github.com/rishav822/care-connect/blob/main/intents.json): `intents.json`
- [Neural model](https://github.com/rishav822/care-connect/blob/main/chatbot_model.h5): `chatbot_model.h5`
- [Vocabulary classes](https://github.com/rishav822/care-connect/blob/main/words.pkl): `words.pkl`
- **MongoDB profiles**

### Other components

- **Chat user**

## Connections

- Chat user → Web chat: enters message (evidence: `README.md`)
- Web chat → Flask routes: posts JSON (evidence: `README.md`)
- Flask routes → Conversation flow: dispatches message (evidence: `app.py`)
- Conversation flow → Intent prediction: predicts intent (evidence: `app.py`)
- Intent prediction → Text preprocessing: vectorizes text (evidence: `app.py`)
- Intent prediction → Neural model: runs inference (evidence: `app.py`)
- Intent prediction → Vocabulary classes: uses classes (evidence: `app.py`)
- Conversation flow → Response selection: selects reply (evidence: `app.py`)
- Response selection → Intent patterns: matches response (evidence: `app.py`)
- Conversation flow → BMI calculation: calculates BMI (evidence: `app.py`)
- Flask routes → Profile API: routes profile (evidence: `app.py`)
- Profile API → MongoDB profiles: reads and writes (evidence: `app.py`)
- Model training → Intent patterns: trains from (evidence: `train_model.py`)
- Model training → Neural model: saves model (evidence: `train_model.py`)
- Model training → Vocabulary classes: saves vocabulary (evidence: `train_model.py`)
