# karthickrajathandapani/healthcare-sales-insight-prediction-and-rag architecture

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

- Interactive diagram: https://gitdiagram.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag
- Repository: https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag

## Overview

Mosaic HCP Assistant is a field-sales dashboard combining HCP follow-up workflows, predictive insights, PDF reporting, and a conversational assistant. A rep uses the dashboard or chatbot; Flask serves filtered HCP data and results from KPI calculations, forecasting, and risk scoring. Chat queries are routed to analytics, prediction, or retrieval, then answered through Groq; the retrieval branch uses hybrid search over a Pinecone index. The README documents UI capabilities and service integrations; some internal wiring is unsampled, so those links are omitted where not evidenced.

Main entry points: [`app.py`](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/app.py) (Flask routes), [`rag/chain.py`](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/chain.py) (Chat engine), [`templates/index.html`](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/templates/index.html) (Dashboard UI), [`rag/vectorstore.py`](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/vectorstore.py) (Pinecone index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Dashboard experience"]
  node_browser["Dashboard UI<br/>[index.html]"]
  node_dashjs["Dashboard controls<br/>[dashboard.js]"]
  node_chatjs["Chat client<br/>[chatbot.js]"]
  node_predjs["Prediction charts<br/>[predictions.js]"]
end

subgraph group_appdata["App and HCP data"]
  node_flask["Flask routes<br/>[app.py]"]
  node_dataset["HCP engagement CSV"]
  node_loader["Data and KPIs<br/>[data_loader.py]"]
end

subgraph group_insights["Predictive insights"]
  node_forecast["Rx forecasting<br/>[forecasting.py]"]
  node_risk["Engagement risk<br/>[risk_model.py]"]
  node_predictions["Prediction APIs<br/>[app.py]"]
end

subgraph group_rag["Chat and retrieval"]
  node_chunking["Document chunking<br/>[chunking.py]"]
  node_vectorstore[("Pinecone index<br/>[vectorstore.py]")]
  node_embeddings["Hosted embeddings"]
  node_retriever["Hybrid retrieval<br/>[retriever.py]"]
  node_reranker["Cross-encoder reranker<br/>[reranker.py]"]
  node_analytics["Query routing<br/>[analytics.py]"]
  node_chatengine["Chat engine<br/>[chain.py]"]
end

subgraph group_report["Reporting"]
  node_pdf["PDF report builder<br/>[reporting.py]"]
end

node_rep(("Field rep"))
node_groq{{"Groq LLM"}}
node_pinecone{{"Pinecone service"}}

node_rep -->|"uses"| node_browser
node_browser -->|"loads controls"| node_dashjs
node_browser -->|"loads chat"| node_chatjs
node_browser -->|"loads charts"| node_predjs
node_dashjs -->|"calls dashboard APIs"| node_flask
node_chatjs -->|"sends chat"| node_flask
node_predjs -->|"requests predictions"| node_flask
node_flask -->|"loads data and KPIs"| node_loader
node_loader -->|"reads"| node_dataset
node_flask -->|"uses forecast model"| node_forecast
node_flask -->|"uses risk model"| node_risk
node_flask -->|"serves results"| node_predictions
node_flask -->|"builds documents"| node_chunking
node_flask -->|"builds or loads index"| node_vectorstore
node_vectorstore -->|"configures embeddings"| node_embeddings
node_embeddings -->|"requests vectors"| node_pinecone
node_vectorstore -->|"reads and writes index"| node_pinecone
node_flask -->|"builds retriever"| node_retriever
node_chatengine -->|"retrieves context"| node_retriever
node_chatengine -->|"routes and answers"| node_analytics
node_chatengine -->|"reranks results"| node_reranker
node_reranker -->|"reranks candidates"| node_retriever
node_chatengine -->|"generates responses"| node_groq
node_flask -->|"streams chat replies"| node_chatengine
node_flask -->|"builds export"| node_pdf
node_rep -->|"exports report"| node_pdf

click node_browser "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/templates/index.html"
click node_dashjs "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/static/js/dashboard.js"
click node_chatjs "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/static/js/chatbot.js"
click node_predjs "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/static/js/predictions.js"
click node_flask "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/app.py"
click node_dataset "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/data/cleaned_hcp_engagement_dataset.csv"
click node_loader "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/data_loader.py"
click node_chunking "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/chunking.py"
click node_vectorstore "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/vectorstore.py"
click node_embeddings "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/pinecone_embeddings.py"
click node_retriever "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/retriever.py"
click node_reranker "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/reranker.py"
click node_analytics "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/analytics.py"
click node_chatengine "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/chain.py"
click node_forecast "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/ml/forecasting.py"
click node_risk "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/ml/risk_model.py"
click node_predictions "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/app.py"
click node_pdf "https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/reporting.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_browser,node_dashjs,node_chatjs,node_predjs toneBlue
class node_flask,node_dataset,node_loader toneAmber
class node_forecast,node_risk,node_predictions toneMint
class node_chunking,node_vectorstore,node_embeddings,node_retriever,node_reranker,node_analytics,node_chatengine toneRose
class node_pdf,node_rep,node_groq,node_pinecone toneIndigo
```

## Components

### Dashboard experience

- [Dashboard UI](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/templates/index.html): `templates/index.html`
- [Dashboard controls](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/static/js/dashboard.js): `static/js/dashboard.js`
- [Chat client](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/static/js/chatbot.js): `static/js/chatbot.js`
- [Prediction charts](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/static/js/predictions.js): `static/js/predictions.js`

### App and HCP data

- [Flask routes](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/app.py): `app.py`
- [HCP engagement CSV](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/data/cleaned_hcp_engagement_dataset.csv): `data/cleaned_hcp_engagement_dataset.csv`
- [Data and KPIs](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/data_loader.py): `rag/data_loader.py`

### Predictive insights

- [Rx forecasting](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/ml/forecasting.py): `ml/forecasting.py`
- [Engagement risk](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/ml/risk_model.py): `ml/risk_model.py`
- [Prediction APIs](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/app.py): `app.py`

### Chat and retrieval

- [Document chunking](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/chunking.py): `rag/chunking.py`
- [Pinecone index](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/vectorstore.py): `rag/vectorstore.py`
- [Hosted embeddings](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/pinecone_embeddings.py): `rag/pinecone_embeddings.py`
- [Hybrid retrieval](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/retriever.py): `rag/retriever.py`
- [Cross-encoder reranker](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/reranker.py): `rag/reranker.py`
- [Query routing](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/analytics.py): `rag/analytics.py`
- [Chat engine](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/rag/chain.py): `rag/chain.py`

### Reporting

- [PDF report builder](https://github.com/karthickrajathandapani/healthcare-sales-insight-prediction-and-rag/blob/main/reporting.py): `reporting.py`

### Other components

- **Field rep**
- **Groq LLM**
- **Pinecone service**

## Connections

- Field rep → Dashboard UI: uses (evidence: `README.md`)
- Dashboard UI → Dashboard controls: loads controls (evidence: `README.md`)
- Dashboard UI → Chat client: loads chat (evidence: `README.md`)
- Dashboard UI → Prediction charts: loads charts (evidence: `README.md`)
- Dashboard controls → Flask routes: calls dashboard APIs (evidence: `README.md`)
- Chat client → Flask routes: sends chat (evidence: `README.md`)
- Prediction charts → Flask routes: requests predictions (evidence: `README.md`)
- Flask routes → Data and KPIs: loads data and KPIs (evidence: `app.py`)
- Data and KPIs → HCP engagement CSV: reads (evidence: `rag/data_loader.py`)
- Flask routes → Rx forecasting: uses forecast model (evidence: `app.py`)
- Flask routes → Engagement risk: uses risk model (evidence: `app.py`)
- Flask routes → Prediction APIs: serves results (evidence: `README.md`)
- Flask routes → Document chunking: builds documents (evidence: `app.py`)
- Flask routes → Pinecone index: builds or loads index (evidence: `app.py`)
- Pinecone index → Hosted embeddings: configures embeddings (evidence: `rag/vectorstore.py`)
- Hosted embeddings → Pinecone service: requests vectors (evidence: `rag/pinecone_embeddings.py`)
- Pinecone index → Pinecone service: reads and writes index (evidence: `rag/vectorstore.py`)
- Flask routes → Hybrid retrieval: builds retriever (evidence: `app.py`)
- Chat engine → Hybrid retrieval: retrieves context (evidence: `README.md`)
- Chat engine → Query routing: routes and answers (evidence: `rag/chain.py`)
- Chat engine → Cross-encoder reranker: reranks results (evidence: `rag/chain.py`)
- Cross-encoder reranker → Hybrid retrieval: reranks candidates (evidence: `README.md`)
- Chat engine → Groq LLM: generates responses (evidence: `README.md`)
- Flask routes → Chat engine: streams chat replies (evidence: `app.py`)
- Flask routes → PDF report builder: builds export (evidence: `app.py`)
- Field rep → PDF report builder: exports report (evidence: `README.md`)
