xavier collantes

Faster In-Stock Alerts During COVID-19

By Xavier Collantes

1/8/2025


COVID Supply Shortage Chaos

Empty store shelves during COVID
During the peak of the COVID-19 pandemic in 2022, essential items were constantly out of stock. From hand sanitizer to home office equipment, finding products in stock became a daily frustration due to halting of supply chains and exploding demand.
From personal experience shopping online, the existing "notify me when in stock" emails from retailers were unreliable, often arriving hours or days after items had already sold out again.
I found myself manually checking dozens of product pages multiple times a day, hoping to catch restocks. This was time-consuming and inefficient.
Update

Since 2023, Checkmate has been turned down due to supply chains returning to normal. I have chosen to focus on other endeavors.

The Solution: Checkmate

Email alert
I built Checkmate, an automated stock monitoring service that continuously tracks product availability across multiple retailers and provides real-time notifications when items come back in stock. Instead of relying on slow email notifications, Checkmate actively scrapes product pages and instantly alerts users the moment products become available instead of relying on email alerts which I found came out hours after the products were made available.
Checkmate
You can choose products to monitor and set the notification preferences.
Shopping page

Notify Me When In Stock

Many online retailers offer a "notify me when in stock" feature. However, I found that these alerts often came out hours after the products were made available.
I found three separate occurrences where the email alerts came out hours after the products were made available. So I built Checkmate to alert when the product was in stock, not when you were notified by the delayed email alerts.
Demo of Checkmate

Architecture Overview

The system consists of two main components:
Backend Service (Python)
Python logo
  • Selenium-based web scraper with Chrome WebDriver
  • Firebase Firestore for product/provider configuration
  • Google Cloud Storage for screenshot evidence
  • Configurable monitoring intervals and randomization to avoid bot detection
  • Deployed on Google Cloud Platform with Docker
Frontend Dashboard (Next.js/React)
  • User authentication and subscription management
  • Product configuration interface
  • Notification preferences and history

Key Technical Features

Intelligent Web Scraping
Notify button
  • Configurable XPath selectors for different retailer layouts
  • Anti-bot measures including user agent rotation and cookie collection
  • Screenshot capture for verification and debugging
  • Randomized delays between requests to avoid rate limiting
🐍
Python3
1def check_if_in_stock(self, driver, provider_url, provider_name,
2                     sold_out_text, full_xpath, product_id):
3    """Check provider site for a single product."""
4    try:
5        driver.get(provider_url)
6        target_block: WebElement = driver.find_element(By.XPATH, full_xpath)
7        target_text: str = target_block.text.upper()
8        sold_out_text: str = sold_out_text.upper()
9
10        # True if in stock (sold out text NOT found).
11        return sold_out_text not in target_text
12    except Exception as ex:
13        logging.error("Could not check stock: %s", ex)
14        return False
15
snippet hosted withby Xavier
Firebase Integration
Firebase logo
  • Firestore for storing product configurations and stock status
  • Cloud Storage for screenshot archives
  • Real-time database updates for instant frontend synchronization
  • User authentication and subscription management
Production-Ready Deployment
  • Docker containerization for consistent environments
  • Google Cloud Build for automated CI/CD
  • Cloud Run for serverless scaling

Technical Challenges Solved

Anti
Bot Detection Avoidance Websites actively block automated scrapers. I implemented several countermeasures:
  • Dynamic user agent generation based on system platform
  • Random delays between requests (5-15 seconds)
  • Cookie collection from Google before visiting target sites
  • Disabling automation-specific browser flags
Despite these measures, some sites would still present CAPTCHA challenges that required manual intervention, highlighting the ongoing arms race between automation and bot detection systems.
Simple Fix

A simple fix for 80% of the sites was to simply turn on cookies and visit random websites to fill out the cookies. This was a signal for many sites that the user is human if there was a history of cookies being set.

Reliability & Error Handling
  • Comprehensive exception handling for network timeouts
  • Screenshot capture for debugging failed checks
  • Automatic retry logic with exponential backoff
  • Health monitoring and uptime tracking
Scalability
  • Configurable product database stored in Firestore
  • Parallel processing capabilities for multiple products
  • Cloud-native architecture supporting horizontal scaling
  • Efficient resource usage with headless browser mode

Real-World Impact

Mobile push notification alerts
During the height of the supply shortage, Checkmate successfully:
  • Monitored 15+ products across 8 different retailers
  • Achieved 95%+ uptime with 5-minute check intervals
  • Provided notifications within minutes of restocks (vs hours for email alerts)
  • Helped secure essential items including sanitizer, masks, and electronics
The system proved particularly valuable for high-demand items that would sell out within minutes of restocking. Traditional email notifications simply couldn't compete with the speed of automated monitoring.
Over time, I stopped using Checkmate as the economy normalized and supply chains returned to normal. I turned down the resources to prioritize other endeavors.

Technical Stack

Backend
Python logo Firebase logo
  • Python 3.9 with Selenium WebDriver
  • Google Chrome/Chromium for rendering
  • Firebase Admin SDK for database operations
  • Google Cloud Storage for file management
  • Absl-py for command-line flag management
Frontend
  • Next.js 13 with TypeScript
  • React 18 with Material-UI components
  • Firebase v9 SDK for real-time data
  • Formik for form validation
  • Stripe integration for subscription billing
Infrastructure
  • Google Cloud Platform (Cloud Run, Storage, Build)
  • Docker containerization
  • Terraform for infrastructure management
  • GitHub Actions for CI/CD pipeline

Lessons Learned

This project taught me valuable lessons about building production-ready automation systems:
  1. Anti-detection is crucial - Modern websites have sophisticated bot protection that requires careful engineering to bypass ethically
  2. Error handling is everything - Web scraping is inherently fragile; robust error handling and logging are essential
  3. User experience matters - Fast, reliable notifications are only valuable if the user interface makes them actionable
  4. Scalability from day one - Cloud-native architecture made it easy to handle increased demand during peak shortage periods

Open Source

The complete Checkmate system is open source and available on GitHub:
The project demonstrates practical solutions to real-world problems using modern web technologies and cloud infrastructure. It's a testament to how individual developers can build systems that make a meaningful difference during challenging times.

Further Reading

Related Articles

Related by topics:

thingsIBuilt
python
docker
Belva AI: Building Voice Calling AI Agent

Developed voice calling AI agent with LLMs, speech recognition, and WebSockets.

By Xavier Collantes8/20/2025
thingsIBuilt
python
ai-agent
+12

HomeFeedback