Add Doris Kitchen household recipe app

This commit is contained in:
Fizzlepoof
2026-05-16 20:22:45 +00:00
parent 19f1f8c5e3
commit 9f614ca0e7
30 changed files with 2009 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
from fastapi import APIRouter, HTTPException, Request
from app.services.planner import planner
from app.services.repository import repo
from app.services.store import JsonStore
router = APIRouter(prefix="/api/planner", tags=["planner"])
store = JsonStore()
@router.post("/generate")
async def generate_plan(request: Request):
payload = await request.json()
week_start = str(payload.get("week_start") or "").strip()
if not week_start:
raise HTTPException(status_code=400, detail="week_start is required.")
anchors = payload.get("anchors") or []
if isinstance(anchors, str):
anchors = [line.strip() for line in anchors.splitlines() if line.strip()]
target_meals = max(3, min(7, int(payload.get("target_meals") or 5)))
plan = planner.generate(week_start=week_start, anchors=list(anchors), target_meals=target_meals)
record = {"id": store.new_id("mealplan"), **plan, "created_at": store.now()}
repo.create_meal_plan(record)
return {"status": "ok", "plan": record}