AWS Builder Center
Weekend Challenge: Turn One Annoying Task Into an App: npm Download Digest

Weekend Challenge: Turn One Annoying Task Into an App: npm Download Digest

Build a serverless app that automatically tracks npm download trends, detects anomalies, and emails weekly digests using AWS Free Tier services.

Vision & What the App Does

As an open-source maintainer of  opentel-mcp  — a Node.js library that instruments MCP (Model Context Protocol) servers with OpenTelemetry observability — I found myself spending five minutes every Monday morning doing the same manual ritual: open npmjs.com, navigate to my package page, mentally compare this week's download count against what I remembered from last week, and try to figure out if my recent LinkedIn post or conference talk actually moved the needle.
It's a small task. It repeats weekly. It quietly eats time.
npm Download Digest eliminates that friction entirely. Every Monday at 9:00 AM IST, a Lambda function automatically wakes up, queries the public npm registry for the last seven days of download data, compares it against a four-week historical baseline stored in DynamoDB, detects anomalies and trends, publishes metrics to CloudWatch, and emails me a clean, actionable digest via SNS. When I open my inbox on Monday morning, the analysis is already done. No tabs to open, no mental math, no friction.
The digest shows not just raw numbers, but directional trends (📈 UP / 📉 DOWN / 🚀 SURGE), percentage change, 4-week moving averages, week-by-week progression, and anomaly flags if downloads spike or drop unexpectedly. The app supports multiple packages via environment variables, so maintainers tracking several libraries get one consolidated digest with trend analysis for each.



How You Built It

I started by validating the npm registry public API. The endpoint  https://api.npmjs.org/downloads/point/{start}:{end}/{package}  returns clean JSON with download counts for any date range — no authentication required, no rate limits for low-volume usage. That simplicity made automation feasible within a weekend.
The architecture uses three data layers. First, the npm API provides current download statistics. Second, DynamoDB stores weekly snapshots (keyed by package name and Unix timestamp) to build a rolling four-week history. Third, the Lambda function queries that history to calculate real trends instead of just week-to-week comparisons.
I implemented a trend-detection heuristic: if this week's downloads exceed 1.5x the rolling average, flag it as a SURGE (anomaly). If below 50% of average, flag as a potential decline. This catches real signal without false positives. The Lambda publishes two CloudWatch custom metrics per package — raw weekly downloads and week-over-week percentage change — enabling future dashboards or alarms.
Error handling is resilient by design. If the npm API fails for one package, the digest still sends for others. DynamoDB or CloudWatch failures don't block the email. The deploy script is idempotent — run it twice, no duplicates or race conditions.
I chose to use only the AWS CLI for deployment (no Serverless Framework, no CDK, no SAM) to keep the infrastructure reproducible and auditable. The entire application stack is created by a single  bash deploy.sh  command that handles IAM role provisioning, DynamoDB table creation, Lambda packaging, EventBridge rule scheduling, and CloudWatch dashboard setup — all without a single manual click in the console.
The Python Lambda handler is 140 lines with zero external dependencies beyond boto3 (pre-installed in the runtime). I kept it small intentionally — small code is easier to test, audit, and maintain.



AWS Services Used / Architecture Overview

The stack uses five AWS services, all within Free Tier limits:
1. AWS Lambda (Python 3.12) — Orchestrates the entire pipeline. Queries the public npm API, reads and writes DynamoDB, publishes CloudWatch metrics, sends SNS notifications. Execution time: ~8 seconds. Free Tier includes 1 million requests/month; this app runs 4/month.
2. Amazon DynamoDB — Persistent storage for weekly download snapshots. Stores one record per package per week (4 rows for a 4-week history). Uses on-demand billing (PAY_PER_REQUEST). Free Tier: 25 GB storage and 25 write capacity units included; our usage is <1%.
3. Amazon SNS (Simple Notification Service) — Email delivery. Publishes the digest message to a topic with one email subscription. Free Tier: 1,000 emails/month included; we send 4/month.
4. Amazon EventBridge — Serverless event bus and scheduler. Triggers Lambda on a cron expression every Monday 3:30 AM UTC (9:00 AM IST). Free Tier: Rules are unlimited and free.
5. Amazon CloudWatch — Metrics and monitoring. Collects custom metrics ( WeeklyDownloads ,  WeekOverWeekChange ) per package in the  npm-download-digest  namespace. Dashboard visualizes trends. Free Tier: 10 custom metrics included.
Architecture Flow:
EventBridge Scheduler (weekly cron: Monday 9 AM IST)
↓
AWS Lambda Function
├─ Fetch npm registry API (public, no auth)
├─ Query DynamoDB (read 4-week history)
├─ Calculate trend & anomaly detection
├─ Publish CloudWatch metrics
└─ Send SNS email notification
↓
┌────┴────┬──────────────┐
↓ ↓ ↓
SNS DynamoDB CloudWatch
(Email) (History) (Metrics)
↓
📧 Weekly Digest in Your Inbox

