A web application that monitors product availability on websites by regularly checking if specific text (indicating out-of-stock status) is present on a webpage.
- Automated Monitoring: Regularly checks target URLs for stock availability
- Web Dashboard: Beautiful, responsive web interface to monitor status
- Real-time Updates: Live status updates and check history
- Configurable: Easy configuration of target URL, check intervals, and stock indicators
- Azure Ready: Designed for deployment on Azure Container Apps
- Logging: Comprehensive logging with Winston
- Error Handling: Robust error handling with retry logic
- Security: Helmet.js security headers and CORS configuration
- Backend: Node.js with TypeScript and Express
- Frontend: Vanilla JavaScript with Tailwind CSS
- Monitoring: Cheerio for web scraping, Axios for HTTP requests
- Scheduling: Node-cron for automated checks
- Deployment: Docker containerization with Azure Container Apps
- Node.js 18 or higher
- npm or yarn
- Docker (for containerization)
- Azure CLI (for deployment)
-
Clone and setup:
cd d:\AIApps\Projects\InstockDetector npm install
-
Configure environment:
cp .env.example .env
Edit
.envfile with your settings:TARGET_URL=https://your-target-website.com/product CHECK_INTERVAL_MINUTES=5 OUT_OF_STOCK_TEXT=No products available yet -
Start development server:
npm run dev
-
Open browser: Navigate to
http://localhost:3000
npm run build npm start
| Variable | Description | Default |
|---|---|---|
NODE_ENV |
Environment mode | development |
PORT |
Server port | 3000 |
TARGET_URL |
URL to monitor | https://example.com |
CHECK_INTERVAL_MINUTES |
Check frequency in minutes | 5 |
OUT_OF_STOCK_TEXT |
Text indicating out of stock | No products available yet |
LOG_LEVEL |
Logging level | info |
You can also update configuration through the web interface:
- Click the "Settings" button in the top right
- Update Target URL, Check Interval, or Out of Stock Text
- Changes take effect immediately
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/api/status |
GET | Current stock status and statistics |
/api/history |
GET | Recent check history |
/api/check |
POST | Perform manual check |
/api/config |
POST | Update configuration |
/api/scheduler/start |
POST | Start automated monitoring |
/api/scheduler/stop |
POST | Stop automated monitoring |
-
Build and push container:
# Build the container docker build -t instock-detector . # Tag for Azure Container Registry docker tag instock-detector <your-acr>.azurecr.io/instock-detector:latest # Push to registry docker push <your-acr>.azurecr.io/instock-detector:latest
-
Deploy with Azure Developer CLI:
azd auth login azd init azd up
-
Or deploy with Bicep:
az deployment group create \ --resource-group <your-rg> \ --template-file infra/main.bicep \ --parameters targetUrl="https://your-site.com" \ --parameters containerImage="<your-acr>.azurecr.io/instock-detector:latest"
# Build docker build -t instock-detector . # Run docker run -p 3000:3000 \ -e TARGET_URL="https://your-site.com" \ -e CHECK_INTERVAL_MINUTES="5" \ -e OUT_OF_STOCK_TEXT="No products available yet" \ instock-detector
-
Amazon Product Page:
- URL:
https://amazon.com/product-page - Out of Stock Text:
Currently unavailable
- URL:
-
Custom Store:
- URL:
https://store.com/limited-edition-item - Out of Stock Text:
Sold out
- URL:
-
Shopify Store:
- URL:
https://store.shopify.com/products/item - Out of Stock Text:
Sorry, this item is out of stock
- URL:
// Check stock manually const response = await fetch('/api/check', { method: 'POST' }); const result = await response.json(); // Update configuration await fetch('/api/config', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ targetUrl: 'https://new-site.com', checkIntervalMinutes: 10, outOfStockText: 'Out of stock' }) });
The application provides comprehensive logging and monitoring:
- Health Endpoint:
/healthfor load balancer checks - Structured Logging: JSON formatted logs with Winston
- Azure Integration: Logs automatically sent to Azure Log Analytics
- Error Tracking: Failed requests and network errors are logged
- Performance Metrics: Response times and success rates tracked
- No Credentials Stored: Uses managed identity for Azure resources
- Security Headers: Helmet.js provides security headers
- CORS Configuration: Configurable cross-origin requests
- Input Validation: All user inputs are validated
- Rate Limiting: Built-in protection against abuse
- Container Security: Runs as non-root user
-
Connection Refused:
- Check if target website blocks automated requests
- Verify URL is accessible
- Check firewall settings
-
False Positives:
- Adjust the "Out of Stock Text" to be more specific
- Check if website structure changed
-
High Memory Usage:
- Reduce check interval
- Clear browser cache
- Monitor for memory leaks
View logs in different ways:
# Local development tail -f logs/combined.log # Docker container docker logs <container-id> # Azure Container Apps az containerapp logs show --name instock-detector --resource-group <rg>
├── src/ # TypeScript source code
│ ├── app.ts # Main Express application
│ ├── stockMonitor.ts # Core monitoring logic
│ ├── scheduler.ts # Cron job scheduling
│ ├── statusManager.ts # Status tracking
│ ├── logger.ts # Winston logging setup
│ └── types.ts # TypeScript type definitions
├── public/ # Static web assets
│ ├── index.html # Web dashboard
│ └── app.js # Frontend JavaScript
├── infra/ # Azure infrastructure as code
│ └── main.bicep # Bicep template
├── Dockerfile # Container configuration
└── azure.yaml # Azure Developer CLI config
# Run tests npm test # Run with coverage npm run test:coverage # Lint code npm run lint
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE file for details.
For issues and questions:
- Create an issue in the repository
- Check the troubleshooting section
- Review Azure Container Apps documentation