.
SMS Alert for Ontario, Canada Covid-19 new cases
Before we start this weekend build and learn, I would like to take a moment to thank you, all my readers, who always support me and provide me with some suggestions and guidance.

You are the most important motivation for me to keep this journey going. If you like my weekend build and learn series, please follow me on Medium.
Use cases
Covid-19 has changed many of our daily life; with the new normal situation, we think and do things differently.
Every day, my wife and son are trying to get the latest update from the internet about the Covid-19 net new case growth in Ontario, Canada, which has become their daily routine.
This week, my son is busy with his school work. So he misses his routine. When my wife asks him about the number, he suddenly realizes that he forgets this essential daily activity. When he rushed out to the computer and started searching for the number, one of his words catches my attention.
Will be awesome if can get some push notification about those daily number!
"Right! What you give me a new idea for my next weekend, build and learn series. Thank you, son."
The idea always comes from our daily life.

Non-functional Requirements
Let’s see what we want to build before putting our hands on the keyboard, which is an important step.
- Rust lang.
- Cost-efficient.
- For push notification, let’s use the SMS for initial use cases, which Twilio provides some out of box feature. And most importantly, there is a free subscription too.
- Capability to scale to different use cases, such as email notification or even further chatbot implementation – design Pattern. (Dependency Inversion Principle and Open/Closed Principle)
- Timely scheduler – Cron job.
- Easy to build and deploy – My favorite Heroku.
- Accurate data source – Canada government website provided some open and trustable data sources.
Epidemiological summary of COVID-19 cases in Canada – Canada.ca
Architecture & Dataflow
After some first-hand analysis:
- The data available on the website is the CSV file.
- The data will update daily at 7 PM EDT. Some time expect a 1-hour delay.
- That schema covered all we need, such as date, total new case number per Province, etc. For simplicity, we only focus on the entire new case number and total unique death number.
- When we finish processed, we need to clean up the tmp file. Mitigate un-necessary space and operational overhead.

Let’s start the coding part.
Hands on the keyboard.

Code structure
The key business logical in this application have 3 majors parts:
- Download, based HTTP request to get the csv file and return the file path for future processing.
- Process – MapReduce, only for the Ontario number, seems that’s what my son wants it :), which is easy to scale to different use cases, such as save to the DB, or producer to Near-Realtime, streaming, etc.
- Alert component, because we want this can scale based on the open/closed principle, opens extending the new use cases, however, closed to modification of the current implementation.
Additionally, the Procfile, it’s the Heroku schedule implementation.
Download in action
Processing with MapReduce in Rust way
Alert component
For the alert component, we will use the Rust Trait, which simulates Golang interface implementation. The benefit of it: we could choose a specific use case implementation, such as Sms, Email, or chatbot, while the general abstraction workflow remains the same. (Dependency Inversion Principle and Open/Closed Principle)
Next time we need to add Email use cases, we only create the email.rs in the alert folder without touch underline mod.rs within the alert component.
Final Result

Deployment and Cron job setup
For my personal project, I usually use the Heroku for the deployment; one important aspect is the pricing model, scale, and use as a pay as we go.
We can also build containers to deploy to most cloud container providers, such as AKS, AWS, and GKE. I have written some articles on this topic.
However, at the end of the day is always the "build vs. buy" decision. For a builder, I really love how easy it is to start the development, deploy, and set up the DevOps capabilities on top of Heroku.
Heroku, all the necessary plugin is always available, such as build pack, cron jobs set up are mostly straightforward and easy.
The CRON job in Heroku is really easy to setup. In the Procfile simple add

And go to the Heroku UI config your scheduler as needed.

Final result
Finally, for my son, every day at 8:30 PM, the SMS arrived. I’m also using the free tiers for both Heroku and Twilio services, so the total cost is 0 $.

Closing thoughts
- The building idea usually comes from real life. Enjoy it, listen to it, and feel it.
- When you build, you need to think about the scale. Think about getting most of the benefits out of it for your use cases; this comes back to our daily works. Reduce the I.T. Infrastruce cost is not nice to have; it’s a must to have. The fundamental back to how you build it. A great example is why I always trace the container build size, which is the most important indicator for your run time footprint, which will impact your cloud runtime cost. Etc.
- Code it right, code it for scale, code it with the lower cost.
That’s it for this week. And by the way, my son is really excited about what I built. Now we will start coding python together.
Thank you again for your time to read my weekend build and learn. See you next time.
See my other articles below for more weekend build and learn, which you may be interested in.