WatchPulse

Monitor web pages, extract structured fields, and send alerts when the values you care about change.

Overview and requirements

WatchPulse is a self-hosted AI web monitor and structured extractor. Track prices, inventory, announcements, or other public page data. Review field-level changes and export the results as XLSX, CSV, or JSON.

  1. FetchHTTP or optional Chromium
  2. Extract and compareCSS, JSON-LD, or an LLM
  3. Record and notifySnapshots, changes, and alerts

A FastAPI backend runs extraction and scheduling. SQLAlchemy 2.0 persists state to SQLite or PostgreSQL, and Alembic manages the schema. The React 19 and TypeScript console talks to the versioned API. FastAPI serves the built frontend from frontend/dist.

  • For local installation, use Python 3.10+ and Node.js 20+ with npm. Node.js 22 matches the Docker build.
  • For the optional Docker installation, use Docker with the Compose plugin 2.24.0 or later. The image supplies Python and Node.js.
  • SQLite and CSS extraction work without an external database or LLM credentials. Install Chromium only for pages that need browser rendering.

Quickstart

Docker Compose (recommended)

From the extracted project root, start the application on a trusted machine. Compose can run without .env for a local evaluation.

docker compose up --build -d
docker compose ps
docker compose logs -f watchpulse

Open http://localhost:8000. To customize settings, copy .env.example to .env and restart with docker compose up -d. Set PORT in .env to change the published port. Compose stores SQLite data in the watchpulse_data volume.

Before exposing this installation, configure APP_ENV=production, a strong APP_SECRET_KEY, and the administrator credentials. Docker publishes the port on all interfaces by default. Put the application behind HTTPS and restrict direct access to its published port.

Windows PowerShell

.\scripts\start.ps1
.\scripts\start.ps1 -Demo -Port 8010
.\scripts\start.ps1 -SkipFrontendBuild

Linux and macOS

bash scripts/start.sh
bash scripts/start.sh --demo --port 8010
bash scripts/start.sh --skip-frontend-build

The launchers create .env from the example when needed, prepare backend/.venv, and build missing frontend assets. The skip option is handy for API-only work or when using an existing build. The server listens on 127.0.0.1. For a local demo, point DATABASE_URL at a separate SQLite file before launching.

Manual local development

Copy .env.example to .env if it is absent. Run these commands from the project root on Linux or macOS.

python3 -m venv backend/.venv
backend/.venv/bin/python -m pip install -r backend/requirements.txt
(cd frontend && if [ -f package-lock.json ]; then npm ci; else npm install; fi && npm run build)
(cd backend && .venv/bin/python -m alembic upgrade head)
backend/.venv/bin/python -m uvicorn app.main:app --app-dir backend --host 127.0.0.1 --port 8000

Use these equivalents in Windows PowerShell. Run the final command from the project root.

py -3 -m venv backend/.venv
.\backend\.venv\Scripts\python.exe -m pip install -r backend/requirements.txt
Push-Location frontend
if (Test-Path package-lock.json) { npm.cmd ci } else { npm.cmd install }
npm.cmd run build
Pop-Location
Push-Location backend
.\.venv\Scripts\python.exe -m alembic upgrade head
Pop-Location
.\backend\.venv\Scripts\python.exe -m uvicorn app.main:app --app-dir backend --host 127.0.0.1 --port 8000

Re-run npm run build in frontend after UI changes. Use --reload on the Uvicorn command for local Python development.

Environment variables

WatchPulse reads .env at the project root as UTF-8. Process environment variables take precedence. The middle column reproduces the assignments from .env.example, including empty values.

