+--------------------+ +--------------------------+ +--------------------------+
| User | | Chatbot Interface | | Backend Application |
| (Healthcare Staff) | | (Frontend) | | (API) |
+---------+----------+ +------------+-------------+ +-----------+--------------+
| | |
| Send question (e.g., patient X)| |
+------------------------------->| |
| Send user question |
+----------------------------+ |
v
+-------------------------------+ |
| Embedding Model (Local) | |
+-------------------------------+ |
| Convert to Query Embedding |
| Return Query Vector |
+---------------+---------------+ |
| |
v |
+-------------------------------------+ |
| Vector Database (Local) | |
+-------------------------------------+ |
| Search for similar chunks | |
| Return relevant chunks (context) | |
+-------------------------------------+ |
| |
v |
+-------------------------------+ |
| Local LLM (e.g., Mistral 7B) | |
+-------------------------------+ |
| Generate SQL Query using | |
| question + retrieved context | |
+-------------------------------+ |
| |
v |
+------------------------+ |
| Main Database (Postgre)|<-----+
| Execute SQL |
+-----------+------------+
|
v
+-------------------------------+
| Return SQL Result |
+-------------------------------+
|
v
+--------------------+ +--------------------------+ |
| User |<-------+ Chatbot Interface |<--+
| (Healthcare Staff) | | (Frontend) |
+--------------------+ +--------------------------+
Create flowchart
requirement: graph style to easily see blocks.
Assistant
Below is a Mermaid flowchart diagram that represents the system flow. You can copy and paste this into your favorite Mermaid live editor (or tools that support Mermaid) to visualize it.
flowchart TD
%% Define Nodes
A[Healthcare Staff<br>(User)]
B[Chatbot Interface<br>(Frontend)]
C[Backend Application<br>(API)]
D[Embedding Model<br>(Local)]
E[Vector Database<br>(Local)]
F[Local LLM<br>(e.g., Mistral 7B)]
G[Main Database<br>(PostgreSQL)]
H[SQL Result]
%% Define connections between nodes
A -->|Sends question<br>(e.g., patient X)| B
B -->|Send user question| C
subgraph BackendProcessing [Backend Processing]
C --> D
D -->|Convert to Query Embedding<br>Return Query Vector| E
E -->|Search for similar chunks<br>Return relevant context| F
F -->|Generate SQL Query using<br>question + context| G
G -->|Execute SQL| H
end
H -->|Return SQL Result| B
B -->|Display result| A
Flow Explanation
Healthcare Staff (User) sends a question (e.g., regarding patient X) to the Chatbot Interface (Frontend).
The Chatbot Interface passes the question to the Backend Application (API).
The Embedding Model (Local) converts the question into a query embedding vector.
The Vector Database (Local) searches using the embedding to find similar content chunks (context).
The Local LLM (e.g., Mistral 7B) uses both the original question and the retrieved context to generate an appropriate SQL query.
The SQL query is executed on the Main Database (PostgreSQL).
The resultant data is returned as an SQL result, which flows back to the Chatbot Interface and then to the Healthcare Staff (User).
This diagram uses a graph style that clearly shows the blocks and their interactions.