Initial project scaffold

Full-stack Dutch supermarket price tracker with FastAPI backend,
PostgreSQL/SQLAlchemy, Albert Heijn scraper, and Next.js frontend.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-04 22:27:24 +02:00
commit 486749a890
40 changed files with 1596 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import os
from logging.config import fileConfig
from alembic import context
from sqlalchemy import engine_from_config, pool
config = context.config
if config.config_file_name is not None:
fileConfig(config.config_file_name)
db_url = os.getenv("DATABASE_URL") or config.get_main_option("sqlalchemy.url")
config.set_main_option("sqlalchemy.url", db_url)
from app.models import Base # noqa: E402
target_metadata = Base.metadata
def run_migrations_offline() -> None:
context.configure(
url=db_url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
+25
View File
@@ -0,0 +1,25 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
revision: str = ${repr(up_revision)}
down_revision: Union[str, None] = ${repr(down_revision)}
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}
+85
View File
@@ -0,0 +1,85 @@
"""initial
Revision ID: 001
Revises:
Create Date: 2024-01-01 00:00:00.000000
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "001"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"stores",
sa.Column("id", sa.Integer(), primary_key=True),
sa.Column("name", sa.String(100), nullable=False),
sa.Column("slug", sa.String(50), nullable=False),
sa.Column("country", sa.String(2), server_default="NL"),
sa.Column("website", sa.String(255)),
sa.UniqueConstraint("slug", name="uq_stores_slug"),
)
op.create_table(
"products",
sa.Column("id", sa.Integer(), primary_key=True),
sa.Column("store_id", sa.Integer(), sa.ForeignKey("stores.id"), nullable=False),
sa.Column("external_id", sa.String(50), nullable=False),
sa.Column("ean", sa.String(20)),
sa.Column("name", sa.String(255), nullable=False),
sa.Column("brand", sa.String(100)),
sa.Column("category", sa.String(100)),
sa.Column("unit_size", sa.String(50)),
sa.Column("url", sa.String(500)),
sa.Column("created_at", sa.DateTime(), server_default=sa.func.now()),
sa.Column("updated_at", sa.DateTime(), server_default=sa.func.now()),
sa.UniqueConstraint("store_id", "external_id", name="uq_products_store_external"),
)
op.create_index("ix_products_ean", "products", ["ean"])
op.create_table(
"scrape_runs",
sa.Column("id", sa.Integer(), primary_key=True),
sa.Column("store_id", sa.Integer(), sa.ForeignKey("stores.id"), nullable=False),
sa.Column("query", sa.String(255), nullable=False),
sa.Column("started_at", sa.DateTime(), server_default=sa.func.now()),
sa.Column("finished_at", sa.DateTime()),
sa.Column("status", sa.String(20), server_default="running"),
sa.Column("products_found", sa.Integer(), server_default="0"),
sa.Column("error_message", sa.String(1000)),
)
op.create_table(
"price_snapshots",
sa.Column("id", sa.Integer(), primary_key=True),
sa.Column("product_id", sa.Integer(), sa.ForeignKey("products.id"), nullable=False),
sa.Column("scrape_run_id", sa.Integer(), sa.ForeignKey("scrape_runs.id"), nullable=False),
sa.Column("price", sa.Integer(), nullable=False),
sa.Column("unit_price", sa.Integer()),
sa.Column("unit_description", sa.String(50)),
sa.Column("currency", sa.String(3), server_default="EUR"),
sa.Column("discount_label", sa.String(100)),
sa.Column("discount_description", sa.String(255)),
sa.Column("was_price", sa.Integer()),
sa.Column("is_on_sale", sa.Boolean(), server_default="false"),
sa.Column("timestamp", sa.DateTime(), server_default=sa.func.now()),
)
op.create_index("ix_price_snapshots_timestamp", "price_snapshots", ["timestamp"])
op.create_index(
"ix_price_snapshots_product_timestamp",
"price_snapshots",
["product_id", "timestamp"],
)
def downgrade() -> None:
op.drop_table("price_snapshots")
op.drop_table("scrape_runs")
op.drop_table("products")
op.drop_table("stores")