Published April 6, 2026 | Version v1.0.0

DvdRivas/DrChatPatin: DrChatPatin

Authors/Creators

Description

DrChatPatin

A Decentralized AI-Powered Medical Assistant for Rare Disease Diagnosis on the Internet Computer Protocol

Abstract

DrChatPatin is a decentralized application (dApp) designed to assist healthcare professionals and patients in the preliminary diagnosis of rare diseases, following diagnostic criteria aligned with the U.S. Food and Drug Administration (FDA) standards. The system operates entirely on the Internet Computer Protocol (ICP), ensuring data immutability, censorship resistance, and persistent conversation storage through on-chain canister smart contracts. The frontend and backend components are co-deployed on the ICP network, eliminating reliance on centralized cloud infrastructure.

Overview

Rare diseases affect a disproportionately small patient population, which historically has led to limited diagnostic tooling and clinical decision support. DrChatPatin addresses this gap by providing an AI-assisted conversational interface capable of guiding diagnostic reasoning according to established FDA rare disease classifications.

Key properties of the system:

  • Decentralized execution: Both the user interface and conversation storage logic are deployed as ICP canisters, ensuring no single point of failure.
  • Persistent conversation history: Patient-provider interactions are encrypted, stored immutably on-chain via the backend canister.
  • External AI integration: A dedicated API layer connects the application to an external AI model, enabling intelligent diagnostic responses.
  • Voice interaction support: The application supports speech-to-text input, improving accessibility in clinical environments.
  • Secure rendering: AI responses are rendered as sanitized Markdown to prevent injection vulnerabilities.
  • Internet Identity integration via NFID: User authentication is handled by NFID (Identity Provider), providing pseudonymous, cryptographically secure login.

System Architecture

The application follows a three-layer architecture deployed on the Internet Computer mainnet:

The frontend canister serves the React-based user interface as static assets. The backend canister, written in Motoko, manages conversation state and persistent storage. The API layer handles communication with an external AI model responsible for generating diagnostic responses.

API

DrChatPatin includes a dedicated API layer that serves as the bridge between the ICP Canisters and the external AI diagnostic engine. This module is responsible for forwarding user queries, receiving model responses, and returning structured data to the frontend for rendering.

Responsibilities

  • Receive conversation context
  • Extract information from RAG (if enabled)
  • Process model response (local or third party API uses)
  • Parse and return AI-generated responses to the frontend

Configuration

API credentials and endpoint URLs can be managed via environment variables. Before running the project locally, ensure the following variables are defined in your .env file:

# AI model endpoint
AI_API_URL=<your_api_endpoint>

# API authentication key
AI_API_KEY=<your_api_key>

Technology Stack

Web3 / Frontend

Layer Technology Version
Frontend Framework React + JavaScript —
Styling SCSS + Material UI (MUI) MUI v6.4.x
Markdown Rendering marked v15.0.x
HTML Sanitization DOMPurify v3.2.x
Voice Input react-speech-recognition v4.0.x
Voice Input (hook) react-hook-speech-to-text v0.8.x

Web3 / Blockchain

Layer Technology Version
Smart Contract Language Motoko Base 0.13.7
Blockchain Platform Internet Computer Protocol (ICP) DFX 0.25.1
Package Manager (Motoko) MOPS 0.9.1
Authentication NFID Remote canister

Web2 / API

Layer Technology Version
Language Runtime Python 3.10.12
API Framework FastAPI 0.129.0
LLM SDK OpenAI SDK 0.20.0
Transformers transformers 4.51.0
Milvus Lite pymilvus 2.5.6
Cryptography cryptography 44.0.1

AI / ML Stack

Layer Technology Version
Deep Learning (Primary) PyTorch 2.6.0
Tensor Library NumPy 1.24.0
Alternative DL Framework TensorFlow 2.16.1
Embeddings / NLP sentence-transformers 4.1.0

Runtime & Tooling

Layer Technology Version
JavaScript Runtime Node.js 22.14.0
Package Manager npm ≥ 7.0.0
OS (Recommended) Ubuntu ≥ 22.04

Deployed Canisters

The application is live on the ICP mainnet. The following canister identifiers correspond to the production deployment:

Canister ID Network
DrChatPatin_backend z552i-qaaaa-aaaad-qhqaq-cai ic (mainnet)
DrChatPatin_frontend zu6ru-giaaa-aaaad-qhqba-cai ic (mainnet)

The live frontend is accessible at:

https://zu6ru-giaaa-aaaad-qhqba-cai.icp0.io

Repository Structure

DrChatPatin/
├── src/
│   ├── DrChatPatin_backend/
│   │   └── main.mo                  # Motoko backend canister (conversation logic & storage)
│   └── DrChatPatin_frontend/
│       └── dist/                    # Compiled frontend assets (served by asset canister)
├── canister_ids.json                # Mainnet canister IDs
├── dfx.json                         # DFX canister configuration
├── mops.toml                        # Motoko package dependencies
├── package.json                     # Node.js workspace configuration
├── package-lock.json
├── tsconfig.json                    
├── README.md
API/
├── API_DrChatPatin.py
└── README.md

Prerequisites

Before setting up the project locally, ensure the following tools are installed:

Local Development Setup

1. Clone the repository

git clone https://github.com/DvdRivas/DrChatPatin.git
cd DrChatPatin

2. Install Node.js dependencies

npm install

3. Configure environment variables

Create a .env file in the project root and add the required API credentials:

cp .env.example .env
# Edit .env with your API endpoint and key

4. Start the local ICP replica

dfx start --background

5. Deploy canisters to the local replica

dfx deploy

Once deployment completes, the application will be available at:

http://localhost:4943?canisterId={asset_canister_id}

6. Start the frontend development server (optional)

# Regenerate Candid declarations (recommended before starting)
npm run generate

# Start the development server
npm start

The development server runs at http://localhost:8080 and proxies all canister API requests to the local replica at port 4943.

Production Deployment

To deploy to the ICP mainnet:

dfx deploy --network ic

Available Scripts

from DrChatPatin_frontend/src/ directory

Script Command Description
Start dev server npm start Starts the Webpack development server at port 8080
Build npm run build Compiles frontend assets for production
Pre-build npm run prebuild Runs workspace pre-build hooks
Generate declarations npm run generate Regenerates Candid interface declarations from deployed canisters
Test npm test Runs the test suite across all workspaces
DFX help dfx help Displays DFX SDK command reference
Canister help dfx canister --help Displays canister management commands

Environment Configuration

API credentials and endpoint URLs can be managed via environment variables. Before running the project locally, ensure the following variables are defined in your .env file:

# AI model endpoint
AI_API_URL=<your_api_endpoint>

# API authentication key
AI_API_KEY=<your_api_key>

Motoko Dependencies

Backend canister dependencies are managed via MOPS and declared in mops.toml:

Package Version Purpose
base 0.13.7 Motoko standard library (data structures, primitives)
map 9.0.1 High-performance hash map implementation for on-chain storage

References

Repository maintained by DvdRivas. Deployed on the Internet Computer mainnet.

Files

DvdRivas/DrChatPatin-v1.0.0.zip

Files (2.5 MB)

Name Size
md5:ce723cc1d5e5831c94140f8c3f1fbe02
2.5 MB Preview Download

Additional details

Related works