commit 9fae4e8349c395e71f440fd1f101fdf529261527 Author: shockrah Date: Thu May 7 20:21:48 2026 -0700 Basic sql and linting diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3615fef --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: + - repo: https://github.com/sqlfluff/sqlfluff + rev: 3.0.7 # Use the latest stable version + hooks: + - id: sqlfluff-lint + args: [--dialect, postgres] + # Only run on files in the db/ directory ending in .sql + files: ^collector/db/.*\.sql$ diff --git a/collector/db/Dockerfile b/collector/db/Dockerfile new file mode 100644 index 0000000..bb3eee4 --- /dev/null +++ b/collector/db/Dockerfile @@ -0,0 +1,10 @@ +FROM postgres:16-alpine + +# Test variables - do not use these in real builds >:( +ENV POSTGRES_DB=collector_db +ENV POSTGRES_USER=collector_user +ENV POSTGRES_PASSWORD=collector_dev_sample123 + + +COPY init.sql /docker-entrypoint-initdb.d/ + diff --git a/collector/db/init.sql b/collector/db/init.sql new file mode 100644 index 0000000..4ee354a --- /dev/null +++ b/collector/db/init.sql @@ -0,0 +1,2 @@ +\i stores.sql; +\i products.sql; diff --git a/collector/db/items.sql b/collector/db/items.sql new file mode 100644 index 0000000..70867a2 --- /dev/null +++ b/collector/db/items.sql @@ -0,0 +1,23 @@ +-- Modeling the products +CREATE TABLE products ( + -- Internal product ID + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + + -- Store-specific Identifiers + business_id UUID REFERENCES businesses (id) NOT NULL, + + -- Product Details + product_name VARCHAR(255) NOT NULL, + product_type VARCHAR(100), -- e.g., 'service', 'goods' + + -- Pricing (Numeric is preferred over Float for money) + -- Also tracking in USD at the time + price NUMERIC(12, 2) NOT NULL, + currency VARCHAR(100) NOT NULL, + + -- Also tracking the price per unit + unit_type VARCHAR(100) NOT NULL, -- e.g. 'item', 'weight', 'hour', etc. + + -- Tracking time that we checked + track_time TIMESTAMPTZ DEFAULT current_timestamp +); diff --git a/collector/db/lint.sh b/collector/db/lint.sh new file mode 100644 index 0000000..5ad183c --- /dev/null +++ b/collector/db/lint.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +set -e + +sqlfluff lint --dialect postgres *.sql diff --git a/collector/db/readme.md b/collector/db/readme.md new file mode 100644 index 0000000..2dd937f --- /dev/null +++ b/collector/db/readme.md @@ -0,0 +1,5 @@ +# Collecter DB + + +Here we are setting up the schemas for housing all the data +regarding the stuff we track. diff --git a/collector/db/stores.sql b/collector/db/stores.sql new file mode 100644 index 0000000..2eca483 --- /dev/null +++ b/collector/db/stores.sql @@ -0,0 +1,6 @@ +-- Modeling the stores that we track overall + +CREATE TABLE businesses ( + store_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + store_name VARCHAR(255) NOT NULL +); diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..a642bb0 --- /dev/null +++ b/readme.md @@ -0,0 +1,16 @@ +# Cash Tracker + + +This project is a special personal graphing service thing that I personally use +to scrape and track the prices of real things that people actually buy in stores +and around town. + +# Why? + +There are tons of tools to track the prices of securities, commodities, bonds, +options, stocks, futures, assets, and tons of other finnancial products/services +but for the layperson this is all greek. This project aims to track things that +they would see in a store so they could say "huh `some food` at +`my favorite grocery store` went up/down by `some_amount` in the last `time interval`. + +