# ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot architecture

> Architecture diagram of the GitHub repository ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot
- Repository: https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot

## Overview

##### Project Type and Purpose
- This is a full-stack IoT + mobile + ML system for healthcare monitoring and assistance.
- Key parts:
- Smart Band (IoT device) that gathers vitals via sensors and pushes them to a database.
- Mobile Application (Android, Java) serving two portals (patient & doctor), displaying vitals, history, scheduling, chat.
- Chatbot Service (BioGPT-PubMedQA Prefix-Tuned) for medical Q&A, deployed on Hugging Face and consumed via REST API.
- Backend API layer (PHP + MySQL) that exposes endpoints for authentication, CRUD on vitals, symptoms, schedules, chat logs.
- Offline ML-fine-tuning pipeline (Python, PyTorch, PEFT, LoRA) producing the deployed model.

##### Major Components
- Smart Band Hardware
- Sensors: Max30100, LM35, BMP180, TFT screen
- Microcontroller: Arduino Nano + ESP8266 Wi-Fi
- Firmware: .ino files, Proteus simulation
- Backend Server
- PHP scripts (conn.php, login.php, add.php, get.php, etc.)
- MySQL Database (Database.sql)
- Mobile Application
- Android Studio project (Java, XML layouts, Gradle)
- Architecture: MVVM (LiveData, ViewModel)
- Networking: OkHttp, Volley
- UI modules: sign/login, doctor portal, patient portal, chat, scheduling, history, settings
- Chatbot Service
- Hosted BioGPT-Finetuned model on Hugging Face Inference API
- REST endpoint with authorization header
- ML Fine-Tuning Pipeline (offline)
- Jupyter Notebook (.ipynb) for prefix tuning on PubMedQA dataset
- PyTorch + Transformers + PEFT + LoRA
- TPU execution, produces final model artifact

##### Relationships & Data Flows
- Smart Band → (HTTPS/MQTT) → PHP API → MySQL → reads/writes vitals
- Mobile App
- Fetches vitals, symptoms, schedules via PHP API → MySQL
- Sends new symptoms, schedule requests → PHP API
- Calls Hugging Face Chatbot API → receives generated responses
- Doctor & Patient portals are two client-side modules interacting with the same backend & chatbot API.
- Offline ML pipeline is decoupled; its output (model) is published to HF and consumed by the mobile app at runtime.

##### Architectural Patterns & Design Principles
- Client-Server: mobile app as client, PHP server as monolith.
- MVVM on Android: separation of UI, business logic, data via ViewModel & LiveData.
- Sensor-to-DB ingestion: IoT edge device pushing metrics in real time.
- External Service Integration: Hugging Face API as third-party ML microservice.
- Modularization: separate PHP scripts per resource; separate Activity/Adapter classes per feature.

