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.
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.