Add recipes, images, AI photo ID, barcode scanning & ingredient matching

- Fuzzy ingredient matching for bar inventory against recipes
- AI photo identification API for bottles/labels (drink + bar context)
- Barcode scanner with photo toggle for My Bar
- Barcode scan + photo ID buttons on Add Drink form
- Auto-pull product images from Open Food Facts barcode lookup
- Recipes section on drink detail pages with bar availability
- Dedicated Recipes page in sidebar navigation
- Bar item image support (schema, upload, display)
- Drink detail image upload component
- MinIO image proxy through Next.js rewrites (fixes broken image links)
- Improved category mapping (energy drinks → Mixers, not Spirits)
- Re-process saved recipe ingredients against current bar inventory

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
JP Scott
2026-03-04 22:26:17 -07:00
parent 2ac2c4b2d4
commit dc1ad4d0c0
36 changed files with 1892 additions and 144 deletions

View File

@@ -2,6 +2,7 @@ import { NextResponse } from "next/server"
import { auth } from "@/lib/auth"
import { prisma } from "@/lib/prisma"
import { recipeCreateSchema } from "@/lib/validators"
import { fuzzyMatchIngredients, recalculateMissingCount } from "@/lib/ingredient-matcher"
import type { Prisma } from "@prisma/client"
export async function GET() {
@@ -11,17 +12,40 @@ export async function GET() {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
const recipes = await prisma.recipe.findMany({
where: { userId: session.user.id },
orderBy: { createdAt: "desc" },
include: {
sourceDrink: {
select: { name: true, type: true },
const [recipes, barItems] = await Promise.all([
prisma.recipe.findMany({
where: { userId: session.user.id },
orderBy: { createdAt: "desc" },
include: {
sourceDrink: {
select: { name: true, type: true },
},
},
},
}),
prisma.barItem.findMany({
where: {
userId: session.user.id,
quantity: { not: "EMPTY" },
},
select: { name: true },
}),
])
// Re-process ingredient availability against current bar inventory
const processedRecipes = recipes.map((recipe) => {
if (barItems.length > 0 && Array.isArray(recipe.ingredients)) {
const ingredients = recipe.ingredients as { name: string; amount: string; available: boolean }[]
const matched = fuzzyMatchIngredients(ingredients, barItems)
return {
...recipe,
ingredients: matched,
missingCount: recalculateMissingCount(matched),
}
}
return recipe
})
return NextResponse.json({ recipes })
return NextResponse.json({ recipes: processedRecipes })
} catch (error) {
console.error("GET /api/recipes error:", error)
return NextResponse.json(