Variable.env.example assignmentPurpose and limits
APP_NAMEAPP_NAME=WatchPulseApplication name.
APP_ENVAPP_ENV=developmentproduction activates secret validation. The check trims whitespace and ignores case.
APP_SECRET_KEYAPP_SECRET_KEY=watchpulse-insecure-development-keySigns JWTs and derives the key for stored secrets. Production requires a non-default value of at least 32 characters after trimming.
DATABASE_URLDATABASE_URL=sqlite:///./data/watchpulse.dbRelative SQLite paths resolve from the project root. Compose defaults to sqlite:////app/data/watchpulse.db when unset.
CORS_ORIGINSCORS_ORIGINS=Comma-separated origins or a JSON array. The empty value is suitable for same-origin use.
ALLOW_PRIVATE_URLSALLOW_PRIVATE_URLS=falseEnable only for trusted installations that intentionally monitor internal hosts.
ALLOW_SELF_REGISTRATIONALLOW_SELF_REGISTRATION=trueControls whether users can sign up. Demo mode disables registration.
DEMO_MODEDEMO_MODE=falseEnables seeded demo data and simulated runs. Use a dedicated database.
SCHEDULER_ENABLEDSCHEDULER_ENABLED=trueRuns the scheduler in the backend process. Enable it in a single worker per database.
SCHEDULER_POLL_SECONDSSCHEDULER_POLL_SECONDS=15Time between scheduler polls. Must be greater than zero.
ADMIN_EMAILADMIN_EMAIL=Bootstrap administrator email. Configure together with ADMIN_PASSWORD.
ADMIN_PASSWORDADMIN_PASSWORD=Bootstrap administrator password. Configure together with ADMIN_EMAIL.
OPENAI_BASE_URLOPENAI_BASE_URL=https://api.openai.com/v1OpenAI-compatible base URL, typically ending in /v1. The extractor appends /chat/completions.
OPENAI_API_KEYOPENAI_API_KEY=Credential for the LLM provider.
OPENAI_MODELOPENAI_MODEL=gpt-4o-miniModel identifier sent to the provider.
SMTP_HOSTSMTP_HOST=SMTP server hostname.
SMTP_PORTSMTP_PORT=587SMTP port, from 1 to 65535.
SMTP_USERNAMESMTP_USERNAME=SMTP authentication username.
SMTP_PASSWORDSMTP_PASSWORD=SMTP authentication password.
SMTP_FROMSMTP_FROM=Sender address for email alerts.
SMTP_USE_TLSSMTP_USE_TLS=trueEnables SMTP STARTTLS.
JWT_EXPIRE_MINUTESJWT_EXPIRE_MINUTES=1440Bearer token lifetime in minutes. Minimum 1.
MAX_FETCH_BYTESMAX_FETCH_BYTES=3145728Fetch size limit in bytes, from 1 to 3,145,728 (3 MiB).
FETCH_TIMEOUT_SECONDSFETCH_TIMEOUT_SECONDS=15Fetch timeout in seconds. Greater than zero and at most 120.

When ADMIN_EMAIL is unset, the first successful registration in an empty database creates an administrator. That requires self-registration to be enabled and demo mode to be off. Set both administrator variables before the first start of a public instance, then set ALLOW_SELF_REGISTRATION=false unless you intend to accept signups.

Administrators can save LLM and SMTP overrides in Settings. If changing those values in .env has no effect, check the stored integration settings.

Extraction modes

css_rules

Give each field a name and a CSS selector. The rule can read an attribute such as href, content, or data-price. Use a regex to extract a subgroup and set field_type to number or price to store numeric values. Price parsing handles common formats such as $1,299.50 and €49,99.

Use the jsonld: pseudo-selector to read a key from embedded JSON-LD. This request body is suitable for POST /api/v1/monitors/test-extract and uses inline HTML.

{
  "extraction_mode": "css_rules",
  "html": "<span class='price'>USD $1,299.50</span><script type='application/ld+json'>{\"@type\":\"Product\",\"name\":\"Espresso Pro\"}</script>",
  "rules": [
    {"name":"price","selector":".price","regex":"USD\\s+(.+)","field_type":"price"},
    {"name":"product","selector":"jsonld:name","field_type":"text"}
  ]
}

llm_extract

Define llm_schema as a list of fields with name, description, and field_type. Use llm_prompt for instructions specific to the page. WatchPulse sends cleaned page text to Chat Completions and requests a JSON object. Select a provider and model that support JSON output.

ProviderOPENAI_BASE_URLOPENAI_MODELOPENAI_API_KEY
OpenAIhttps://api.openai.com/v1gpt-4o-miniOpenAI API key
OpenRouterhttps://openrouter.ai/api/v1openai/gpt-4o-miniOpenRouter API key
DeepSeekhttps://api.deepseek.comdeepseek-chatDeepSeek API key
Ollamahttp://127.0.0.1:11434/v1llama3.1ollama (non-empty placeholder for a local Ollama server)

For Ollama, run ollama pull llama3.1 on the Ollama host. The local URL assumes WatchPulse and Ollama share the same host network. From a WatchPulse container, use an address reachable from that container, such as the Ollama service name on a shared Docker network.

hybrid

Combine CSS rules with an LLM schema. WatchPulse gates LLM calls on the normalized page-content hash, so identical checks can reuse the previous extraction and avoid repeated token charges. Add selectors for rotating banners, timestamps, or other noise to ignore_selectors to keep them out of the hash.

Alerts and webhooks

Create a webhook or email channel, attach it to a monitor, and choose one condition for that monitor. Use the channel test to check connectivity and see the result in delivery logs.

alert_condition.typeWhen it firesExample condition
any_changeA structured field is added, removed, or changed.{"type":"any_change"}
field_changedThe named extracted field changes.{"type":"field_changed","field":"stock"}
price_drop_pctThe named numeric field drops by at least the percentage threshold.{"type":"price_drop_pct","field":"price","threshold":10}
keyword_matchA keyword match occurs in newly matching content.{"type":"keyword_match","keyword":"back in stock"}

