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:
@@ -5,6 +5,7 @@ import { decrypt } from "@/lib/encryption"
|
||||
import { createProvider } from "@/lib/ai/provider-factory"
|
||||
import { rateLimit } from "@/lib/rate-limit"
|
||||
import { WHAT_CAN_I_MAKE_PROMPT, buildBarInventoryString } from "@/lib/ai/prompts"
|
||||
import { fuzzyMatchIngredients, recalculateMissingCount } from "@/lib/ingredient-matcher"
|
||||
|
||||
export async function POST() {
|
||||
const session = await auth()
|
||||
@@ -80,6 +81,21 @@ export async function POST() {
|
||||
suggestions = []
|
||||
}
|
||||
|
||||
// Post-process: fuzzy-match ingredients against bar inventory and re-sort
|
||||
if (barItems.length > 0) {
|
||||
suggestions = suggestions.map((s: { ingredients?: { name: string; amount: string; available: boolean }[]; missingCount?: number }) => {
|
||||
if (s.ingredients && Array.isArray(s.ingredients)) {
|
||||
s.ingredients = fuzzyMatchIngredients(s.ingredients, barItems)
|
||||
s.missingCount = recalculateMissingCount(s.ingredients)
|
||||
}
|
||||
return s
|
||||
})
|
||||
// Re-sort by missingCount ascending
|
||||
suggestions.sort((a: { missingCount?: number }, b: { missingCount?: number }) =>
|
||||
(a.missingCount ?? 99) - (b.missingCount ?? 99)
|
||||
)
|
||||
}
|
||||
|
||||
return NextResponse.json({ suggestions })
|
||||
} catch (error) {
|
||||
console.error("Bartender suggest error:", error)
|
||||
|
||||
Reference in New Issue
Block a user