Looks like there's a Dev Blog now? Cron jobs, emails and offline mode
Published: 12/17/2024.
Edited on: 12/17/2024.
Well so I suppose the first update worth mentioning is that I started a Dev Blog for Thirty Plants. The most obvious benefit from outside may be to give updates / insight to anyone interested in keeping up with the app's progress, but the main motivation actually is to provide a bit of reference for my own benefit. Its easy to forget, from my perspective, how much work has gone into the various stages so hopefully this helps with that!
So onto the actual update. My recent focus has been on working towards a "Weekly Email" feature. The idea is simply that at the end of each week, each user will get a summary of their achievements that week, or some kind of nudge if they didnt do anything.
This required integrating with some kind of email service as well as setting up a Cron Job.
By far the most difficult part of this has been the Cron... seems wild in 2023 that this isn't straightforward. One promising new option was Vercel, who recently launched a Cron feature. However I didn't like the lack of security (I really dont want the trigger to exposed to the public internet...) and also the fact that its in Beta still. Heroku has been my go-to for many years, however the monorepo structure of the project made this much more difficult and I was never able to figure out several issues there. After a lot of looking around I found that Github Actions can actually do Crons via the 'schedule' feature - after a decent bit of poking around I got this working nicely.
Emails comparatively were a breeze. I set things up using a tool called Resend (and React Email) and had things working almost immediately.
So whats next?
While writing the email cron job, I realised that the stats calculated for the email could be re-used throughout the week to prevent a huge amount of database usage (especially for calculating things like "weeks since you ate X plant"). So doing something along these lines should be a priority soon.
While using the app myself, 2 things have started to annoy me:
You are forced to log in way too often. This is not a banking app... I dont think security has to be hugely tight here. So I way look at extending the session time - honestly it could be fine for it to be infinite but I will look into this very soon.
The initial load takes way too long. The list of plants in particular has no reason to spend so much time loading, and could even be embedded into the app code? If not some kind of cache, Redis etc, would be very appropriate in this instance.
Finally I want to mention a more substantial goal but one to start working towards. Rather than doing everything direct with the Cloud, I want the app to work offline and then sync when possible. Its really frustrating having to wait 2 seconds or more for the "eat" button to finish sending. This will also lay the ground for the long-term free version of the app which will be pure offline and require no server interaction.
Hope you enjoyed reading the first ever 30p Dev Blog post. Cya later