Select generic for your own JSON receiver, slack for a Slack incoming webhook, or discord for a Discord webhook. Email channels use the configured SMTP server and the channel's recipient address.

Verify HMAC-SHA256 signatures

When a webhook channel has a secret, WatchPulse sends X-WatchPulse-Signature: sha256=<hex>. Sign the exact request body bytes using the same UTF-8 secret and compare the digests in constant time. Capture the raw body before JSON parsing and reject requests with missing or invalid signatures before handling the event.

import hashlib
import hmac
import re


def verify_watchpulse(raw_body: bytes, signature: str | None, secret: str) -> bool:
    if not secret or not signature or not re.fullmatch(r"sha256=[0-9a-f]{64}", signature):
        return False
    expected = hmac.new(secret.encode("utf-8"), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(signature, f"sha256={expected}")


# Pass the raw request bytes and the X-WatchPulse-Signature header.
const { createHmac, timingSafeEqual } = require("node:crypto");

function verifyWatchPulse(rawBody, signature, secret) {
  if (!secret || !Buffer.isBuffer(rawBody) ||
      typeof signature !== "string" || signature.length !== 71 ||
      !/^sha256=[0-9a-f]{64}$/.test(signature)) {
    return false;
  }
  const expected = createHmac("sha256", secret).update(rawBody).digest();
  const supplied = Buffer.from(signature.slice(7), "hex");
  return timingSafeEqual(supplied, expected);
}

// Pass a Buffer and the value of req.headers["x-watchpulse-signature"].

Security and SSRF

  • Keep ALLOW_PRIVATE_URLS=false for any public deployment. WatchPulse checks HTTP(S) monitor and webhook destinations against a public-address policy that blocks loopback, private, link-local, and other non-public addresses. The HTTP fetcher pins vetted addresses and checks redirects. Playwright checks browser requests against the URL policy.
  • WatchPulse hashes user passwords with scrypt. API access uses expiring bearer tokens, resource ownership checks, and administrator-only settings.
  • Fernet encrypts saved LLM keys, SMTP passwords, and webhook signing secrets at rest. Back up the database and APP_SECRET_KEY separately. Rotating the key invalidates existing tokens and can require saving integration credentials again. Restrict access to any environment file containing credentials.
  • XLSX and CSV exports neutralize formula-like strings to reduce spreadsheet injection risk. Numeric values remain numeric.
  • Use HTTPS on public deployments, and fetch only pages you are authorized to monitor.

Host a public Live Demo

Deploy the demo from a dedicated copy of the project, on a separate hostname and with a dedicated database. Use the Compose override to enable DEMO_MODE=true, disable self-registration and the scheduler, block private destinations, and mount watchpulse_demo_data at /app/data.

Generate a unique value with python -c "import secrets; print(secrets.token_hex(32))". Store it as WATCHPULSE_DEMO_SECRET in the demo host's environment or its Compose .env. The override uses it for production APP_SECRET_KEY validation. Keep real monitoring data and live integration credentials outside this deployment.

docker compose -p watchpulse-demo -f docker-compose.yml -f docker-compose.demo.yml up --build -d
docker compose -p watchpulse-demo -f docker-compose.yml -f docker-compose.demo.yml ps
curl -fsS http://127.0.0.1:8000/api/v1/health

Choose an unused PORT in the demo's Compose environment when running both instances on one host. Put the public demo behind a TLS reverse proxy and allow inbound access through the proxy.

In a private browser window, check Demo Login, seeded monitors and history, a simulated run, CSS extraction with inline HTML, and a spreadsheet export. The health response should show demo_mode: true, allow_self_registration: false, and scheduler_enabled: false. Monitor and channel edits, integration-setting writes, and live extraction requests are restricted in demo mode.

PostgreSQL and Alembic migrations

Provision a PostgreSQL database and a user with permission to create the application schema. Set DATABASE_URL in the project-root .env for a local deployment. URL-encode reserved characters in connection credentials. Add connection TLS options as required by your provider.

DATABASE_URL=postgresql+psycopg://USER:PASSWORD@db.example.net:5432/watchpulse?sslmode=require

With Compose, set DATABASE_URL in the project-root .env (or shell environment), then run the migrations before starting the service.

docker compose build
docker compose run --rm --no-deps --workdir /app/backend watchpulse python -m alembic upgrade head
docker compose up -d

For local deployments, run python -m alembic upgrade head from backend/ using the backend virtual environment. Run python -m alembic current in the same environment to check the applied revision. Back up existing data before upgrading. Alembic updates the schema on the selected database. Moving rows from an old SQLite database to PostgreSQL is a separate data migration.

Optional Playwright Chromium rendering

Use render_mode=playwright when the page renders the monitored fields in JavaScript. Install the package and Chromium using the same Python environment and OS user that run WatchPulse.

In the monitor editor or rule tester, set Wait for CSS selector (wait_for_selector in the API) when the target element appears after the page loads. Playwright waits briefly for a matching element to enter the DOM before capturing the page. The selector is optional and supports up to 500 characters. If the wait times out, WatchPulse continues with the available page content.

python -m pip install playwright
python -m playwright install chromium

On Linux, use python -m playwright install --with-deps chromium when system libraries also need installing. In Docker, build the image with the optional browser dependencies.

docker compose build --build-arg INSTALL_PLAYWRIGHT=true watchpulse
docker compose up -d

Apply the same Compose file flags to both commands when using an override. The health endpoint reports whether the Python Playwright package is present. Test a browser-rendered monitor to confirm the Chromium binary and its dependencies work.

API reference

At runtime, open http://localhost:8000/docs for the interactive OpenAPI reference and request schemas. API paths below use the /api/v1 prefix. Send Authorization: Bearer <access_token> for authenticated requests.

AreaRoutes relative to /api/v1
Health and authGET /health, POST /auth/register, POST /auth/login, POST /auth/demo-login, GET /auth/me
DashboardGET /dashboard/summary
MonitorsGET/POST /monitors, GET/PATCH/DELETE /monitors/{id}, POST /monitors/{id}/run, GET /monitors/{id}/snapshots, POST /monitors/test-extract
ChangesGET /changes, GET /changes/{id}
Channels and deliveriesGET/POST /channels, PATCH/DELETE /channels/{id}, POST /channels/{id}/test, GET /deliveries
SettingsGET/PUT /settings (administrator access)
ExportsGET /exports/xlsx, GET /exports/csv, GET /exports/json. Add ?monitor_id=123 for a single monitor.

Commercial licensing

Standard / Regular License
Use and customize WatchPulse for one internal or free-to-use public deployment, subject to the terms of purchase.
Extended SaaS License
Use and customize WatchPulse as part of a hosted service that charges end users, subject to the terms of purchase.

Both tiers prohibit repackaging and reselling WatchPulse as a competing source kit, template, or boilerplate. Marketplace purchases follow the marketplace license and listing terms. See LICENSE.txt in the source ZIP for the product summary and third-party notices.

Open-source package attributions

Direct dependencies and runtime componentsUpstream license
FastAPI, SQLAlchemy, Alembic, Pydantic, pydantic-settings, Beautiful Soup 4, openpyxl, ReactMIT
Uvicorn, HTTPX, httpcoreBSD 3-Clause
python-multipart, TypeScript, optional PlaywrightApache License 2.0
cryptographyApache License 2.0 or BSD 3-Clause
regexApache License 2.0 and CNRI Python License
Psycopg 3GNU LGPL 3.0
SQLite / PostgreSQLPublic domain / PostgreSQL License

See LICENSE.txt for upstream notices. Installed versions and transitive dependencies carry their own license files. Retain the required notices when redistributing images or binaries, including optional Chromium and the components in the Docker base images.

Troubleshooting

The app fails to start in production

Check the logs. Set a non-default APP_SECRET_KEY of at least 32 characters and configure both administrator values together or leave both blank. For the demo override, set WATCHPULSE_DEMO_SECRET.

The port is already in use

Set PORT=8010 in the Compose environment, or use -Port 8010 on Windows and --port 8010 on Linux or macOS.

The API works but the console is missing or stale

Run npm run build in frontend/ and confirm frontend/dist/index.html exists. With Docker, rebuild the image and recreate the service with docker compose up --build -d.

A selector returns an empty field

Try the rule on a minimal inline HTML sample. Check the attribute, regex, and JSON-LD key. If the live HTML lacks the relevant element and JavaScript creates it, use the Chromium renderer.

A monitor is blocked or timing out

Confirm that its URL and redirects resolve to public addresses and that the response fits the configured timeout and fetch size limits. The origin may require access that your deployment does not have.

Some proxies use Fake-IP DNS to return addresses in the reserved 198.18.0.0/15 range. WatchPulse blocks this range under its public-address policy. Disable Fake-IP DNS for the target or configure a public resolver. Keep ALLOW_PRIVATE_URLS=false on public deployments.

LLM extraction or webhook delivery fails

For LLM calls, check the base URL, model identifier, key, and support for JSON output. For webhooks, test the channel, inspect the delivery log, and confirm that the destination accepts the chosen payload format and that any receiver-side signature check uses the raw request body.

Scheduled checks do not run

Check that the monitor is active and /api/v1/health reports scheduler_enabled: true. The public demo disables scheduling by design.