Public Access
R1 stabilization: pytest harness with transactional db fixture, smoke + alembic + auth + scrape + approval + swiftly tests, github actions ci yaml. Bearer-token admin auth + signed-cookie session for family ui mutations. Async POST /api/admin/scrape (BackgroundTasks, returns 202). Path canonicalization (no /list, /planned suffixes). DATABASE_URL fail-fast on empty. R2 deferred-risk spikes: live lucky california fetch (R2-A), full email+per-voter approval click round trip with single-use enforcement (R2-B, console email backend, sendgrid stub). R3-0 phase 3 redesign: replaced playwright html scraper with requests based swiftly json api client. 17 categories, ~10k products per scrape, upsert by (source, external_id). 401 surfaces actionable token-refresh message via ScrapeLog.error_message. Pre-existing defects fixed: shopping_list.py syntax error blocking app import, MealPlan.votes orphan relationship, JSONB(astext=True) invalid kwarg, missing requests dep, calorie_target schema drift, every SQLEnum needed values_callable, 0001 had empty downgrade(), seed had duplicate ingredient rows. Migrations added: 0003 grocery_item.description, 0004 family_profile. calorie_target, 0005 grocery_item.external_id + source + composite index. Verified: 31/31 pytest green, alembic upgrade->downgrade->upgrade clean, frontend npm run build clean, live scrape 9,960 grocery_item rows in 36s. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from pydantic_settings import BaseSettings
|
|
from pydantic import model_validator
|
|
from typing import Optional
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# Required — fail fast at import time if unset.
|
|
DATABASE_URL: str = ""
|
|
|
|
SENDGRID_API_KEY: Optional[str] = None
|
|
EMAIL_BACKEND: str = "console"
|
|
LUCKY_CA_URL: str = "https://www.luckyncal.com"
|
|
# R3-0: Swiftly product API (replaces Playwright path).
|
|
SWIFTLY_BEARER_TOKEN: str = ""
|
|
LUCKY_STORE_ID: str = "757"
|
|
SWIFTLY_API_BASE: str = "https://prod.swiftlyapi.net"
|
|
SWIFTLY_CATEGORIES_URL: str = "https://luckysupermarkets.com/categories"
|
|
AI_IMAGE_ENABLED: bool = False
|
|
AI_IMAGE_PROVIDER: Optional[str] = None
|
|
AI_IMAGE_API_KEY: Optional[str] = None
|
|
LOG_LEVEL: str = "INFO"
|
|
SECRET_KEY: str = "dev-secret-key"
|
|
|
|
# Auth (R1-B+D)
|
|
ADMIN_TOKEN: str = ""
|
|
SESSION_PASSWORD: str = ""
|
|
|
|
FAMILY_EMAIL_1: Optional[str] = None
|
|
FAMILY_EMAIL_2: Optional[str] = None
|
|
RECIPES_EMAIL: Optional[str] = None
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
|
|
@model_validator(mode="after")
|
|
def _require_database_url(self) -> "Settings":
|
|
if not self.DATABASE_URL:
|
|
raise RuntimeError("DATABASE_URL is required")
|
|
return self
|
|
|
|
|
|
settings = Settings()
|