# shalinigpt/healthcare architecture

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

- Interactive diagram: https://gitdiagram.com/shalinigpt/healthcare
- Repository: https://github.com/shalinigpt/healthcare

## Overview

The “Patient 360” project is a blockchain-based healthcare record management system, built on the Ethereum platform. It is designed to manage and retrieve patient records and associated medical documents in a distributed, secure manner using smart contracts and the IPFS (InterPlanetary File System) for storing immutable documents like prescriptions, lab reports, and X-rays.

##### Project Type and Overall Purpose
- This is a full-stack decentralized application (DApp) that leverages Ethereum blockchain smart contracts for patient and medical record management.
- The Node.js application code (files such as Patient360.js, app.js, mine.js) interacts with the Ethereum blockchain.
- IPFS is integrated for storing non-blockchain data (medical documents) referenced in the blockchain via hexadecimal hashes.

##### File Structure
- Top-level files include Patient360.js, app.js, mine.js, and g1.json (likely a configuration or deployment file).
- The data folder contains subdirectories for geth, indicating that a local Ethereum node is used (through the Geth client) for blockchain operations.
- The presence of node_modules emphasizes that Node.js is the underlying runtime for executing blockchain interaction logic.
- Readme.txt (or README content provided) reveals the purpose, smart contract functions, and the interaction with IPFS.

##### Main Components
a. Blockchain Layer (Ethereum):
– Represent the Ethereum network, specifically noting the use of Geth.
– Include components such as the blockchain ledger, which maintains smart contract state and transaction history.
– List smart contract functionalities like addPatient, getPatient, addMedicalRecord, getMedicalRecord, and getMedicalRecordDetails.

b. Application (Node.js Back-End):
– Nodes running Patient360.js, app.js, and mine.js that invoke the smart contract methods.
– Indicate the interface that sends transactions and queries to the Ethereum blockchain.

c. IPFS Storage Component:
– A separate component for IPFS where medical documents (like prescriptions and lab reports) are stored.
– Show that the smart contract stores the IPFS hash for each document.

d. Data Storage and Ethereum Node (Geth):
– Include the geth node and its data directories to represent the actual backing of the blockchain state.
– This illustrates how data persists on the blockchain network maintained by geth.

##### Relationships and Interactions
- That when a new patient is added or a medical record is created, the Node.js application sends a transaction to the blockchain.
- Interaction between the geth node (Ethereum client) and the Node.js application, highlighting how blockchain transactions are processed and stored.

##### Architectural Patterns/Design Principles
- Separation of concerns:
– Smart contract layer handles immutable record storage.
– Application layer (Node.js) manages business logic and interacts with both the blockchain and IPFS.
– Data integrity and security are enforced by the blockchain whereas data storage efficiency is managed via IPFS.
- Use of decentralization to ensure distributed data validation and storage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Layer"
        A1["Patient360.js"]:::app
        A2["app.js"]:::app
        A3["mine.js"]:::app
    end

    subgraph "Blockchain Layer"
        B1["Ethereum Smart Contract<br>Functions:addPatient, getPatient, addMedicalRecord, getMedicalRecord, getMedicalRecordDetails"]:::blockchain
        B2["Geth Node"]:::blockchain
    end

    subgraph "IPFS Storage"
        C1["IPFS (Medical Documents)"]:::ipfs
    end

    subgraph "Configuration"
        D1["g1.json"]:::config
    end

    subgraph "Documentation"
        E1["Readme.txt"]:::docs
    end

    %% Interactions between Application and Blockchain
    A1 -->|"invokeSmartContract"| B1
    A2 -->|"invokeSmartContract"| B1
    A3 -->|"invokeSmartContract"| B1

    %% Interaction between Application and IPFS
    A1 -->|"storeDocument"| C1
    A2 -->|"storeDocument"| C1
    A3 -->|"storeDocument"| C1

    %% IPFS returns hash to Smart Contract
    C1 -->|"returnsIPFSHash"| B1

    %% Blockchain writes transaction data into Geth node
    B1 -->|"recordsTransaction"| B2

    %% Styling Classes
    classDef app fill:#98FB98,stroke:#006400,stroke-width:2px;
    classDef blockchain fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef ipfs fill:#FFA500,stroke:#FF8C00,stroke-width:2px;
    classDef config fill:#D3D3D3,stroke:#696969,stroke-width:2px;
    classDef docs fill:#FFFFE0,stroke:#FFD700,stroke-width:2px;

    %% Click Events for Component Mapping
    click A1 "https://github.com/shalinigpt/healthcare/blob/master/Patient360.js"
    click A2 "https://github.com/shalinigpt/healthcare/blob/master/app.js"
    click A3 "https://github.com/shalinigpt/healthcare/blob/master/mine.js"
    click D1 "https://github.com/shalinigpt/healthcare/blob/master/g1.json"
    click E1 "https://github.com/shalinigpt/healthcare/blob/master/Readme.txt"
    click B2 "https://github.com/shalinigpt/healthcare/tree/master/data/geth"
```
