# vinayjoseph003/care-ai architecture

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

- Interactive diagram: https://gitdiagram.com/vinayjoseph003/care-ai
- Repository: https://github.com/vinayjoseph003/care-ai

## Overview

Care-AI is a multilingual medical information chatbot. Users enter symptoms or health questions through the Streamlit interface or CLI; the bot gathers follow-up information, assesses symptoms and triage, grounds an answer in medical knowledge, and presents the result with source and safety information. The graph also shows the documented doctor-finder capability and LLM fallback providers. Some core modules were not sampled, so their internal call wiring is shown only where the README or excerpts support it.

Main entry points: [`bot/careai.py`](https://github.com/vinayjoseph003/care-ai/blob/main/bot/careai.py) (Conversation and XAI), [`core/llm_router.py`](https://github.com/vinayjoseph003/care-ai/blob/main/core/llm_router.py) (LLM fallback router), [`ui/app.py`](https://github.com/vinayjoseph003/care-ai/blob/main/ui/app.py) (Streamlit UI), [`main.py`](https://github.com/vinayjoseph003/care-ai/blob/main/main.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_streamlit["Streamlit UI<br/>[app.py]"]
  node_cli["CLI<br/>[main.py]"]
  node_doctor_panel["Doctor finder panel"]
end

subgraph group_clinical["Clinical conversation"]
  node_careai["Conversation and XAI<br/>[careai.py]"]
  node_symptom_score["Symptom scoring<br/>[symptom_scorer.py]"]
  node_doctor_finder["Specialist finder<br/>[doctor_finder.py]"]
  node_prompts["Clinical prompts<br/>[prompts.py]"]
end

subgraph group_knowledge["Knowledge and retrieval"]
  node_knowledge_base["Knowledge ingestion<br/>[knowledge_base.py]"]
  node_medical_data["Medical source data"]
  node_query_expander["Query expansion<br/>[query_expander.py]"]
  node_vector_store[("Vector retrieval<br/>[vector_store.py]")]
  node_nhs_parser["NHS chunk parser<br/>[nhs_parser.py]"]
end

subgraph group_providers["LLM providers"]
  node_llm_router["LLM fallback router<br/>[llm_router.py]"]
end

node_user(("User"))
node_openrouter{{"OpenRouter"}}
node_groq{{"Groq"}}
node_gemini{{"Gemini"}}
node_ollama{{"Ollama"}}

node_user -->|"asks"| node_streamlit
node_user -->|"asks"| node_cli
node_streamlit -->|"builds chunks"| node_knowledge_base
node_cli -->|"builds chunks"| node_knowledge_base
node_knowledge_base -->|"reads sources"| node_medical_data
node_nhs_parser -->|"writes NHS chunks"| node_medical_data
node_streamlit -->|"creates bot"| node_careai
node_cli -->|"creates bot"| node_careai
node_streamlit -->|"renders finder"| node_doctor_panel
node_careai -->|"scores symptoms"| node_symptom_score
node_careai -->|"selects specialist"| node_doctor_finder
node_careai -->|"retrieves context"| node_vector_store
node_careai -->|"requests generation"| node_llm_router
node_llm_router -.->|"calls provider"| node_openrouter
node_llm_router -.->|"calls provider"| node_groq
node_llm_router -.->|"calls provider"| node_gemini
node_llm_router -.->|"calls provider"| node_ollama

click node_streamlit "https://github.com/vinayjoseph003/care-ai/blob/main/ui/app.py"
click node_cli "https://github.com/vinayjoseph003/care-ai/blob/main/main.py"
click node_doctor_panel "https://github.com/vinayjoseph003/care-ai/blob/main/ui/doctor_finder_panel.py"
click node_careai "https://github.com/vinayjoseph003/care-ai/blob/main/bot/careai.py"
click node_symptom_score "https://github.com/vinayjoseph003/care-ai/blob/main/core/symptom_scorer.py"
click node_doctor_finder "https://github.com/vinayjoseph003/care-ai/blob/main/core/doctor_finder.py"
click node_prompts "https://github.com/vinayjoseph003/care-ai/blob/main/core/prompts.py"
click node_knowledge_base "https://github.com/vinayjoseph003/care-ai/blob/main/core/knowledge_base.py"
click node_medical_data "https://github.com/vinayjoseph003/care-ai/tree/main/data"
click node_query_expander "https://github.com/vinayjoseph003/care-ai/blob/main/core/query_expander.py"
click node_vector_store "https://github.com/vinayjoseph003/care-ai/blob/main/core/vector_store.py"
click node_nhs_parser "https://github.com/vinayjoseph003/care-ai/blob/main/nhs_parser.py"
click node_llm_router "https://github.com/vinayjoseph003/care-ai/blob/main/core/llm_router.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_streamlit,node_cli,node_doctor_panel,node_user toneBlue
class node_careai,node_symptom_score,node_doctor_finder,node_prompts toneAmber
class node_knowledge_base,node_medical_data,node_query_expander,node_vector_store,node_nhs_parser,node_openrouter toneMint
class node_llm_router toneRose
class node_groq,node_gemini,node_ollama toneIndigo
```

## Components

### User interfaces

- [Streamlit UI](https://github.com/vinayjoseph003/care-ai/blob/main/ui/app.py): `ui/app.py`
- [CLI](https://github.com/vinayjoseph003/care-ai/blob/main/main.py): `main.py`
- [Doctor finder panel](https://github.com/vinayjoseph003/care-ai/blob/main/ui/doctor_finder_panel.py): `ui/doctor_finder_panel.py`

### Clinical conversation

- [Conversation and XAI](https://github.com/vinayjoseph003/care-ai/blob/main/bot/careai.py): `bot/careai.py`
- [Symptom scoring](https://github.com/vinayjoseph003/care-ai/blob/main/core/symptom_scorer.py): `core/symptom_scorer.py`
- [Specialist finder](https://github.com/vinayjoseph003/care-ai/blob/main/core/doctor_finder.py): `core/doctor_finder.py`
- [Clinical prompts](https://github.com/vinayjoseph003/care-ai/blob/main/core/prompts.py): `core/prompts.py`

### Knowledge and retrieval

- [Knowledge ingestion](https://github.com/vinayjoseph003/care-ai/blob/main/core/knowledge_base.py): `core/knowledge_base.py`
- [Medical source data](https://github.com/vinayjoseph003/care-ai/tree/main/data): `data`
- [Query expansion](https://github.com/vinayjoseph003/care-ai/blob/main/core/query_expander.py): `core/query_expander.py`
- [Vector retrieval](https://github.com/vinayjoseph003/care-ai/blob/main/core/vector_store.py): `core/vector_store.py`
- [NHS chunk parser](https://github.com/vinayjoseph003/care-ai/blob/main/nhs_parser.py): `nhs_parser.py`

### LLM providers

- [LLM fallback router](https://github.com/vinayjoseph003/care-ai/blob/main/core/llm_router.py): `core/llm_router.py`

### Other components

- **User**
- **OpenRouter**
- **Groq**
- **Gemini**
- **Ollama**

## Connections

- User → Streamlit UI: asks
- User → CLI: asks
- Streamlit UI → Knowledge ingestion: builds chunks
- CLI → Knowledge ingestion: builds chunks
- Knowledge ingestion → Medical source data: reads sources
- NHS chunk parser → Medical source data: writes NHS chunks
- Streamlit UI → Conversation and XAI: creates bot
- CLI → Conversation and XAI: creates bot
- Streamlit UI → Doctor finder panel: renders finder
- Conversation and XAI → Symptom scoring: scores symptoms
- Conversation and XAI → Specialist finder: selects specialist
- Conversation and XAI → Vector retrieval: retrieves context
- Conversation and XAI → LLM fallback router: requests generation
- LLM fallback router → OpenRouter: calls provider
- LLM fallback router → Groq: calls provider
- LLM fallback router → Gemini: calls provider
- LLM fallback router → Ollama: calls provider
