Secure Data Storage API
Tags: octograd2020, githubsdp, github, django
Published: 2020-05-21 15:58:13

[Comment]: # (All of this is placeholder text. Use this format or any other format of your choosing to best describe your project and experience.)

[Note]: # (If you used the GitHub Student Developer Pack on your project, add the "#githubsdp" tag above. We’d also love to know which services you used and how you used it!)

## Medicon
This is one of the few projects close to my heart, probably because I've written it from scratch. It showcases the use of [IPFS](https://ipfs.io/) as a secure & scalable persistence module for a data service exposed as an easy to use REST API, built using [django](https://www.djangoproject.com/).

The API can be harnessed to efficiently store data in desired order. I used this API to store medical records of patients in a secure and chronological manner.

### How?
I decided that every event in someone's medical history can be grouped into episodes each of which may contain multiple encounters with a lab/pharmacy/doctor/.. etc, also a person can have multiple episodes running simultaneously (you can have a broken hand and fall sick of the flu sometimes, assuming the worst case scenario).

Now, all we need is a simple mechanism which allows us to use the current episode to track the next episode which subsequently allows us to track the next episode and so on.

This is done by using hashes (think of a linked list) which are generated by the IPFS client as a response of any data that gets successfully added. These hashes can be used to fetch the data from IPFS.

![IPFS storage order](https://dev-to-uploads.s3.amazonaws.com/i/7210lp8a2fnse0j5yxnw.jpg)

While I was working on the back-end, my other teammate designed a great front-end which allowed us to transform the API calls into a user-friendly application which followed the following activity diagram.

![activity flow](https://dev-to-uploads.s3.amazonaws.com/i/o6aegfbz4zkrlpajnzfb.jpg)


## Demo Link
 This [dropbox link](https://www.dropbox.com/sh/2qct0skfc0t60ou/AAAhXlDP5Ks4BJYQkNlRhKa0a?dl=0) contains the detailed demo and explanation of the project.
I created the back-end and my friend created the front-end. It also has an explanation of the architecture and other features in detail.

## Link to Code
{% github https://github.com/underscoreanuj/medical-blockchain %}

[Note]: # (Our markdown editor supports pretty embeds. If you're sharing a GitHub repo, try this syntax: `{% github link_to_your_repo %}`)

## How I built it 
I used [django](https://www.djangoproject.com/) to create the REST API and [ipfs client library](https://pypi.org/project/ipfshttpclient/) for python. 
The major challenges I faced while making the project was creating a link between django and the IPFS daemon and ensuring that the data is pushed and retrieved in the appropriate order, also writing a REST API in django requires you to write serializers which helps in making the class objects and json data inter-convertible, and since I was using a group of interconnected classes with inheritance writing the serializers such that they would be generic enough was a painstaking task. I learnt a lot about how serailization and deserialization of a class based object works and why is it important.


## Additional Thoughts
Once the API was ready I sat down with my teammate who created the front-end and we helped each other in merging the two so that the entire project worked seamlessly. All this while our other two teammates were working hard to work up a good paper on the project which we could present. All in all it was a great experience making this project and working alongside my team.

### Why I'm proud of it
This project was shortlisted in top 10 projects out of 1400+ projects for a hackathon organized by hackerearth.

Thanks to [github's student developer pack](https://education.github.com/pack) for providing a free subscription to the following:
1. PyCharm Pro (a great IDE with great support for django)
2. Heroku (which we used to deploy the project upon, the free hobby dyno is very helpful)
3. Github (makes working in teams an easy and fun task).

[Final Note]: # (CONGRATULATIONS!!! You are amazing!)