# sanoj-936/medassist architecture

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

- Interactive diagram: https://gitdiagram.com/sanoj-936/medassist
- Repository: https://github.com/sanoj-936/medassist

## Overview

MedAssist is a medical-reference RAG chatbot with two knowledge-to-answer paths: an offline ingestion path that builds a FAISS index from the Gale encyclopedia, and an online Streamlit path that retrieves passages, asks an LLM for a grounded response, and displays supported page citations. The sampled chatbot code shows the online retrieval, Groq invocation, evidence parsing, and rendering; the README documents the ingestion stages and index flow. The separate command-line script uses a Hugging Face endpoint. Some ingestion and deployment details are documented rather than verified in sampled runtime code.

Main entry points: [`chatbot.py`](https://github.com/sanoj-936/medassist/blob/main/chatbot.py) (Passage Retrieval), [`vectorstore/db_faiss`](https://github.com/sanoj-936/medassist/tree/main/vectorstore/db_faiss) (FAISS Store), [`connect_memory_with_llm.py`](https://github.com/sanoj-936/medassist/blob/main/connect_memory_with_llm.py) (CLI RAG), [`create_memory_for_llm.py`](https://github.com/sanoj-936/medassist/blob/main/create_memory_for_llm.py) (PDF Extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat Interface"]
  node_streamlit["Streamlit Chat<br/>[chatbot.py]"]
  node_answer["Rendered Answer<br/>[chatbot.py]"]
end

subgraph group_runtime["Grounded Answering"]
  node_retrieval["Passage Retrieval<br/>[chatbot.py]"]
  node_context["Context Prompt<br/>[chatbot.py]"]
  node_grounding["Evidence Parsing<br/>[chatbot.py]"]
  node_citations["Page Citations<br/>[chatbot.py]"]
  node_cli["CLI RAG"]
end

subgraph group_knowledge["Knowledge Ingestion"]
  node_faiss[("FAISS Store")]
  node_pdf["Medical Encyclopedia"]
  node_pdf_loader["PDF Extraction"]
  node_chunking["Text Chunking"]
  node_index_build["Index Creation"]
end

subgraph group_integrations["Models and Services"]
  node_groq["Groq Inference"]
  node_embeddings["Sentence Embeddings"]
  node_hf_model["Hugging Face Endpoint"]
end

node_user(("User"))

node_user -->|"asks"| node_streamlit
node_streamlit -->|"retrieves passages"| node_retrieval
node_retrieval -->|"searches index"| node_faiss
node_retrieval -->|"supplies passages"| node_context
node_context -->|"prompts"| node_groq
node_groq -->|"returns response"| node_grounding
node_grounding -->|"selects evidence"| node_citations
node_citations -->|"formats citations"| node_answer
node_grounding -->|"provides answer"| node_answer
node_answer -->|"displays"| node_user
node_pdf -->|"loads pages"| node_pdf_loader
node_pdf_loader -->|"splits text"| node_chunking
node_chunking -->|"embeds chunks"| node_embeddings
node_embeddings -->|"provides vectors"| node_index_build
node_index_build -->|"saves index"| node_faiss
node_cli -->|"loads and searches"| node_faiss
node_cli -->|"invokes"| node_hf_model

click node_streamlit "https://github.com/sanoj-936/medassist/blob/main/chatbot.py"
click node_retrieval "https://github.com/sanoj-936/medassist/blob/main/chatbot.py"
click node_faiss "https://github.com/sanoj-936/medassist/tree/main/vectorstore/db_faiss"
click node_context "https://github.com/sanoj-936/medassist/blob/main/chatbot.py"
click node_grounding "https://github.com/sanoj-936/medassist/blob/main/chatbot.py"
click node_citations "https://github.com/sanoj-936/medassist/blob/main/chatbot.py"
click node_answer "https://github.com/sanoj-936/medassist/blob/main/chatbot.py"
click node_pdf "https://github.com/sanoj-936/medassist/blob/main/The_GALE_ENCYCLOPEDIA_of_MEDICINE_SECOND.pdf"
click node_pdf_loader "https://github.com/sanoj-936/medassist/blob/main/create_memory_for_llm.py"
click node_chunking "https://github.com/sanoj-936/medassist/blob/main/create_memory_for_llm.py"
click node_index_build "https://github.com/sanoj-936/medassist/blob/main/create_memory_for_llm.py"
click node_cli "https://github.com/sanoj-936/medassist/blob/main/connect_memory_with_llm.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_answer,node_user toneBlue
class node_retrieval,node_context,node_grounding,node_citations,node_cli toneAmber
class node_faiss,node_pdf,node_pdf_loader,node_chunking,node_index_build toneMint
class node_groq,node_embeddings,node_hf_model toneRose
```

## Components

### Chat Interface

- [Streamlit Chat](https://github.com/sanoj-936/medassist/blob/main/chatbot.py): `chatbot.py`
- [Rendered Answer](https://github.com/sanoj-936/medassist/blob/main/chatbot.py): `chatbot.py`

### Grounded Answering

- [Passage Retrieval](https://github.com/sanoj-936/medassist/blob/main/chatbot.py): `chatbot.py`
- [Context Prompt](https://github.com/sanoj-936/medassist/blob/main/chatbot.py): `chatbot.py`
- [Evidence Parsing](https://github.com/sanoj-936/medassist/blob/main/chatbot.py): `chatbot.py`
- [Page Citations](https://github.com/sanoj-936/medassist/blob/main/chatbot.py): `chatbot.py`
- [CLI RAG](https://github.com/sanoj-936/medassist/blob/main/connect_memory_with_llm.py): `connect_memory_with_llm.py`

### Knowledge Ingestion

- [FAISS Store](https://github.com/sanoj-936/medassist/tree/main/vectorstore/db_faiss): `vectorstore/db_faiss`
- [Medical Encyclopedia](https://github.com/sanoj-936/medassist/blob/main/The_GALE_ENCYCLOPEDIA_of_MEDICINE_SECOND.pdf): `The_GALE_ENCYCLOPEDIA_of_MEDICINE_SECOND.pdf`
- [PDF Extraction](https://github.com/sanoj-936/medassist/blob/main/create_memory_for_llm.py): `create_memory_for_llm.py`
- [Text Chunking](https://github.com/sanoj-936/medassist/blob/main/create_memory_for_llm.py): `create_memory_for_llm.py`
- [Index Creation](https://github.com/sanoj-936/medassist/blob/main/create_memory_for_llm.py): `create_memory_for_llm.py`

### Models and Services

- **Groq Inference**
- **Sentence Embeddings**
- **Hugging Face Endpoint**

### Other components

- **User**

## Connections

- User → Streamlit Chat: asks (evidence: `README.md`)
- Streamlit Chat → Passage Retrieval: retrieves passages (evidence: `chatbot.py`)
- Passage Retrieval → FAISS Store: searches index (evidence: `README.md`)
- Passage Retrieval → Context Prompt: supplies passages (evidence: `chatbot.py`)
- Context Prompt → Groq Inference: prompts (evidence: `chatbot.py`)
- Groq Inference → Evidence Parsing: returns response (evidence: `chatbot.py`)
- Evidence Parsing → Page Citations: selects evidence (evidence: `chatbot.py`)
- Page Citations → Rendered Answer: formats citations (evidence: `chatbot.py`)
- Evidence Parsing → Rendered Answer: provides answer (evidence: `chatbot.py`)
- Rendered Answer → User: displays (evidence: `README.md`)
- Medical Encyclopedia → PDF Extraction: loads pages (evidence: `README.md`)
- PDF Extraction → Text Chunking: splits text (evidence: `README.md`)
- Text Chunking → Sentence Embeddings: embeds chunks (evidence: `README.md`)
- Sentence Embeddings → Index Creation: provides vectors (evidence: `README.md`)
- Index Creation → FAISS Store: saves index (evidence: `README.md`)
- CLI RAG → FAISS Store: loads and searches (evidence: `connect_memory_with_llm.py`)
- CLI RAG → Hugging Face Endpoint: invokes (evidence: `connect_memory_with_llm.py`)
