DEV Community

Cover image for Managing Diabetes with the Jamstack: The Idea 💡
Jamie Bradley
Jamie Bradley

Posted on • Updated on

Managing Diabetes with the Jamstack: The Idea 💡

On the 23rd December 2003, at the age of 14, I became ill and ended up in hospital. I was very quickly diagnosed with Type 1 Diabetes. 2019 marked my 17th year with Diabetes and as I write this post I find myself reflecting over the years and realising how much technology has positively impacted people who suffer with Diabetes.

However, despite these revolutions there's still a problem...

But before we discuss the problem and look at how I want to help solve this problem let's take a quick biology lesson.

What is Diabetes?

According to the NHS Website:

Diabetes is a lifelong condition that causes a person's blood sugar level to become too high.

If you think back to Science lessons at school you will have learned about an organ called the Pancreas. The Pancreas is responsible for the generation of an enzyme called Insulin. Insulin is a hormone that our bodies use to breakdown sugars (a byproduct of Carbohydrates that we eat) in our bloodstream.

So when a person with a healthy pancreas eats a meal their body will release the exact amount of insulin needed to break down the sugars consumed in that meal. Those who suffer with Diabetes are either unable to produce the right amount of insulin (Type 2) or unable to produce any insulin at all (Type 1).

What's the difference between the two groups?

The main differences are the root causes and treatment.

  • type 1 diabetes – caused when the body's immune system attacks and destroys the cells that produce insulin. Type 1 diabetes is not reversible. Type 1 diabetes is treated by injecting insulin, with pen injections or an insulin pump, to replicate the pancreas' behaviour.

  • type 2 diabetes – caused when the body does not produce enough insulin, or the body's cells do not react to insulin. The exact reason for this is unknown but obesity, being inactive and genetics are often factors that are associated with this type. Type 2 diabetes is often treated by making lifestyle changes and the prescription of tablets. Type 2 diabetes is potentially reversible if diagnosed early enough and drastic lifestyle changes are made.

How is Type 1 Diabetes Managed?

Type 1 Diabetics manage the disease by carrying out several blood sugar tests every day, usually before a meal. Ths involves using a blood sugar monitor which returns a blood sugar count. Using this reading and a carbohydrate count from our meals, we have to calculate the amount of insulin we need to take.

We're only human so we're bound to get insulin amounts wrong. If we don't take enough insulin our blood sugar count rises and this is called Hyperglycemia. If we take too much insulin our blood sugar count drops and this is called Hypoglycemia.

I have no idea how Type 2 Diabetes is managed on a daily basis. If someone lives with Type 2 Diabetes and would like to make a contribution to this article then I'm all ears!

Which is Worse?

A common question I get asked by friends, co-workers etc is "Which is worse? Type 1 or type 2?". In my opinion, both can be as bad as each other. In the UK type 2 diabetes is a lot more common that type 1. The NHS website states that "around 90% of all adults with diabetes have type 2". But, regardless of the type, if diabetes is poorly managed and blood sugar levels aren't stable then complications can arise:

  • Problems with eyes, potentially resulting in loss of eye sight
  • Problems with legs and feet, potentially resulting in ampuation
  • High Cholesterol
  • High Blood Pressure
  • Cardiovascular Disease
  • Kidney Failure

In the UK these complications add serious stress to our National Health Service. Managing diabetes effectively can drastically reduce these potential complications.

The Problem

Phew! 😅

Hopefully I haven't bored you away from the article. If you're still with me then let's talk about the problem with technology in diabetes.

Technology is expensive and it isn't accessible to everyone who suffers with diabetes. As a Brit I am very thankful for the NHS. I treat my Diabetes with an Insulin Pump combined with a CGM (Continous Glucose Monitor) - both of which are funded by the NHS. With this technology I am able to look over previous readings on a graph and adjust medication levels accordingly.

However, there isn't enough funding for every diabetic to access this treatment. We also have to remember that not every country has a service like the NHS which means diabetics outside of the UK have to fund their own treatment. Those who don't use insulin pumps or CGM's are relying on the functionality of their blood glucose monitor, most of which are very good at reading blood sugars but not painting the bigger picture.

Got an Insulin Pump/CGM?

If you do have access to this technology then you should checkout the Nightscout Project. Nightscout is an Open Source, DIY project that helps you get your CGM data into the cloud. This allows for remote monitoring of blood sugars - great for parents!

There's an awesome talk by Scott Hanselman that was recorded in 2015. In this talk Scott showcases the Night Scout software and discusses CGM data in the cloud. Check out the video here

My Solution

Don't get me wrong. Nightscout is an awesome project but it seems very much geared towards diabetics with a CGM and an Insulin Pump. There's also an essence of hacking involved to make the hardware work with the software - this isn't ideal for those who receive pumps through the NHS (it'll void the warranty).

So what about those who are still taking injections for their insulin? Or those who use pumps that have been prescribed by the NHS? How can we provide these users with a similar experience?

I want to create a system that is easy to deploy, cheap to host, secure and fast. This is where JAMstack comes in!

Why JAMstack?

We've been doing a lot of work with JAMstack at Endeavour Digital and the more I work with it, the more potential I see with this architecture. More importantly there are services in this space that I can utilise to meet my criteria:

  • Netlify - An easy to use and affordable hosting solution for static websites and client side applications. The free tier comes with an environment for executing lambda functions which is perfect for what I have in mind. As for keeping deployments simple, their 'deploy to Netlify' button will be super useful here!

  • *Update 18.05.2020 * - Since posting this article I made the decision to store blood results on the Sanity platform, as oppose to Fauna. I wanted to get something online quickly and started to get distracted from my primary goal as I started developing the custom admin interface.

