
- FastAPI application that monitors websites for updates - SQLite database with Website and WebsiteAlert models - REST API endpoints for website management and alerts - Background scheduler for automatic periodic checks - Content hashing to detect website changes - Health check endpoint and comprehensive documentation - Alembic migrations for database schema management - CORS middleware for cross-origin requests - Environment variable configuration support Co-Authored-By: Claude <noreply@anthropic.com>
86 lines
2.3 KiB
Markdown
86 lines
2.3 KiB
Markdown
# Website Update Alert Service
|
|
|
|
A FastAPI application that monitors websites for updates and provides alerts when changes are detected.
|
|
|
|
## Features
|
|
|
|
- Add websites to monitor with custom check intervals
|
|
- Automatic periodic checking for website updates
|
|
- REST API for managing websites and viewing alerts
|
|
- Background scheduler for continuous monitoring
|
|
- SQLite database for data persistence
|
|
|
|
## API Endpoints
|
|
|
|
### Base
|
|
- `GET /` - Service information and documentation links
|
|
- `GET /health` - Health check endpoint
|
|
- `GET /docs` - Interactive API documentation
|
|
- `GET /redoc` - Alternative API documentation
|
|
|
|
### Websites
|
|
- `POST /websites/` - Add a new website to monitor
|
|
- `GET /websites/` - List all monitored websites
|
|
- `GET /websites/{id}` - Get specific website details
|
|
- `PUT /websites/{id}` - Update website settings
|
|
- `DELETE /websites/{id}` - Remove website from monitoring
|
|
- `POST /websites/{id}/check` - Manually trigger a check for updates
|
|
- `GET /websites/{id}/alerts` - Get alerts for a specific website
|
|
|
|
### Alerts
|
|
- `GET /alerts/` - List all alerts (with optional unread filter)
|
|
- `PUT /alerts/{id}/mark-read` - Mark an alert as read
|
|
|
|
## Installation and Setup
|
|
|
|
1. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. Run the application:
|
|
```bash
|
|
uvicorn main:app --host 0.0.0.0 --port 8000
|
|
```
|
|
|
|
The application will be available at `http://localhost:8000`
|
|
|
|
## Environment Variables
|
|
|
|
- `CHECK_INTERVAL_MINUTES` - How often to check all websites (default: 5 minutes)
|
|
|
|
## Database
|
|
|
|
The application uses SQLite with automatic database creation. The database file is stored at `/app/storage/db/db.sqlite`.
|
|
|
|
## Example Usage
|
|
|
|
1. Add a website to monitor:
|
|
```bash
|
|
curl -X POST "http://localhost:8000/websites/" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"url": "https://example.com",
|
|
"name": "Example Website",
|
|
"check_interval_minutes": 60
|
|
}'
|
|
```
|
|
|
|
2. List all websites:
|
|
```bash
|
|
curl "http://localhost:8000/websites/"
|
|
```
|
|
|
|
3. Get alerts:
|
|
```bash
|
|
curl "http://localhost:8000/alerts/"
|
|
```
|
|
|
|
## How It Works
|
|
|
|
1. Websites are checked periodically based on their individual check intervals
|
|
2. Content is hashed (MD5) to detect changes
|
|
3. When changes are detected, alerts are created
|
|
4. Background scheduler runs every 5 minutes to check websites that are due for checking
|
|
5. Manual checks can be triggered via the API
|