# ronitpatil/healthcarechatbot architecture

> Architecture diagram of the GitHub repository ronitpatil/healthcarechatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ronitpatil/healthcarechatbot
- Repository: https://github.com/ronitpatil/healthcarechatbot

## Overview

##### Project Type and Purpose
- This is a full-stack, AI-powered healthcare data mining application. Its main goal is to process and retrieve accurate, timely healthcare information by directly interfacing with multiple Large Language Models (LLMs) via a Streamlit-based UI.
- The system integrates several LLMs (like OpenAI, Claude, Gemini, Mistral, and LLama2), uses web scraping (via Beautiful Soup and requests) to gather healthcare data, and evaluates responses using Trulens.

##### Analyzing the File Structure
- Top-Level Files and Directories:
– OpenAI.py: Likely acts as the main Streamlit entry point.
– README.md: Provides a high-level overview, architecture description, and setup instructions.
– pages/: Contains individual modules (Claude.py, Gemini.py, History_Aware_Retriever_Chain.py, Langchain_Agent.py, Retriever_Chain.py) which likely represent different LLM integrations or specific query chains.
– utils/: Provides supportive functions to create chains (create_chains.py), load healthcare data (data_loader.py, load_healthcare_data.py), and initialize the underlying vector store (initialize_vector_store.py).
– requirements.txt: Lists all the dependencies needed to run the project.
- Architectural Hint:
– The separation into “pages” and “utils” indicates a clear separation of concerns: the UI/interaction layer versus underlying data processing and logic.

##### Core Components to Highlight
a. Frontend/UI Layer:
– Streamlit Interface: Represents the entry point where users input queries, upload files, and view responses.
b. LLM Integration Modules (in the pages/ folder):
– Each script (e.g., OpenAI.py, Claude.py, Gemini.py) forms a distinct module responsible for handling communication with a particular LLM.
c. Data Processing and Chain Creation (in the utils/ folder):
– Utility modules such as create_chains.py, data_loader.py, initialize_vector_store.py, and load_healthcare_data.py handle backend processing like data pre-processing, chain creation, and vector store management.
– Label these as “Chain/Process Utilities” or “Backend Services.”
d. External Services:
– LLM APIs: Represent external connections to services such as OpenAI’s API, Claude, Gemini, and others.
– Data Sources: Represent healthcare websites (e.g., WebMD, Mayo Clinic) used for web scraping, and even the evaluation component using Trulens.

##### Relationships and Interactions
- How user queries flow from the Streamlit UI to the respective LLM integration modules.
- If relevant, indicate feedback paths from the evaluation engine (Trulens) back into the processing pipelines for adjustment or analysis.

##### Architectural Patterns and Technologies
- The system follows a modular design separating the presentation layer (UI), business logic (LLM integrations and chain operations), and data processing (utils for data loading and vector store initialization).
- Design principles like separation of concerns and the use of micro-modules for each LLM integration.
- Key technologies: Python, Streamlit, Beautiful Soup, Requests, and Trulens.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        UI["Streamlit UI (Frontend)"]:::frontend
    end

    %% LLM Integration Modules
    subgraph "LLM Integration Modules"
        CLAUDE["Integration – Claude"]:::integration
        GEMINI["Integration – Gemini"]:::integration
        HARC["Integration – History Aware Retriever Chain"]:::integration
        LANGCHAIN["Integration – Langchain Agent"]:::integration
        RETRIEVER["Integration – Retriever Chain"]:::integration
    end

    %% Backend Services
    subgraph "Backend Services"
        UTIL["Chain/Process Utilities"]:::backend
        DATA["Data Loading (Healthcare Data)"]:::backend
        VECTOR["Vector Store Initialization"]:::backend
    end

    %% External Services
    subgraph "External Services"
        API_OPENAI["LLM API – OpenAI"]:::external
        API_CLAUDE["LLM API – Claude"]:::external
        API_GEMINI["LLM API – Gemini"]:::external
        WEBSOURCES["Web Data Sources"]:::external
        TRUELENS["Evaluation Engine: Trulens"]:::external
    end

    %% Interactions from UI to Integration Modules
    UI -->|"sendsQuery"| CLAUDE
    UI -->|"sendsQuery"| GEMINI
    UI -->|"sendsQuery"| HARC
    UI -->|"sendsQuery"| LANGCHAIN
    UI -->|"sendsQuery"| RETRIEVER

    %% Integration Modules calling Backend Utilities
    CLAUDE -->|"chainInteraction"| UTIL
    GEMINI -->|"chainInteraction"| UTIL
    HARC -->|"chainInteraction"| UTIL
    LANGCHAIN -->|"chainInteraction"| UTIL
    RETRIEVER -->|"chainInteraction"| UTIL

    %% Direct External API calls from UI and Integration Modules
    UI -->|"callsAPI"| API_OPENAI
    CLAUDE -->|"callsAPI"| API_CLAUDE
    GEMINI -->|"callsAPI"| API_GEMINI

    %% Backend Utilities interactions with Data and Vector Store
    UTIL -->|"loadsData"| DATA
    UTIL -->|"initStore"| VECTOR

    %% Backend Utilities accessing External Data Sources and Evaluation Engine
    UTIL -->|"retrievesData"| WEBSOURCES
    UTIL -->|"evaluationFeedback"| TRUELENS

    %% Click Events
    click UI "https://github.com/ronitpatil/healthcarechatbot/blob/main/OpenAI.py"
    click CLAUDE "https://github.com/ronitpatil/healthcarechatbot/blob/main/pages/Claude.py"
    click GEMINI "https://github.com/ronitpatil/healthcarechatbot/blob/main/pages/Gemini.py"
    click HARC "https://github.com/ronitpatil/healthcarechatbot/blob/main/pages/History_Aware_Retriever_Chain.py"
    click LANGCHAIN "https://github.com/ronitpatil/healthcarechatbot/blob/main/pages/Langchain_Agent.py"
    click RETRIEVER "https://github.com/ronitpatil/healthcarechatbot/blob/main/pages/Retriever_Chain.py"
    click UTIL "https://github.com/ronitpatil/healthcarechatbot/blob/main/utils/create_chains.py"
    click DATA "https://github.com/ronitpatil/healthcarechatbot/blob/main/utils/data_loader.py"
    click DATA "https://github.com/ronitpatil/healthcarechatbot/blob/main/utils/load_healthcare_data.py"
    click VECTOR "https://github.com/ronitpatil/healthcarechatbot/blob/main/utils/initialize_vector_store.py"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef integration fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