Infrastructure Deployed

Screenshot 1: AWS Lambda Function

Caption: "Lambda function configured with environment variables pointing to SNS, DynamoDB, and npm packages. The function is triggered by EventBridge every Monday at 9:00 AM IST."


Screenshot 2: DynamoDB Table with Data

Caption: "DynamoDB table storing weekly download snapshots. Each record captures a package's download count for trend analysis. The table uses on-demand billing and is fully within Free Tier."


Screenshot 3: SNS Email Digest

Caption: "Weekly npm Download Digest email sent automatically via SNS every Monday. The digest includes trend analysis, 4-week averages, and anomaly detection."


Screenshot 4: CloudWatch Metrics Dashboard

Caption: "CloudWatch Dashboard configured to track npm download metrics. The dashboard will populate with data every Monday at 9:00 AM IST when the Lambda function executes. Custom metrics are published automatically."


Screenshot 5: EventBridge Scheduled Rule

Caption: "EventBridge Scheduler rule configured to trigger Lambda every Monday at 3:30 AM UTC (9:00 AM IST). The cron expression ensures consistent weekly execution."


Cost Breakdown (Monthly):
  • Lambda: 4 invocations × 8 sec = 32 sec compute → Free (< 400k GB-seconds)
  • DynamoDB: ~8 operations → Free (25 WCUs included)
  • SNS: 4 emails → Free (1,000/month included)
  • EventBridge: 1 rule → Free (unlimited)
  • CloudWatch: 2 custom metrics → Free (10 included)
Total monthly cost: $0.00



What You Learned

Building under a 48-hour constraint forced discipline. I initially considered adding a web dashboard, setting up Slack alerting, or building a months-long archive — but the challenge prompt says "one clear job, done well," and a weekly email digest is exactly that.
I discovered that the npm public registry API is remarkably well-designed for automation. No API key required, no rate limits on reasonable usage, clean JSON responses, and instant availability. Integration took less than 15 minutes. This is a reminder that good APIs don't need complexity to be powerful.
I learned that DynamoDB's on-demand billing model (PAY_PER_REQUEST) is perfect for low-traffic workloads like this. No capacity planning, no reserved throughput, no surprises. The free tier covers us completely.
EventBridge cron syntax deserves mention. The six-field format and the  ?  wildcard for day-of-month vs day-of-week are gotchas. But the documentation is clear, and the service is elegant once you understand it.
Finally, using the AWS CLI exclusively (no SDK wrappers, no frameworks) made the deployment script portable and auditable. Anyone can read  deploy.sh , understand what it does, and reproduce the infrastructure exactly. That reproducibility is a feature, not a limitation.



Link to App or Repo

The repository contains:
  •  lambda_function_v2.py  — Python Lambda handler with DynamoDB + CloudWatch integration
  •  deploy-v2.sh  — One-command AWS deployment script (creates all infrastructure)
  •  README.md  — Full setup instructions, troubleshooting, architecture diagrams
All code is production-ready with error handling, logging, and comprehensive comments.



Closing

The npm Download Digest is proof that the most valuable tools are often the simplest ones. Five AWS services, 140 lines of Python, one bash script, zero manual overhead. It solves one real problem (weekly download tracking), does it reliably (runs every Monday at the scheduled time), costs nothing (entirely within Free Tier), and shipped in a weekend.
If you maintain an open-source package and want to track your adoption without the friction, fork the repo and deploy. If you have a different metric you'd like to track automatically, the architecture is generic enough to adapt.


Built by Thirumalaiboobathi B — GenAI & Full Stack Engineer, Madurai, Tamil Nadu, India. Open-source contributor
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article