Justin Ng

Justin Ng

aboutblogprojectsresumecontact
Shedding Light on the Vaccination Regimen in Singapore
SG Vaccine Tracker, October 2021
SG Vaccine Tracker, October 2021

It has been nearly two years since the onset of the COVID-19 pandemic. Having recovered from a bout of infection from the Omicron variant myself, I thought it time to write a eulogy for the SG Vaccine Tracker before I shut down the servers forever.

I shut the tracker down for good reasons. First, the Government started showing percentage statistics sometime around October 2021. Second, I was paying about 7 USD a month to upkeep infrastructure on AWS and Heroku. Third, the HTTPS cert had expired, preventing sane users from ever accessing the tool.

Why I built SG Vaccine Tracker

Back in the day, health authorities in Singapore were slow to release vaccination statistics; when they did, the numbers made it hard to discern the program's success. At the same time, there was skepticism and hesitancy about vaccines bubbling from a small sect of the populace. I thought transparency was an important tool to help show the urgency behind getting vaccinated quickly. It was also my intention to make tracking the progress a fun one. If people could contribute to the "filling of the bar" by getting vaccinated, maybe they would do so in greater droves.

SG Vaccine Tracker had its own Twitter account that automatically tweets whenever an update is available, winning Mahjong tiles as it went along.

SG Vaccine Tracker also posted these updates to an internal Slack channel for a team to monitor the system.

How I did it

To get the latest data, I built a data scraper on AWS Lambda that parses the DOM from the Ministry of Health's statistics page, calculates the daily percentage totals and past-period stats, and updates a DynamoDB table whenever there is a change. The lambda runs daily using a cron trigger.

Since statistics are already widely available in raw form in Our World In Data, there isn't a need to store historicals. The lambda replaces the data, recalculating the past period's statistics whenever a new update is available.

This AWS Lambda function sits behind an AWS API Gateway endpoint to allow the frontend to make REST calls to get the latest data. It also has access to the Twitter API and Slack API SDKs to enable posting to Twitter and Slack. Here is a building block of the Tweet's Mahjong tile progress bar.

const mahjongBar: Array<String> = [
  '🀫','🀑','🀒','🀓','🀕','🀕','🀕','🀗','🀗','🀗','🀅','🀅','🀅','🀑','🀑'
];

Presenting the data is less complicated. The frontend is a separate React app hosted on Heroku using create-react-app as the boilerplate. I added an Admin page secured behind Auth0 to allow easy managing of the data. It also allowed me to update the counts using a JSON payload should something be off.

SG Vaccine Tracker Admin Console
SG Vaccine Tracker Admin Console

The entire backend is held together with Serverless, allowing me to deploy to AWS without writing SAM or Terraform. The Serverless Offline plugin spins up the tables, lambdas, and API gateway locally. A Docker Compose file enabled seamless test orchestration of the front and backend.

While SG Vaccine Tracker is no longer online, a link to the GitHub repository is on the projects page.

What I would have done better

Building the tool was a great exercise applying what I learned as a Certified AWS Developer on AWS! However, it cost me about $2 a month to use the AWS Key Management Service and an additional $5 a month to host the frontend with HTTPS on Heroku. The microservice architecture is too expensive and complex for the simple endeavor of reading from a DynamoDB to serve data to a static page. I would have written everything as a micro-monolith on Next.JS with HTTPS support and for free. Going by the low volume of data, a JSON file would have been preferable to a full-on database.

Concluding

I am relieved to see that at the time of writing this post, 93% of the population in Singapore has been fully vaccinated, up from 9.42% in April 2021 and 83.87% the last time the tracker pulled data in October 2021.

SG Vaccine Tracker, April 2021
SG Vaccine Tracker, April 2021

I believe that vaccines save lives and prevent the onset of hospital-requiring infection. The symptoms I had were not grave enough to warrant a trip to the emergency room. The whole point of saving this trip is to allow others who need the spot -- the immunocompromised, the elderly, the unvaccinated -- to have a fighting chance.

I lay the SG Vaccine Tracker to rest with this sentence

The fight against misinformation progresses with those who can shed some light to amplify the truth. "Light shines in darkness, and the darkness cannot overcome it" -- John 1:5

2024 © NGSIM