# amberkakkar01/health-care-chatbot architecture

> Architecture diagram of the GitHub repository amberkakkar01/health-care-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amberkakkar01/health-care-chatbot
- Repository: https://github.com/amberkakkar01/health-care-chatbot

## Overview

##### Project type and purpose
- This is a Python-based healthcare FAQ chatbot, combining a rule-based “if/then” engine with an ML intent-classification model.
- Purpose: serve 24/7 automated answers to health-related FAQs via a simple GUI or console interface.

##### File structure
Top-level files and directories:
- Data_Analysis.ipynb – exploratory data analysis (EDA) on heart-disease.csv
- heart-disease.csv – raw dataset used for EDA/training
- intents.json – rule-based intents + responses
- classes.pkl & words.pkl – tokenization / label encoders for the model
- chatbotmodel.h5 & chatbot_model.model/… – persisted TensorFlow/Keras classification model
- training_py.py – script that reads intents.json, heart-disease.csv, builds vocabulary, trains the model, saves .h5/.pb
- chatbot_py.py – main chatbot server logic: loads model, classes, words, handles user input
- gui.py – optional front-end layer (Tkinter or PyQt) for desktop GUI
- MedBot_Working_Model.rar – packaged version of the trained model for distribution
- chat.txt – sample conversation logs
- LICENSE & README.md

##### README insights
- Emphasizes rule-based keyword flows + well-defined “if/then” logic
- No external cloud microservices—entirely local, Python-driven

##### Don’t overthink—be exhaustive
- Break the system into all discrete pieces:
- Jupyter Notebook (EDA)
- Training Script
- Model Files
- Tokenizers
- Intent Definitions
- Chatbot Runtime Engine
- UI Layer
- Logs

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Offline Training Pipeline
    subgraph "Offline Training Pipeline"
        direction TB
        EDA["Data_Analysis.ipynb"]:::offline
        RawData["heart-disease.csv"]:::data
        IntentsDef["intents.json"]:::data
        TrainScript["training_py.py"]:::offline
        ModelH5["chatbotmodel.h5"]:::artifact
        SavedModel["chatbot_model.model/"]:::artifact
        Tokenizers["words.pkl & classes.pkl"]:::artifact
        Archive["MedBot_Working_Model.rar"]:::artifact
        EDA -->|runs on| TrainScript
        RawData -->|feeds into| TrainScript
        IntentsDef -->|feeds into| TrainScript
        TrainScript -->|produces| ModelH5
        TrainScript -->|produces| SavedModel
        TrainScript -->|produces| Tokenizers
        TrainScript -->|packages| Archive
    end

    %% Runtime Inference Pipeline
    subgraph "Runtime Inference Pipeline"
        direction TB
        %% UI Layer
        subgraph "UI Layer"
            direction TB
            CLI["CLI Interface\n(chatbot_py.py)"]:::ui
            GUI["GUI Interface\n(gui.py)"]:::ui
        end

        %% Engine Layer
        subgraph "Chatbot Engine"
            direction TB
            Preproc["Input Preprocessor\n(tokenization & encoding)"]:::engine
            Classifier["Intent Classifier"]:::engine
            RuleEngine["Rule-based Response Selector"]:::engine
        end

        %% Data Layer
        subgraph "Data & Artifacts"
            direction TB
            Pkl["words.pkl & classes.pkl"]:::data
            ModelFile["chatbotmodel.h5"]:::data
            SavedDir["saved_model.pb & variables/"]:::data
            IntentsRuntime["intents.json"]:::data
        end

        %% Logging
        Log["chat.txt"]:::data

        %% Runtime flow
        User(["User"]):::external
        User -->|sends message| CLI
        User -->|sends message| GUI
        CLI -->|user message| Preproc
        GUI -->|user message| Preproc
        Preproc -->|token vector| Classifier
        Classifier -->|predicted intent| RuleEngine
        RuleEngine -->|response text| CLI
        RuleEngine -->|response text| GUI
        RuleEngine -->|logs conversation| Log
        %% Data loading
        Preproc -->|loads tokenizer| Pkl
        Classifier -->|loads model| ModelFile
        Classifier -->|loads model| SavedDir
        RuleEngine -->|loads rules| IntentsRuntime
    end

    %% Project Documentation
    subgraph "Project Documentation"
        direction TB
        Docs1["README.md"]:::doc
        Docs2["LICENSE"]:::doc
    end

    %% Click Events
    click CLI "https://github.com/amberkakkar01/health-care-chatbot/blob/main/chatbot_py.py"
    click GUI "https://github.com/amberkakkar01/health-care-chatbot/blob/main/gui.py"
    click Preproc "https://github.com/amberkakkar01/health-care-chatbot/blob/main/words.pkl"
    click Preproc "https://github.com/amberkakkar01/health-care-chatbot/blob/main/classes.pkl"
    click Classifier "https://github.com/amberkakkar01/health-care-chatbot/blob/main/chatbotmodel.h5"
    click Classifier "https://github.com/amberkakkar01/health-care-chatbot/tree/main/chatbot_model.model/"
    click RuleEngine "https://github.com/amberkakkar01/health-care-chatbot/blob/main/intents.json"
    click RawData "https://github.com/amberkakkar01/health-care-chatbot/blob/main/heart-disease.csv"
    click EDA "https://github.com/amberkakkar01/health-care-chatbot/blob/main/Data_Analysis.ipynb"
    click TrainScript "https://github.com/amberkakkar01/health-care-chatbot/blob/main/training_py.py"
    click Log "https://github.com/amberkakkar01/health-care-chatbot/blob/main/chat.txt"
    click Archive "https://github.com/amberkakkar01/health-care-chatbot/blob/main/MedBot_Working_Model.rar"
    click Docs1 "https://github.com/amberkakkar01/health-care-chatbot/blob/main/README.md"
    click Docs2 "https://github.com/amberkakkar01/health-care-chatbot/tree/main/LICENSE"

    %% Styles
    classDef ui fill:#D0E7FF,stroke:#0284C7,color:#03045E
    classDef engine fill:#E2F0D9,stroke:#2E8B57,color:#006400
    classDef data fill:#FFE4B5,stroke:#D2691E,color:#8B4513
    classDef artifact fill:#FFE4B5,stroke:#D2691E,color:#8B4513
    classDef offline fill:#F0F0F0,stroke:#A9A9A9,color:#696969
    classDef doc fill:#FFF5BA,stroke:#DAA520,color:#8B7500
    classDef external fill:#FFFFFF,stroke:#000000,color:#000000
```
