Unifies the model: a table is ALWAYS one account; every active Order on a table number is a subaccount (named or not) — no more 'normal vs split table'. Total convergence (fixes the bug): the dashboard groups ALL active orders by tableNumber into one card; two normal orders on the same table now share one table card with two subaccounts. (POST /order already converges split too.) Batches: items sent together share a batchId + batchAt; later additions form a new batch. reconcileItems() carries id/batch/delivered for matched lines and opens one new batch for new lines. (OrderItem is embedded JSON, so its new fields — id, batchId, batchAt, delivered, deliveredAt — need no migration.) Per-item timer + delivery: each item runs from its batch start; 'Entregado' freezes that item's timer (deliveredAt) while siblings keep running. Color thresholds are per-restaurant (timerGreenMax/timerYellowMax, migration 0011) and editable in the Orders tab; each item colors green/yellow/red by its own minutes. Independent states: delivered (per item, kitchen) vs paid (per subaccount, billing). Admin can rename a subaccount inline (PATCH subaccountName). All live via SSE; retention unchanged. i18n es/en at parity. Glassmorphism/mobile-first/safe areas preserved. Cart, maridajes and consultant untouched. New: Restaurant.timerGreenMax/timerYellowMax (migration 0011); OrderItem JSON gains id/batchId/batchAt/delivered/deliveredAt (no migration); PATCH orders/[id] gains deliverItemId+delivered and subaccountName; settings + GET /orders carry thresholds. Verified (build passes, all i18n present, migration 0011 applies): 1 two normal orders table 7 -> one card, two subaccounts; 2 lote A (30m ago) red + lote B (now) green, two batches; 3 deliver A1 -> frozen w/ deliveredAt, A2 keeps running; 4 thresholds 5/15 persist and return via GET /orders; 5 paid toggles independent of delivered (and vice versa); 6 rename '(table)' -> 'Juan' persists + SSE order-edit carries it.
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.