BLOCK 1 — Orders persistence + expiration:
- New GET /api/[slug]/orders loads active orders from PostgreSQL on mount, so the
dashboard survives reloads (SSE only carries live events); it also prunes
completed orders older than the retention window on read (no cron)
- Restaurant.orderRetentionHours (default 24, migration 0007) + editor control in
the Orders tab; settings PATCH accepts it
BLOCK 2 — Smart cart pairings (precomputed, zero tokens at runtime):
- Restaurant.pairings JSON (migration 0008) stores { productId: [productId] }
- Optional 'Generate smart suggestions' checkbox in the publish modal; on publish,
one cheap Haiku call analyzes the snapshot and stores validated complements
(lib/pairings.ts, reuses parseLenientJson). AI failure never breaks publishing
- pairings read live and exposed via the public menu; cart shows an auto-rotating,
swipeable SuggestionCarousel of complements for what's in the cart (excluding
items already added), each with Add — only when orders are on and pairings exist
BLOCK 3 — Brand header:
- Restaurant.bannerImage, profileImage, socialLinks (migration 0009)
- New editor Brand tab: upload banner + circular logo (reuses /upload), social
links with common-platform suggestions and basic URL validation; saved via settings
- Public BrandHeader: full-bleed banner (edge-to-edge behind the island, safe-area
aware), circular logo avatar, name, and clickable social icons (lucide-react).
Graceful fallbacks (palette gradient banner, initial avatar) — no broken images.
Images are language-independent
All read live (no republish needed). i18n es/en at parity; glassmorphism,
mobile-first and safe areas preserved. Adds lucide-react.
Verified: build passes; 9 migrations apply; orders persist + prune on read;
publish survives missing API key; pairings + brand exposed via /menu.
- Move the global 'Show macros' toggle from the Palette tab to the Catalog tab,
next to 'Cargar menú', where catalog assembly lives
- Section.showMacros boolean (default true) + migration 0006; existing sections
default to showing (so turning the global on shows all by default)
- Per-section toggle in the editor, visible only when the global toggle is on
- Hierarchy: global wins. A dish shows macros only if Restaurant.showMacros AND
its Section.showMacros are both true. Applies to card flip, list tap-image, the
gallery, and the color-code legend (legend shows only if some visible section does)
- Turning the global off only HIDES — macro data is never deleted; the disclaimer
is reassuring ('Macros will stop showing to the public, but they are not deleted')
- Live read: global + per-section showMacros are overlaid onto the published
snapshot at read time (new applyLiveSectionMacros helper) so toggles take effect
instantly without republishing; old snapshots default section macros on
- sections PATCH accepts showMacros; settings PATCH still handles the global
- i18n: sectionMacros + soft disclaimer (es/en parity); hint reworded
Verified: build passes; 6 migrations apply; section toggle persists; /menu reflects
the global+section hierarchy live; macro data preserved in DB and API when toggled off.
Builds on the existing Order model + SSE dashboard (no parallel system).
Model: extend Order.items JSON to {productId,name,qty,note?,price?} and add
Order.note (general note) — migration 0005.
Public menu (only when orders are enabled):
- Add button on every dish in BOTH card and list views
- Dedicated floating cart FAB with an item-count badge
- Cart sheet: per-line qty +/- (0 removes), per-item note, per-line subtotal +
total, a general order note, and required table number; confirm posts to the
existing POST /order, shows a confirmation toast and clears the cart
- Cart lives in client state only (no localStorage)
Admin Orders tab:
- Shows per-item notes and the general note
- Edit mode: adjust quantities, edit per-item and general notes, and ADD dishes
via a searchable dropdown over the restaurant's menu; saves through an extended
PATCH /orders/[id] that updates items/note and broadcasts a new 'order-edit' SSE
event so the dashboard updates live. Table number and timer (createdAt) preserved
order POST and PATCH sanitize/clamp incoming items (public + admin input).
i18n: cart/notes/total/confirm/search labels in es/en at parity. Glassmorphism,
mobile-first and safe areas preserved.
Endpoints/models: no new routes — POST /api/[slug]/order and PATCH
/api/[slug]/orders/[id] extended; Order model extended (items shape + note column,
migration 0005); new SSE event type 'order-edit'.
Verified: build passes; 5 migrations apply; order create persists qty/notes/price;
admin edit adds dishes + notes keeping table/timer; unauth edit 401.
The consultant could surface an unrelated dish as if it directly answered the
request. Now each recommendation is classified and presented accordingly.
- Prompt: model classifies each recommendation as type 'direct' (answers what was
asked) or 'complement' (pairs with it). Direct first and primary; complements
are optional and never used to pad to a count. Reasons must be anchored to a real
dish attribute or the dish isn't recommended. If nothing matches directly, the
intro says so gracefully instead of inventing a false direct match.
- Route: parse/validate the type (defaults to 'direct' if missing), keep existing
existence validation, order direct-first then complements, cap at 3.
- UI: AiConsultant renders direct cards first, then a 'Para acompañar' / 'To pair
with' header before complements (glassmorphism preserved).
- i18n: ai.pairWith in es/en (parity); the type field itself is internal, not translated.
Keeps prompt caching and the compact menu context. Verified: build passes; parser
orders direct-first, drops non-existent dishes, defaults missing type to direct.
Feature 1 — showMacros toggle:
- Restaurant.showMacros boolean (default false) so existing menus (e.g. NOCNEX)
never publish with empty macros (migration 0004; default applies to existing rows)
- Editor toggle in the Palette tab, saved via the existing /settings endpoint
- Read live (not from the snapshot) in the public page and /menu API so it takes
effect immediately without republishing; old snapshots default off
- When off, the public menu hides every macro layer: card flip + 'tap to see
macros', the gallery macros, and the macro color-code legend
Feature 2 — public list view:
- Card/list toggle in the public menu; preference is NOT persisted (always starts
on cards)
- New ListRow: compact traditional rows (name + price + allergen tags); tap the
name to expand image + description (accordion); tap the image to reveal macros
(only when showMacros is on)
i18n: viewCards/viewList (menu) and showMacros/showMacrosHint (editor) in es/en at parity.
Glassmorphism, mobile-first and safe areas preserved. Existing features untouched
(versioning, import, consultant, QR, i18n).
Verified: build passes; 4 migrations apply in order; existing rows default false;
toggling via /settings updates /menu live without republish.
Bug 1 (malformed/truncated JSON crashed the route with SyntaxError):
- Raise extraction max_tokens 4000 -> 8000 and ask the model for compact, complete JSON
- Parse tolerantly: extractJson() for fences/prose, plus a repair pass that closes
open strings/brackets and drops a trailing partial entry for token-truncated output
- Wrap JSON.parse; on failure return a friendly code (parse_failed, or output_truncated
when stop_reason was max_tokens) instead of a raw 500
Bug 2 (40MB PDF -> Anthropic 413):
- Validate visual file size BEFORE calling the API (max 4.5MB raw; base64 inflates ~33%)
- Return 413 {error:file_too_large, maxMb} so the UI shows 'max X MB, compress or use text/link'
i18n: file_too_large (with {mb}), parse_failed, output_truncated (es/en); ImportModal
interpolates the size limit.
Verified: build passes; repair recovers mid-string/mid-property/fenced/prose JSON;
oversized upload returns 413 with the limit; text path fails gracefully (no crash).
Editor QR tab now generates a styled, scannable QR with live preview and clean
PNG/SVG export (no frame or text — the owner lays it out).
- Restaurant.qrConfig JSON persists the styling (migration 0003)
- qr-code-styling (MIT) runs client-side in QrTab: preview + WYSIWYG PNG (2048px)
and vector SVG export, avoiding native canvas deps in the alpine image
- Controls: dots color/gradient, background (incl. transparent), corners color,
dot & corner shapes, optional center logo (uploaded via /upload, capped at 20%)
- Scannability: error correction forced to 'H' whenever there's a logo or color;
WCAG contrast check warns on low contrast; persistent 'verify before printing' notice
- Templates inherit the menu palette but every value is independently editable
- QR always targets {APP_BASE_URL}/{slug}
- PATCH /api/[slug]/qr saves config; GET stays as a config-aware server fallback
- i18n (es/en) for the qr namespace; glassmorphism, mobile-first
Verified: build passes; migration 0003 applies; PATCH persists qrConfig; GET
honors saved colors/ECC (png + colored svg); auth guard returns 401.
ProductEditor and CatalogTab use t('save'/'edit'/'delete') from the editor
namespace, but those keys only existed in the common namespace, so the UI showed
raw keys (editor.save, editor.delete). Add them to messages/es.json and en.json.
Audited every useTranslations call across src/ against both catalogs: no other
unresolved keys, and es/en are at full key parity.
Import a menu from PDF, photo, Excel/CSV, web link, or pasted text and turn it
into draft sections + products with Claude.
- Product.aiEstimated JSON flags AI-inferred macros/allergens (migration 0002)
- POST /api/[slug]/import: resolves the source (vision via Sonnet for PDF/photo,
Haiku for text/CSV/XLSX/web), extracts structured JSON for review only
- POST /api/[slug]/import/apply: writes to the draft in add or replace mode,
preserving aiEstimated flags; replace wipes the draft first
- Editor: 'Cargar menú' button + glass ImportModal (method -> review -> add/replace),
'Estimado por IA — verifica' badges, verification disclaimer; ProductEditor shows
the badge and clears the flag when the value is edited
- Reuses anthropic.ts, upload/guard, shared extractJson (moved to lib/json.ts)
- i18n labels (es/en); adds xlsx dependency for spreadsheet parsing
Verified: build passes; migration applies; apply add/replace persist correctly
with aiEstimated; extract validation + auth guard behave as expected.
Multi-tenant digital menu platform (Collina Systems): public QR menu with
glassmorphism + 3D macro flip cards, mobile-first editor with draft/publish
versioning (5-version history + restore), AI consultant & translation (Claude
Haiku), realtime orders via SSE, configurable palette, QR generation, superadmin
panel, and Docker/Coolify infra.