# sahumonu/medibot architecture

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

- Interactive diagram: https://gitdiagram.com/sahumonu/medibot
- Repository: https://github.com/sahumonu/medibot

## Overview

MediBot is a medical-information question-answering app grounded in a local PDF knowledge base. Its main workflow is PDF ingestion, chunking and indexing, followed by Streamlit chat, retrieval, and a context-constrained Groq answer with source documents. A separate script offers a terminal-based retrieval-and-answer flow over the same FAISS store. The graph reflects the three supplied scripts; the README is empty, and the repository tree shows no data or vector-store contents.

Main entry points: [`medibot.py`](https://github.com/sahumonu/medibot/blob/main/medibot.py) (App QA chain), [`connect_memory_with_llm.py`](https://github.com/sahumonu/medibot/blob/main/connect_memory_with_llm.py) (Terminal question flow), [`create _memory_for_lim.py`](https://github.com/sahumonu/medibot/blob/main/create%20_memory_for_lim.py) (FAISS index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Knowledge ingestion"]
  node_pdfs["PDF collection"]
  node_ingest["Load and chunk PDFs"]
  node_embed["Create embeddings"]
  node_faiss[("FAISS index")]
end

subgraph group_app["Chat application"]
  node_chat["Streamlit chat and history<br/>[medibot.py]"]
  node_appchain["App QA chain<br/>[medibot.py]"]
  node_appretriever["App retriever<br/>[medibot.py]"]
  node_appprompt["Medical answer prompt<br/>[medibot.py]"]
  node_sources["Source formatting<br/>[medibot.py]"]
end

subgraph group_cli["Terminal Q&amp;A"]
  node_cli["Terminal question flow"]
  node_cliretriever["CLI retriever"]
  node_cliprompt["CLI context prompt"]
end

node_user(("Chat user"))
node_groq["Groq chat model"]
node_climodel["CLI Groq model"]

node_pdfs -->|"loads"| node_ingest
node_ingest -->|"chunks for"| node_embed
node_embed -->|"indexes"| node_faiss
node_user -->|"asks"| node_chat
node_chat -->|"invokes"| node_appchain
node_appchain -->|"uses"| node_appretriever
node_appretriever -->|"searches"| node_faiss
node_appchain -->|"configures with"| node_appprompt
node_appchain -->|"queries"| node_groq
node_appchain -->|"returns answer and sources"| node_chat
node_chat -->|"formats sources"| node_sources
node_chat -->|"displays answer"| node_user
node_user -->|"enters query"| node_cli
node_cli -->|"builds chain with"| node_cliretriever
node_cliretriever -->|"loads and searches"| node_faiss
node_cli -->|"builds chain with"| node_cliprompt
node_cli -->|"configures chain with"| node_climodel
node_cli -->|"prints answer and sources"| node_user

click node_ingest "https://github.com/sahumonu/medibot/blob/main/create%20_memory_for_lim.py"
click node_embed "https://github.com/sahumonu/medibot/blob/main/create%20_memory_for_lim.py"
click node_faiss "https://github.com/sahumonu/medibot/blob/main/create%20_memory_for_lim.py"
click node_chat "https://github.com/sahumonu/medibot/blob/main/medibot.py"
click node_appchain "https://github.com/sahumonu/medibot/blob/main/medibot.py"
click node_appretriever "https://github.com/sahumonu/medibot/blob/main/medibot.py"
click node_appprompt "https://github.com/sahumonu/medibot/blob/main/medibot.py"
click node_sources "https://github.com/sahumonu/medibot/blob/main/medibot.py"
click node_cli "https://github.com/sahumonu/medibot/blob/main/connect_memory_with_llm.py"
click node_cliretriever "https://github.com/sahumonu/medibot/blob/main/connect_memory_with_llm.py"
click node_cliprompt "https://github.com/sahumonu/medibot/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_pdfs,node_ingest,node_embed,node_faiss,node_user toneBlue
class node_chat,node_appchain,node_appretriever,node_appprompt,node_sources toneAmber
class node_cli,node_cliretriever,node_cliprompt toneMint
class node_groq,node_climodel toneIndigo
```

## Components

### Knowledge ingestion

- **PDF collection**
- [Load and chunk PDFs](https://github.com/sahumonu/medibot/blob/main/create%20_memory_for_lim.py): `create _memory_for_lim.py`
- [Create embeddings](https://github.com/sahumonu/medibot/blob/main/create%20_memory_for_lim.py): `create _memory_for_lim.py`
- [FAISS index](https://github.com/sahumonu/medibot/blob/main/create%20_memory_for_lim.py): `create _memory_for_lim.py`

### Chat application

- [Streamlit chat and history](https://github.com/sahumonu/medibot/blob/main/medibot.py): `medibot.py`
- [App QA chain](https://github.com/sahumonu/medibot/blob/main/medibot.py): `medibot.py`
- [App retriever](https://github.com/sahumonu/medibot/blob/main/medibot.py): `medibot.py`
- [Medical answer prompt](https://github.com/sahumonu/medibot/blob/main/medibot.py): `medibot.py`
- [Source formatting](https://github.com/sahumonu/medibot/blob/main/medibot.py): `medibot.py`

### Terminal Q&A

- [Terminal question flow](https://github.com/sahumonu/medibot/blob/main/connect_memory_with_llm.py): `connect_memory_with_llm.py`
- [CLI retriever](https://github.com/sahumonu/medibot/blob/main/connect_memory_with_llm.py): `connect_memory_with_llm.py`
- [CLI context prompt](https://github.com/sahumonu/medibot/blob/main/connect_memory_with_llm.py): `connect_memory_with_llm.py`

### Other components

- **Chat user**
- **Groq chat model**
- **CLI Groq model**

## Connections

- PDF collection → Load and chunk PDFs: loads (evidence: `create _memory_for_lim.py`)
- Load and chunk PDFs → Create embeddings: chunks for (evidence: `create _memory_for_lim.py`)
- Create embeddings → FAISS index: indexes (evidence: `create _memory_for_lim.py`)
- Chat user → Streamlit chat and history: asks (evidence: `medibot.py`)
- Streamlit chat and history → App QA chain: invokes (evidence: `medibot.py`)
- App QA chain → App retriever: uses (evidence: `medibot.py`)
- App retriever → FAISS index: searches (evidence: `medibot.py`)
- App QA chain → Medical answer prompt: configures with (evidence: `medibot.py`)
- App QA chain → Groq chat model: queries (evidence: `medibot.py`)
- App QA chain → Streamlit chat and history: returns answer and sources (evidence: `medibot.py`)
- Streamlit chat and history → Source formatting: formats sources (evidence: `medibot.py`)
- Streamlit chat and history → Chat user: displays answer (evidence: `medibot.py`)
- Chat user → Terminal question flow: enters query (evidence: `connect_memory_with_llm.py`)
- Terminal question flow → CLI retriever: builds chain with (evidence: `connect_memory_with_llm.py`)
- CLI retriever → FAISS index: loads and searches (evidence: `connect_memory_with_llm.py`)
- Terminal question flow → CLI context prompt: builds chain with (evidence: `connect_memory_with_llm.py`)
- Terminal question flow → CLI Groq model: configures chain with (evidence: `connect_memory_with_llm.py`)
- Terminal question flow → Chat user: prints answer and sources (evidence: `connect_memory_with_llm.py`)
