MedHub: Decentralized Healthcare Management System

Inspiration

Traditional healthcare data management systems often fall short in terms of security, privacy, and data ownership. MedHub was inspired by the need for a more secure, decentralized solution that leverages blockchain technology to improve healthcare data management, ensuring that sensitive medical information remains private, verifiable, and accessible only to authorized users.

What it does

MedHub is a decentralized hospital management platform where users can register as patients or doctors:

  • Patients can securely upload their medical records, book appointments, receive prescriptions, and shop for medications.
  • Doctors can access authorized patient records, provide medical advice, and communicate with patients.

Here is a snapshot of user information.

Demo user

Additionally, MedHub offers:

  • A marketplace for patients to purchase medications.
  • A chat feature for doctor-patient communication.
  • An AI assistant for healthcare-related queries.

By using blockchain and IPFS for storage, MedHub ensures that medical data is stored securely and remains immutable.

How we built it

Frontend: Next.js and CSS

The frontend is developed using Next.js, with CSS for styling, resulting in a fast, responsive, and user-friendly interface.

Backend: Solidity Smart Contracts

The backend is powered by Solidity smart contracts deployed on the BTTC network. These contracts manage user roles (patient, doctor, admin) and enable secure interactions, such as data access, file storage, and payment transactions.

Decentralized File Storage with Pinata and IPFS

We used Pinata’s API to upload files and metadata to IPFS, allowing data to be decentralized and immutable. Below is an example of how files and metadata are stored:

IPFS Image Upload Function

export const UPLOAD_IPFS_IMAGE = async (file) => {
  if (file) {
    const formData = new FormData();
    formData.append("file", file);

    const response = await axios({
      method: "post",
      url: "https://api.pinata.cloud/pinning/pinFileToIPFS",
      data: formData,
      headers: {
        pinata_api_key: PINATA_API_KEY,
        pinata_secret_api_key: PINATA_SECRET_KEY,
        "Content-Type": "multipart/form-data",
      },
    });
    const ImgHash = `https://gateway.pinata.cloud/ipfs/${response.data.IpfsHash}`;
    return ImgHash;
  }
};

Metadata Upload Function

export const UPLOAD_METADATA = async (data) => {
  const response = await axios({
    method: "POST",
    url: "https://api.pinata.cloud/pinning/pinJSONToIPFS",
    data: data,
    headers: {
      pinata_api_key: PINATA_API_KEY,
      pinata_secret_api_key: PINATA_SECRET_KEY,
      "Content-Type": "application/json",
    },
  });
  const url = `https://gateway.pinata.cloud/ipfs/${response.data.IpfsHash}`;
  return url;
};

Built With

Share this project:

Updates