Sanity provides a fantastic interface out of the box, that similar to a CMS, and it is very flexible. This means I can move my focus to the presentation layer whilst still delivering a great data entry experience for my users.

However, this isn't the end of my journey with Fauna. There are other ideas that I want to explore which will work perfectly with the Fauna Platform. So, please check them out, it's really awesome, and stay posted for my other Jamstack ideas!!

  • Gatsby - I'll be using Gatsby to develop the UI. I love Gatsby and I find it's Hybrid Pages feature both useful and awesome.

The Boring Solution

My good friend Sam Beckham introduced me to the idea of starting with the "Boring Solution". In other words the minimum functionality required to get a job done. Naturally I have A LOT of ideas for this application but I need to prove the concept first.

So I'll start with the boring solution, this will let me:

  • Publish data to FaunaDB via the Fauna dashboard. That's right, I'll not be bothering with a custom interface at this stage and why bother if there's one there for me to use?

  • Trigger a gatsby build on Netlify when data is updated. I'm going to try and keep my site as static as possible and this includes pre-fetching Fauna data. Since data is inputted manually and via my CGM I don't need a real-time interface, nor will I be triggering hundreds of deploys each day.

  • Display results in a graph on a basic front end built with Gatsby.

The Less Boring Solution

If I find my proof of concept useful then I will continue to build on this idea. I already have some things in mind that I would like to try which include:

  • Integrating a Netlify Function with iOS Shortcuts/IFTTT! This means I'll be able to publish results from my phone easily.

  • Develop an authenticated application for posting data to Fauna. So I can publish data via a web application rather than the Fauna dashboard. It'll also make posting data easier for less technical users (I would like to Open Source something if this works out).

Wrapping Up

I'm sure more and more ideas will come up as I work through this. But I'm really excited to see how far I can go with JAMstack and learn more about what these services are capable of.

I intend to keep writing about my progress and hope that I can finish with something that I can showcase and talk about at meetups and conferences.

If you also suffer with diabetes and have some ideas you would like to share or would just like to chat to a fellow human with a silly pancreas, then please feel free to reach out to me on Twitter @jamiebradley234.

Top comments (10)

Collapse
 
lady_phair profile image
Amber P.

Thank you for posting this! I'm very excited to hear more about your progress. My husband is a Type 1 diabetic and I've thought about setting up Nightscout for him before, but the devices in USA are so expensive and I'm so afraid of messing it up/voiding warranty/etc.

Best of luck with the project!

Collapse
 
jamiebradley profile image
Jamie Bradley

Thank you for commenting it’s this which motivates me to push on with this project. I hope it works out the way I imagine it to as I totally appreciate the situation you are in! I’ll be posting technical progress as I hit certain milestones so be sure to check back if you would like to learn more. I wish you and your husband the best and thank you again 🙏🏻

Collapse
 
g4challenge profile image
Lukas

Thanks, Jamie, great idea.

Did you consider providing an API like FHIR (e.g. in conjunction with GraphQL) from Sanity to other services? This would make integration a charm. hl7.org/fhir/graphql.html

Collapse
 
jamiebradley profile image
Jamie Bradley

Hey Lukas thanks for the comment. I’m not familiar with this so I will take a look and make a note of your suggestion.

At the moment the aim of the project was to get something online that people can use/try and deliver some immediate feedback. But I’m constantly thinking of ways to expand the project and likewise excited to hear other opinions/suggestions.

Thanks again for taking the time to read. I’ll check out your link now 🙏

Collapse
 
jamiebradley profile image
Jamie Bradley

On the back of this, Sanity has a graphql api and as part of the setup for HeySugar you have to deploy this API for Gatsby to integrate with Sanity. Therefore, if I’ve understood right, we’ve got the graphql data there already to integrate!

Thread Thread
 
g4challenge profile image
Lukas

That is already good to hear - there would be considerations to make - in order to make your side "compatible"/interoperable with FHIR - the process is kind off daunting - but would make a huge difference. Because it could possibly connect to healthcare systems.

If you are interested, this would make it very interesting!

Collapse
 
blairbo profile image
blairbo

This is great news. I used GastbyJS on my latest project and was very pleased. I'm attending the JAMstack conf and was so disappointed to have missed your talk as I am a T1D parent who is getting the bits n pieces together to connect my daughter's kit to Nightscout. I'm super excited to see this news. I'm sure you'll have a lot of interest & help following putting it up on github/lab/etc.

Collapse
 
jamiebradley profile image
Jamie Bradley

Hey! I’m sorry for missing your comment. Notifications didn’t come through for some reason. If you haven’t seen it already the talk is actually available on YouTube along with other talks from JAMstack conf! Just search “managing diabetes with Jamstack”.

Likewise the GitHub is now live so fee free to check it out github.com/HeySugar/hey-sugar-app it’s in very early stages but things are also progressing so be sure to follow the project and thank you for taking the time to read the article 🙏

Collapse
 
chrispecoraro profile image
Christopher Pecoraro

Jamie. Yes, Yes, and definitely Yes. This sounds like a wonderful idea! Make sure you have everything working for Android as well.

Collapse
 
jamiebradley profile image
Jamie Bradley

Thanks Christopher! The application will be web based so it should work well across platforms. This is one of my biggest gripes with some of the Diabetes software at the moment - especially Medtronic's Care Link - and I definitely don't want this to fall into that category!