🧅 Onion Price Tracker – How It Works
Check out the tracker here if you haven't already.🛠️ Tech Stack
- AWS S3 – Stores static web pages, daily price JSON files, and the
city_state.json
mapping. - AWS CloudFront – Serves static assets globally via CDN for fast access.
- AWS Lambda – Runs serverless functions for data ingestion and processing.
- AWS DynamoDB – Stores raw onion price records with city and date.
- AWS EventBridge – Schedules Lambda executions automatically.
Architecture

📂 Data Flow
1. Data Ingestion
- A Lambda function fetches onion prices from the Government API.
- Prices are averaged at the city level.
- Data is stored in DynamoDB with schema:
city
: Partition keydate
: Sort keyprice
2. Data Processing
- Another Lambda function generates JSON files (
city_date.json
) by reading from DynamoDB data. - This function is configured as output of the ingestion lambda so that it is triggered after it.
- Each file contains data for the last 6 months for a city
- These JSON files are written to an S3 bucket.
3. Data Serving
- The webpage fetches JSON files from S3.
- CloudFront serves both:
- Static HTML/CSS/JS files.
- City-specific JSON data files.
4. Scheduling
- EventBridge triggers the Lambda functions once daily.
⚡ Additional Details
- Entire system runs within the AWS Free Tier (Lambda free invocations, DynamoDB free reads/writes, S3 free storage/requests).
- Data retention is capped at 6 months per city (older entries expire automatically via TTL).
- The list of supported cities is stored in a static JSON (
city_state.json
) in S3, making the system configurable without code changes.
✅ This pipeline ensures that visitors always see the latest onion prices per city, fetched once per day, stored for 6 months, and served globally through S3 + CloudFront — all while staying within AWS Free Tier.