Skip to content

Repository files navigation

πŸ›’ Amazon Price Monitor

A Python application that monitors Amazon product prices and sends notifications when prices drop below your target thresholds. Built with Crawl4AI for reliable price extraction and supports multiple notification methods.

alt text

alt text

✨ Features

  • Smart Price Extraction: Crawl4AI for Amazon price scraping
  • Notification: email alerts
  • Price History Tracking: Maintains historical price data with timestamps
  • Continuous Monitoring: Runs in background with configurable check intervals
  • Docker Support: Ready-to-run Docker container for Raspberry Pi and other platforms

alt text

πŸš€ Quick Start

Create .env file with

Email Notifications

SMTP_SENDER_EMAIL= SMTP_SENDER_PASSWORD= SMTP_RECIPIENT_EMAIL= SMTP_SERVER=smtp.gmail.com SMTP_PORT=587

On RasPi

hostname -I  # On the Pi

Or check your router's device list

Local Installation

  1. Clone and setup:
git clone <your-repo-url>
cd amazon-price-monitor
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
playwright install
  1. Configure your products:
cp config.example.json config.json
# Edit config.json with your product URLs and notification settings
  1. Run the monitor:
python amazon_price_monitor.py

Docker Installation (Recommended for Raspberry Pi)

  1. Setup:
chmod +x setup-pi.sh
./setup-pi.sh
  1. Configure and run:
# Edit config.json with your settings
docker-compose up -d
  1. Monitor logs:
docker-compose logs -f

βš™οΈ Configuration

Edit config.json to customize your monitoring:

{
    "products": [
        {
            "name": "Product Name",
            "url": "https://www.amazon.com/gp/product/B0XXXXXXXX/",
            "target_price": 50.00
        }
    ],
    "check_interval_minutes": 60,
    "email_notifications": {
        "enabled": true
    }
}

πŸ“§ Email Setup (Gmail)

For Gmail notifications:

  1. Enable 2-Factor Authentication
  2. Generate an App Password
  3. Use the app password (not your regular password) in config.json

πŸ”” Notification Types

  • Email Alerts: SMTP email notifications

πŸ“ Project Structure

amazon-price-monitor/
β”œβ”€β”€ README.md
β”œβ”€β”€ .env.example
β”œβ”€β”€ .env                    # Your actual environment variables
β”œβ”€β”€ .gitignore
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ setup.py               # Package setup
β”‚
β”œβ”€β”€ app/                   # Main application package
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py           # FastAPI app entry point
β”‚   β”œβ”€β”€ config.py         # Configuration management
β”‚   β”œβ”€β”€ dependencies.py   # FastAPI dependencies
β”‚   β”‚
β”‚   β”œβ”€β”€ api/              # API routes
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ deps.py       # API dependencies
β”‚   β”‚   └── v1/           # API version 1
β”‚   β”‚       β”œβ”€β”€ __init__.py
β”‚   β”‚       β”œβ”€β”€ api.py    # Main API router
β”‚   β”‚       └── endpoints/
β”‚   β”‚           β”œβ”€β”€ __init__.py
β”‚   β”‚           β”œβ”€β”€ products.py
β”‚   β”‚           β”œβ”€β”€ monitoring.py
β”‚   β”‚           └── status.py
β”‚   β”‚
β”‚   β”œβ”€β”€ core/             # Core business logic
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ config.py     # Settings and configuration
β”‚   β”‚   β”œβ”€β”€ security.py   # Security utilities
β”‚   β”‚   └── logging.py    # Logging configuration
β”‚   β”‚
β”‚   β”œβ”€β”€ models/           # Pydantic models
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ product.py
β”‚   β”‚   β”œβ”€β”€ monitoring.py
β”‚   β”‚   └──
β”‚   β”‚
β”‚   β”œβ”€β”€ services/         # Business logic services
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ price_monitor.py    # Main monitoring service
β”‚   β”‚   β”œβ”€β”€ notification.py     # Notification service
β”‚   β”‚   └── price_extractor.py  # Price extraction service
β”‚   β”‚
β”‚   └── utils/            # Utility functions
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ 
β”‚       └── exceptions.py
β”‚
β”œβ”€β”€ frontend/             # React frontend
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ package.json
β”‚   └── ...
β”‚
β”œβ”€β”€ tests/                # Test files
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ conftest.py
β”‚   β”œβ”€β”€ test_api/
β”‚   β”œβ”€β”€ test_services/
β”‚   └── test_utils/
β”‚
β”œβ”€β”€ scripts/              # Utility scripts
β”‚   β”œβ”€β”€ 
β”‚   β”œβ”€β”€ 
β”‚   └── 
β”‚
β”œβ”€β”€ data/                 # Data directory
β”‚   β”œβ”€β”€ config.json
β”‚   β”œβ”€β”€ price_history.json
β”‚   └── logs/
β”‚       └── app.log
β”‚
└── docs/                 # Documentation
    β”œβ”€β”€ 
    β”œβ”€β”€ 
    └── 

🐳 Docker Deployment

Perfect for running 24/7 on a Raspberry Pi or server:

Build and Run

# Build image
docker-compose build

# Run in background
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

Raspberry Pi Considerations

  • Use email notifications instead of desktop notifications
  • Consider longer check intervals (2-4 hours) to reduce load
  • Monitor resource usage: docker stats
  • Logs are persistent in ./logs/ directory

πŸ“Š Monitoring & Logs

Log Files

  • Application logs: price_monitor.log
  • Price history: price_history.json
  • Docker logs: docker-compose logs

Health Checks

# Check if container is healthy
docker-compose ps

# View resource usage
docker stats

# Follow live logs
docker-compose logs -f amazon-price-monitor

πŸ”§ Advanced Usage

Multiple Products

Add multiple products to monitor in config.json:

"products": [
    {
        "name": "Echo Dot",
        "url": "https://amazon.com/dp/B0757911C2",
        "target_price": 30.00
    },
    {
        "name": "iPad",
        "url": "https://amazon.com/dp/B09G9FPHY6",
        "target_price": 300.00
    }
]

Custom Check Intervals

"check_interval_minutes": 120  // Check every 2 hours

πŸ› οΈ Troubleshooting

Common Issues

Playwright Browser Error:

playwright install

Permission Denied (Docker):

sudo usermod -aG docker $USER
# Log out and back in

Price Extraction Fails:

  • Check if Amazon URL is accessible
  • Verify product page format hasn't changed
  • Check logs for specific error messages

Email Notifications Not Working:

  • Verify SMTP settings
  • Use app passwords for Gmail
  • Check firewall settings

Debug Mode

Add verbose logging:

logging.basicConfig(level=logging.DEBUG)

πŸ“ˆ Performance Tips

  • Check Intervals: Don't check too frequently (Amazon may block)
  • Resource Monitoring: Use docker stats to monitor usage
  • Log Rotation: Implement log rotation for long-running instances
  • Multiple Instances: Run separate containers for different product categories

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

This tool is for personal use only. Please respect Amazon's terms of service and robots.txt. Don't overload their servers with too frequent requests.


Happy deal hunting! 🎯

About

Amazon price tracking app with web scraping, email notifications, and price history. Containerized for easy deployment on Raspberry Pi.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages