Skip to content

About

Price tracker built with Spring Boot

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

bitdotfree — Price Tracker

A price tracker built with Spring Boot and PostgreSQL. It runs on a schedule via GitHub Actions, fetches prices from retailer APIs, stores history in Supabase, and sends a summary to Discord.


Architecture

GitHub Actions (cron: daily)
        │
        ▼
Spring Boot App (CommandLineRunner)
        │
        ├── Reads active products from Supabase (PostgreSQL)
        ├── Looks up domain config (API URL, SKU regex, price field)
        ├── Fetches price from retailer's internal JSON API
        ├── Saves price snapshot to price_records table
        └── Posts summary to Discord webhook

Tech Stack

Layer Technology
App Spring Boot 4.1 (Java 21)
Database Supabase (free hosted PostgreSQL)
Price fetching Java HttpClient + Jackson (JSON parsing)
Notifications Discord webhook
Automation GitHub Actions
Build tool Maven

Database Schema

products

The configurable watch list. Add a row to start tracking a product, set active = false to pause it without losing history.

Column Type Description
id bigserial Primary key
name text Human-friendly label (e.g. "Sony WH-1000XM6")
url varchar Product page URL
active boolean Whether to scrape on each run
created_at timestamptz When it was added

domain_configs

Tells the scraper how to fetch a price for any product from a given domain. One row per retailer.

Column Type Description
id bigserial Primary key
domain text Bare hostname (e.g. www.bestbuy.ca)
api_url_template varchar API endpoint with {sku} placeholder
sku_regex varchar Regex with one capture group to extract the product ID from the URL
price_field varchar JSON key that holds the price (e.g. salePrice)
created_at timestamptz When it was added

price_records

One row per price check — the full history.

Column Type Description
id bigserial Primary key
product_id bigint FK → products
price numeric(12,2) Price at time of scrape
currency varchar Currency code (e.g. CAD)
scraped_at timestamptz When the price was recorded

Setup

Prerequisites

  • Java 21 (Temurin)
  • Maven (brew install maven on Mac)
  • psql (brew install libpq on Mac)
  • A free Supabase account
  • A Discord server with a webhook URL

1. Clone the repo

git clone https://github.com/YOUR_USERNAME/bitdotfree.git
cd bitdotfree

2. Create a Supabase project

  1. Go to supabase.com and create a new project
  2. Under Connect, grab the Session pooler connection string (not Direct — it is IPv6 only and will not work in GitHub Actions)
  3. Disable the Data API in project settings (not needed — the app connects via JDBC directly)

3. Configure environment variables

DB_URL=jdbc:postgresql://aws-x-us-east-1.pooler.supabase.com:5432/postgres?sslmode=require
DB_USERNAME=postgres.yourprojectref
DB_PASSWORD=your-supabase-password
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...

4. Run the initial migration

Creates the schema in your Supabase database:

./scripts/db/migrate.sh

5. Add a domain config

Tells the scraper how to fetch prices from a retailer. Example for Best Buy CA:

./scripts/domains/add.sh \
  "www.bestbuy.ca" \
  "https://www.bestbuy.ca/api/offers/v1/products/{sku}/offers" \
  "/([0-9]+)$" \
  "salePrice"

6. Add your first product

./scripts/products/add.sh \
  "Sony WH-1000XM6" \
  "https://www.bestbuy.ca/en-ca/product/sony-wh-1000xm6/.../19320383"

7. Run locally

./scripts/run-local.sh

GitHub Actions

The workflow in .github/workflows/scrape.yml runs daily.

Adding secrets

Go to your repo → Settings → Secrets and variables → Actions → New repository secret.

Add the same four variables from your .env:

  • DB_URL
  • DB_USERNAME
  • DB_PASSWORD
  • DISCORD_WEBHOOK_URL

Manual trigger

Go to Actions → Price Tracker → Run workflow to trigger a run on demand.


Scripts Reference

All scripts load .env automatically.

Script Usage Description
run-local.sh ./scripts/run-local.sh Boot the app locally
products/add.sh ./scripts/products/add.sh <name> <url> Add a product to the watch list
products/remove.sh ./scripts/products/remove.sh <id> Deactivate a product (preserves history)
products/list.sh ./scripts/products/list.sh List all products with latest price
domains/add.sh ./scripts/domains/add.sh <domain> <api-url> <sku-regex> <price-field> Add or update a domain config
db/migrate.sh ./scripts/db/migrate.sh Run pending SQL migrations

Adding a New Retailer

  1. Open DevTools → Network tab → reload the product page and filter for JSON requests to find the retailer's internal price API
  2. Identify the JSON field that holds the price
  3. Write a regex that captures the product ID from the product page URL
  4. Add the domain config and then add products from that domain:
./scripts/domains/add.sh "<domain>" "<api-url-with-{sku}>" "<sku-regex>" "<price-field>"
./scripts/products/add.sh "<name>" "<product-url>"

About

Price tracker built with Spring Boot

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages