The cart/consultant suggestion carousel no longer depends on Claude-generated pairings. It now computes suggestions locally and instantly from the menu structure + cart — always available, zero API calls, zero cost, no failure point. - New lib/recommendations.ts: getRecommendations(menu, cartItemIds, opts) — a pure function. Section-complement rules (main+no drink -> drinks; food+no dessert -> desserts; drink-only -> food/snacks) classified by flexible keywords (es/en, whole-word match so 'te'/tea doesn't match 'fuertes'), then featured fill (unrepresented sections first, then price desc). Excludes cart items + inactive; empty cart -> featured so the carousel is never empty. - Phase-2 seam: opts.coOccurrence?(cartIds) => Map<productId, score> lets a future market-basket signal blend in WITHOUT changing the carousel — it still only calls getRecommendations(menu, cart). Documented where it plugs in. - PublicMenu computes cartSuggestions via getRecommendations (was the pairings map); carousel shows whenever there's >=1 suggestion and orders are enabled, in both the cart sheet and the consultant. SuggestionCarousel reused unchanged. - Removed the Claude generation: publish no longer calls generatePairings and the 'Generar sugerencias' checkbox is gone; deleted lib/pairings.ts. Restaurant.pairings column kept (unused, no migration churn). i18n parity kept. Glassmorphism/mobile-first/safe-areas untouched. Cart, consultant, SSE, split all intact. Verified (build passes, no Anthropic import in the carousel/publish path): 1 fresh publish (nothing generated) -> carousel shows; 2 main+no drink -> drinks surface first; 3 cart items never suggested; 4 empty cart -> featured; 5 zero Anthropic calls in the carousel flow; 6 carousel in both cart and consultant.
Menú inteligente — Collina Systems
Plataforma multi-tenant de menús digitales para restaurantes. Cada restaurante tiene su menú público (vía QR), un editor protegido mobile-first y un tablero de órdenes en tiempo real, con consultor IA y soporte bilingüe (ES/EN).
Estética: glassmorphism claro/transparente con animaciones high-end (flip 3D de macros, entradas escalonadas, micro-interacciones).
Stack
- Next.js 14 (App Router) + TypeScript
- PostgreSQL + Prisma
- next-intl (ES/EN, switch por cookie sin cambiar URL)
- Claude Haiku (
claude-haiku-4-5) para traducción y consultor IA - SSE para órdenes en tiempo real
- Almacenamiento en volumen local (
/data/uploads) - Tailwind CSS
- JWT + link secreto para auth del editor
- Docker + docker-compose (listo para Coolify)
Rutas
| Ruta | Descripción | Auth |
|---|---|---|
/{slug} |
Menú público (QR) | — |
/{slug}/editor?k={secret} |
Editor | link secreto + login |
/{slug}/editor/login |
Login del editor | — |
/admin |
Panel maestro Collina | superadmin (env) |
Desarrollo local
cp .env.example .env # completa los valores
# DATABASE_URL apuntando a tu Postgres local, JWT_SECRET, ANTHROPIC_API_KEY,
# SUPERADMIN_USER / SUPERADMIN_PASSWORD, APP_BASE_URL=http://localhost:3000
npm install
npx prisma migrate deploy # o `npm run prisma:migrate` para desarrollo
npm run db:seed # crea el restaurante demo (opcional)
npm run dev
El seed imprime el link de editor con su secreto y las credenciales admin / demo1234.
Versionado (concepto clave)
- Las tablas
SectionyProductson el borrador vivo que el restaurante edita. - El menú público nunca lee el borrador: lee el
snapshotJSON de laMenuVersionapuntada porRestaurant.publishedVersionId. - "Guardar y publicar" pide un nombre de versión, crea un
MenuVersioncon el snapshot completo del borrador y actualizapublishedVersionId. - Se conservan máximo 5 versiones por restaurante; al publicar la 6ª se elimina la más vieja (nunca la publicada). Cada versión del historial se puede restaurar al borrador.
Código de color de macros (estándar fijo)
Universal en todos los restaurantes — definido en src/lib/macros.ts y tailwind.config.ts.
La paleta del restaurante (fondos, acentos, tabs) sí es configurable; la de macros no.
| Macro | Color |
|---|---|
| Proteína | #C2410C |
| Carbohidratos | #B45309 |
| Azúcares | #BE185D |
| Grasas | #CA8A04 |
| Fibra | #15803D |
| Calorías | #1D4ED8 |
Despliegue con Coolify / Docker
docker-compose.yml define app (Next.js standalone) y db (Postgres 16) con volúmenes
menu_data (uploads) y menu_db. El contenedor corre prisma migrate deploy al arrancar
(ver docker-entrypoint.sh).
Variables de entorno (.env):
DATABASE_URL=postgresql://menu:${DB_PASSWORD}@db:5432/menu
DB_PASSWORD=
JWT_SECRET=
ANTHROPIC_API_KEY=
SUPERADMIN_USER=
SUPERADMIN_PASSWORD=
APP_BASE_URL=https://smartmenu.collinasystems.com.mx
UPLOAD_DIR=/data/uploads
docker compose up -d --build
En Coolify: apuntar al repo, montar el volumen persistente en /data, fijar las variables
de entorno y el dominio smartmenu.collinasystems.com.mx.
Endpoints
Públicos: GET /api/{slug}/menu, POST /api/{slug}/order, POST /api/{slug}/call-waiter,
POST /api/{slug}/ai-consult, GET /api/{slug}/orders/stream (SSE).
Editor (JWT): POST /api/{slug}/auth/login, CRUD sections/products,
POST /api/{slug}/publish, GET /api/{slug}/versions,
POST /api/{slug}/versions/{id}/restore, POST /api/{slug}/translate,
POST /api/{slug}/upload, PATCH /api/{slug}/orders/{id}, PATCH /api/{slug}/palette,
PATCH /api/{slug}/settings, GET /api/{slug}/qr.
Superadmin: POST /api/admin/login, GET|POST /api/admin/restaurants,
PATCH /api/admin/restaurants/{id}.
Notas
- i18n de interfaz en
messages/{es,en}.json; agregar un idioma = añadir un JSON nuevo. - Contenido dinámico (nombres/descripciones) se guarda como
{ es, en }; el botón "Traducir con IA" llena el idioma faltante y marcatranslationStatus.encomoautohasta que el restaurante lo edita (reviewed). - Sentence case en toda la UI.