
Weekend Annoying Task Challenge: MedTracker
List your medicines, stocks remaining, and dosage and let the app send you a reminder on when to restock what medicines.
Vision & What the App Does
Every few days, I face the same problem, I'd reach for a medicine strip and find it empty, I have to wait till the next morning to either go and buy from a pharmacy or wait until the online order gets delivered thus resulting in missing the dose. Manually keeping the track of tablet counts for multiple medicines in head with several other tasks is annoying.
MedTracker is a web app that solves this task. For each medicine: add the name, the dosage (how many times in a day you take it), number of tablets that come in a packet, and how many packets you currently have. From there it calculates automatically, every single day — exactly how many tablets you have left and the calendar date they'll run out. A day before you'd fall short a full day's dose, it emails you: "Med A will soon run out of stock!". When you buy a new packet, you tap Restock, tell it how many packets, and the countdown resets. No spreadsheets, no mental math, no more surprise empty strips.
How I Built It
I started from the core math problem rather than the UI. Given a starting tablet count and a daily dosage, the app needs to know, as of today, how many tablets are left and when they'll hit zero — accounting for the fact that stock isn't decremented in real time by the user, only recalculated on demand. My solution: store
currentStock alongside a reference date, lastUpdateDate . Every calculation derives today's true remaining count as currentStock - (daysElapsed × dosagePerDay) , where daysElapsed is the gap between today and that reference date. Restocking simply recomputes the "true" remaining amount, adds the new tablets, and resets the reference date — so the whole cycle stays accurate indefinitely without needing a background process to decrement stock every day.The trickiest decision was when exactly to fire the reminder. The challenge spec was specific: 10 tablets at 3-a-day, starting Day 1 breakfast,should trigger a restock reminder on Day 3 — one full day before the stock actually runs out mid-Day-4. I landed on a simple rule: after subtracting today's doses from today's remaining stock, if what's left can't cover one more full day, send the reminder now. Walking through the example by hand confirmed it fires exactly on Day 3, matching the spec.
I also went back and forth on whether to decrement stock in real time(e.g., a "mark dose taken" button) versus deriving it mathematically from dates. I chose the date-based approach — it's stateless, requires zero user interaction beyond adding and restocking medicines, and is far less likely to drift out of sync if a day gets missed.
AWS Services Used
The whole thing is serverless and built to stay inside the AWS Free Tier:
- DynamoDB – A single table stores each medicine as an item, keyed by a generated UUID (
medicineId), with attributes for dosage, stock reference date, and areminderSentflag to avoid duplicate emails.
- Lambda – There are five small Python functions: add, list, restock, delete, and a daily stock-check function. No frameworks, just
boto3.
- API Gateway (HTTP API) – It exposes the CRUD Lambdas as REST-style endpoints (
POST/GET /medicines,PUT /medicines/{id}/restock,DELETE /medicines/{id}) that the frontend calls with plainfetch().
- EventBridge Scheduler – It fires the stock-check Lambda once a day on a cron schedule. This is the "brain" that decides who needs a reminder. No API Gateway involved here — it invokes the Lambda directly.
- SNS – A single topic with an email subscription. The scheduled Lambda publishes a message per medicine that needs restocking, and SNS handles the delivery.
- S3 – S3 bucket is used for static website hosting for the frontend.
Architecture Overview
The agent is triggered two ways: interactively, whenever the user adds, restocks, or deletes a medicine through the UI (API Gateway → Lambda), and
autonomously, once a day via EventBridge Scheduler, which is what actually watches stock levels and decides when to notify.

What I Learned
I was already familiar with Lambda, SNS, and EventBridge as it was used in a previous project, so the real learning curve this time was everywhere else in the stack. DynamoDB was new to me, and it pushed me to think differently about state: instead of a mutable counter I decrement every day, each medicine item stores a snapshot (
currentStock ) plus a reference date ( lastUpdateDate ), and the "true" remaining count is derived on every read. That single-table, computed-on-read approach turned out to be far more robust than trying to keep a running countdown perfectly in sync, and it's a pattern I'll reach for again.API Gateway was the other big new piece — specifically wiring an HTTP API's routes to individual Lambda integrations and getting CORS to actually apply. My first deploy threw "Failed to fetch" errors in the browser, and digging into the Network tab taught me the difference between a preflight
OPTIONS request succeeding and the actual POST still being blocked because the response was missing the Access-Control-Allow-Origin header — a distinction I hadn't had to reason about before.Finally, hosting a frontend on S3 static website hosting was straightforward but new to me — no build step, just a bucket policy and an index document setting — and a good reminder of how far
fetch() and a bit of DOM manipulation can go for a small, single-purpose tool.Challenges faced
I did not set the CORS properly so I got the error "No Access Control Allow Origin header is present on the requested resource".


Link
- App: MedTracker
Screenshots


#productivity #app
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article