- Role
- Co-author of a two-person thesis
- Year
- 2025 (thesis), 2026 (v2)
- Stack
- Solidity, Hardhat, ethers.js, Flask, scikit-learn
- Context
- Graduation thesis, Computer Engineering, Fırat University
HealthChain is the graduation thesis I wrote with Deniz Bektaş in 2025 in Computer Engineering at Fırat University, supervised by Prof. Dr. Mehmet Karaköse. We combined a system that keeps medical records in an Ethereum smart contract with a decision-support module that predicts a disease from symptoms.
The problem
Patient data mostly sits on central servers. That was the thesis's starting point: the data is open to manipulation, reachable through a single point, and a privacy risk. The second need was on the user's side: someone who enters their symptoms should get quick, reliable first information.
The thesis prototype
The system has four components: an interface in HTML, Tailwind CSS and JavaScript, a Web3 layer through Ethers.js and MetaMask, the Solidity contract MedikalKayitSistemi.sol, and a prediction module served by Flask. The wallet address is the identity, and every transaction is signed in MetaMask. A patient can reach only their own record; the admin can list, update and delete every record through admin.html.
- WalletMetaMask connects, the wallet address is the identity
- RecordName and disease are written to the contract
- SymptomsThe list goes to
POST /tahminin Flask - PredictionThe likely disease and precautions come back as JSON
For prediction we first tried a text-based LSTM; its accuracy stayed low and it tended to memorise. We trained a Random Forest with 200 trees in scikit-learn instead. We used the open “Disease Symptom Prediction Dataset”: each symptom became its severity weight, and the data was split 80/20 into training and test sets. The POST /tahmin endpoint in Flask takes the symptom list and returns the prediction and suggested precautions as JSON.
The results we reported in the thesis (2025):
These numbers belong to the thesis version, the Random Forest model served by Flask. The v2 below does not claim that those experiments were repeated under the new design.
What v2 changes
In the thesis prototype the patient's name and disease sat in the contract as plain text. HealthChain v2, the current version in the repository, reverses that decision. Its README states the rule: a public blockchain may prove integrity, but it must not become a database for private medical content.
The README also lists the problems of the old version: medical fields were written on-chain in plain text, the admin could change records without restriction, deployment details were hardcoded, generated dependencies were committed, and an AI credential had appeared in the source history.
| Thesis prototype (2025) | v2 | |
|---|---|---|
| Written on-chain | Name and disease, plain text | Salted digest, author, timestamp, revocation flag |
| Record content | Inside the contract | In the browser and the downloaded proof bundle |
| Admin | Lists, updates, deletes | None |
| Changing a record | Update and delete | Append-only; the patient sets the revocation flag |
| AI | Disease prediction with a Random Forest | Optional educational notes, no diagnosis |
| Tooling | Hardhat, Ethers.js, Flask, scikit-learn | Hardhat 3, viem, Express 5 |
| Network | Local Hardhat network | Local Hardhat network |
In v2 the content of a record does not leave the browser. The browser generates a random 32-byte salt and computes the digest SHA-256(salt_hex + ":" + canonical_json_payload). Only that digest, the author's wallet address, a timestamp and a revocation flag are written to the MedicalRecordRegistry.sol contract. The contract has no admin, no update and no delete. The patient uses setProviderAuthorization to authorise a provider who may add records on their behalf, and only the patient can mark a record as revoked.
Writing a record and verifying it later takes six steps:
- RecordThe content is prepared in the browser
- Salt and digestRandom 32-byte salt, SHA-256
- Signature
addRecord, from the patient's or an authorised provider's wallet - ChainDigest, author and timestamp are written
- Proof bundleContent, salt, digest and transaction details download as JSON
- VerificationThe digest is recomputed locally and must match the one in the bundle
The AI side changed too. v2 has no Random Forest; in its place is an optional Node.js endpoint that calls the OpenAI Responses API. Its instructions prohibit diagnosis, prescription, dosing and medication changes, and the output is presented as educational notes.
Stack
- Thesis (2025)
- Solidity, Hardhat, Ethers.js, MetaMask, Flask, scikit-learn, Tailwind CSS
- v2 contract
- Solidity ^0.8.24, Hardhat 3, TypeScript, viem
- v2 application
- Node.js 22, Express 5, HTML, CSS, JavaScript, ethers.js
- Process
- GitHub Actions, Dependabot
- Licence
- MIT
Limits
The thesis prototype ran only on Hardhat's local network; the thesis mentions no deployment to a public testnet or mainnet. Its limitations section adds that gas costs would be high on a real network, a model trained on a limited dataset makes more errors on rare diseases, and the Flask API on a single server becomes a bottleneck under parallel requests.
v2 is a research prototype too. Its README lists no encrypted record database, no FHIR or HL7 support and no third-party audit. Wallets are pseudonymous, the AI output is not clinically validated, and no HIPAA, GDPR or KVKK compliance is claimed.