##### Essentials Checklist
- Callouts for major frameworks/technologies: Arduino IDE, Android Studio, Volley/OkHttp, PHP, MySQL, PyTorch, Transformers

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Hardware Layer
    subgraph "Smart Band" 
        direction TB
        sensors["Sensors\n(Max30100, LM35, BMP180, TFT)"]:::hardware
        micro["Arduino Nano + ESP8266"]:::hardware
        firmware["Firmware Code"]:::hardware
        schematic["Circuit Schematic"]:::hardware
    end

    %% Backend Layer
    subgraph "API Server (PHP + MySQL)"
        direction TB
        subgraph "PHP Scripts"
            direction TB
            auth["Authentication & Registration\n(conn.php, login.php,\nD_register.php, P_register.php)"]:::backend
            vitals["Vitals & Symptoms CRUD\n(add.php, Add_Symptoms.php,\nget.php, getsym.php)"]:::backend
            schedules["Schedule & History Endpoints\n(getfsch.php, getfschdoc.php,\ngethis.php, getphis.php,\ngetphomevitals.php)"]:::backend
            chatLogs["Chat Logs Endpoint\n(gettext.php)"]:::backend
            password["Password Management\n(confirm_info_for_new_password.php,\nupdate_password.php)"]:::backend
            deleter["Deletion Endpoint\n(deleter.php)"]:::backend
            dbConnect["DB Connection\n(dbConnect.php)"]:::backend
        end
        mysql[(MySQL Database)]:::database
    end

    %% Frontend Layer
    subgraph "Mobile App (Android MVVM)" 
        direction TB
        subgraph "Build & Config"
            direction TB
            gradle["Gradle Config\n(build.gradle,\nsettings.gradle,\ngradle.properties,\nproguard-rules.pro)"]:::frontend
            manifest["AndroidManifest.xml"]:::frontend
        end
        subgraph "MVVM & Networking"
            direction TB
            config["Config.java"]:::frontend
            request["RequestHandler.java"]:::frontend
            singleton["MySingleton.java"]:::frontend
            background["Background Services & Receivers\n(MyBackgroundService.java,\nMyBroadcastReceiver.java,\nDatabaseReceiver.java,\nDatabaseService.java)"]:::frontend
        end
        subgraph "Patient Portal"
            direction TB
            patientUI["Activities & UI\n(HomepActivity.java,\nHistorypActivity.java,\nCalenderpActivity.java,\nMapActivity.java,\nMeetingpActivity.java,\nSettingpActivity.java,\nSymptomsActivity.java)"]:::frontend
            patientChat["Chat Module\n(ChatpActivity.java,\nMessageModel.java,\nMessageModelAdapter.java)"]:::frontend
        end
        subgraph "Doctor Portal"
            direction TB
            doctorUI["Activities & UI\n(HomeActivity.java,\nProfileActivity.java,\nHistorydoctor/*,\nSymptomsdoctor/*,\nFScheduleDoc/*,\nTextEmergancy/*,\nVideoActivity.java,\nschedule/*)"]:::frontend
            doctorChat["Chat Module\n(ChatActivity.java,\nMessage.java,\nMessageAdapter.java)"]:::frontend
        end
        subgraph "Auth & Onboarding"
            direction TB
            authMobile["Sign/Login Flow\n(MainActivity.java,\nSignUp.java,\nConfirm_OTP.java,\nNewPassword.java,\nD_Sign_Up.java,\nF_P.java,\nPopUp.java)"]:::frontend
        end
    end

    %% External & Offline ML Layers
    chatbot["BioGPT Chatbot Service\n(Hugging Face REST API)"]:::external
    pipeline["Offline ML Fine-Tuning Pipeline\n(PyTorch, PEFT, LoRA)"]:::offline

    %% Connections
    sensors -->|"ESP8266 Wi-Fi\n(HTTPS/MQTT)"| auth
    micro -->|"HTTPS/MQTT"| auth
    firmware --> auth
    schematic --> auth

    auth -->|"MySQL JDBC"| mysql
    vitals -->|"MySQL JDBC"| mysql
    schedules -->|"MySQL JDBC"| mysql
    chatLogs -->|"MySQL JDBC"| mysql
    password -->|"MySQL JDBC"| mysql
    deleter -->|"MySQL JDBC"| mysql
    dbConnect -->|"MySQL JDBC"| mysql

    gradle --> config
    manifest --> config

    config --> request
    request --> singleton
    singleton --> background

    background --> auth
    patientUI --> auth
    doctorUI --> auth

    patientUI --> patientChat
    doctorUI --> doctorChat

    patientChat -->|"HTTPS REST"| chatbot
    doctorChat -->|"HTTPS REST"| chatbot

    pipeline -->|"Model Deployment"| chatbot

    %% Click Events
    click firmware "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/Smart Band/all_code.ino"
    click schematic "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/Smart Band/schematic circuit.pdsprj"
    click auth "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/tree/main/Mobile Application - HealTech/connection"
    click vitals "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/tree/main/Mobile Application - HealTech/connection"
    click schedules "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/tree/main/Mobile Application - HealTech/connection"
    click chatLogs "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/tree/main/Mobile Application - HealTech/connection"
    click password "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/tree/main/Mobile Application - HealTech/connection"
    click deleter "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/tree/main/Mobile Application - HealTech/connection"
    click dbConnect "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/Mobile Application - HealTech/connection/dbConnect.php"
    click mysql "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/Mobile Application - HealTech/Database.sql"
    click gradle "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/Mobile Application - HealTech/HealTech/build.gradle"
    click manifest "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/AndroidManifest.xml"
    click config "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/java/com/example/app_login/dbconnection/Config.java"
    click request "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/java/com/example/app_login/dbconnection/RequestHandler.java"
    click singleton "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/java/com/example/app_login/MySingleton.java"
    click background "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/java/com/example/app_login/MyBackgroundService.java"
    click patientUI "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/java/com/example/app_login/patient/patient/HomepActivity.java"
    click patientChat "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/java/com/example/app_login/patient/patient/finetuned_model/ChatpActivity.java"
    click doctorUI "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/java/com/example/app_login/doctor/doctor/HomeActivity.java"
    click doctorChat "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/java/com/example/app_login/doctor/doctor/ChatGpt/ChatActivity.java"
    click authMobile "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/app/src/main/java/com/example/app_login/signlogin/MainActivity.java"
    click pipeline "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/BioGPT-PubMedQA-Prefix-Tuning - ChatBot/biogpt-pubmedqa-prefix-tuning-lora.ipynb"
    click pipeline "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/BioGPT-PubMedQA-Prefix-Tuning - ChatBot/Raw Datasets/pubmed_qa.py"
    click pipeline "https://github.com/ridhibrata-das/ai-based-healthcare-monitoring-system-using-iot/blob/main/BioGPT-PubMedQA-Prefix-Tuning - ChatBot/README.md"

    %% Styles
    classDef hardware fill:#9f6,stroke:#393,stroke-width:1px
    classDef backend fill:#6cf,stroke:#36a,stroke-width:1px
    classDef database fill:#ccf,stroke:#66c,stroke-width:1px,shape:cylinder
    classDef frontend fill:#f96,stroke:#d65,stroke-width:1px
    classDef external fill:#c9f,stroke:#84c,stroke-width:1px
    classDef offline fill:#ccc,stroke:#888,stroke-width:1px
```
