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>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from fastapi import FastAPI, Depends
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
from app.database import get_db
|
|
from app.config import settings
|
|
import logging
|
|
|
|
logging.basicConfig(level=settings.LOG_LEVEL)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
app = FastAPI(
|
|
title="MealPlanner",
|
|
description="Self-hosted meal planning system",
|
|
version="0.1.0",
|
|
)
|
|
|
|
|
|
@app.get("/health")
|
|
def health_check(db: Session = Depends(get_db)):
|
|
return {"status": "ok"}
|
|
|
|
|
|
@app.get("/health/db")
|
|
def health_check_db(db: Session = Depends(get_db)):
|
|
try:
|
|
db.execute(text("SELECT 1"))
|
|
return {"status": "ok", "database": "connected"}
|
|
except Exception as e:
|
|
return {"status": "error", "database": "disconnected", "error": str(e)}
|
|
|
|
|
|
from app.api import profile, recipes, meals, shopping_list, pantry, admin, auth
|
|
|
|
app.include_router(auth.router, prefix="/api/auth", tags=["auth"])
|
|
app.include_router(profile.router, prefix="/api/profile", tags=["profile"])
|
|
app.include_router(recipes.router, prefix="/api/recipes", tags=["recipes"])
|
|
app.include_router(meals.router, prefix="/api/meals", tags=["meals"])
|
|
app.include_router(shopping_list.router, prefix="/api/shopping-list", tags=["shopping-list"])
|
|
app.include_router(pantry.router, prefix="/api/pantry", tags=["pantry"])
|
|
app.include_router(admin.router, prefix="/api/admin", tags=["admin"])
|