Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sergio-salcedo-dev/excel-product-manager/llms.txt

Use this file to discover all available pages before exploring further.

Preoc Product Manager integrates Google Gemini (via @google/genai) to provide two AI-powered search modes that surface real construction product data and let you import it into your catalog with one click. Both modes use the gemini-3-flash-preview model with Google Search grounding to retrieve up-to-date, real-world pricing — CYPE Precios for technically coded Spanish construction products, and Mercado AI for broader market research.

How It Works

The AI search workflow follows a straightforward four-step flow:
  1. Type a search term into the toolbar search bar (e.g., “hormigón HA-25”, “cable eléctrico 2.5mm”).
  2. Click either CYPE Precios or Mercado AI to start a search.
  3. Gemini returns a JSON array of matching products, which appears in a results modal with checkboxes.
  4. Select the products you want and click Añadir N productos seleccionados to bulk-import them into your catalog.
Both AI search modes require a valid Gemini API key. Configure it by setting NEXT_PUBLIC_GEMINI_API_KEY in your .env.local file before starting the application. See Environment Variables for setup instructions.
The CYPE Precios button (primary color, left of the search bar) searches Spain’s CYPE Generador de Precios — the standard cost-estimation database used across the Spanish construction industry. The request is made by searchInCype, which instantiates new GoogleGenAI({ apiKey: process.env.NEXT_PUBLIC_GEMINI_API_KEY }) on the client side and calls ai.models.generateContent with the gemini-3-flash-preview model. The googleSearch grounding tool is enabled via config.tools: [{ googleSearch: {} }] and the response is requested as responseMimeType: "application/json", so results are anchored to live web data rather than model training weights. Gemini is prompted to act as an expert in CYPE Generador de Precios (obra nueva) and return products with technically precise descriptions and CYPE-style article codes (e.g., MTB010, HAC010). Best for: Looking up products that need to match standard Spanish construction specifications, budgets prepared with CYPE, or technical project documentation that references official CYPE codes.

Expected JSON Schema

Gemini is instructed to return only a JSON array matching this shape:
[
  {
    "description": "Hormigón para armar HA-25/B/20/IIa fabricado en central",
    "code": "HAC010",
    "unit": "m3",
    "price": 74.5,
    "category": "Estructuras"
  }
]
If no matching products are found, the model returns an empty array [] and an info alert is displayed — see Error Handling below. The Mercado AI button (amber/accent color, rightmost in the search bar) performs a broader market search via searchInAI, returning 3–5 real construction products available on the general market for the search term. Like CYPE Precios, it uses gemini-3-flash-preview with googleSearch grounding (config.tools: [{ googleSearch: {} }]) and responseMimeType: "application/json". It returns the same JSON schema: description, code, unit, price, and category for each result. Product codes are realistic but not strictly CYPE-formatted. Best for: General market pricing research, comparing prices across product types, or importing products when strict CYPE coding is not required.

Selecting and Importing Results

When either search returns results, a modal overlay appears with the full list of matched products. The modal header indicates the source (“CYPE Precios Sync” or “Mercado AI Sync”) and the number of results found. Each result card displays:
  • Code — the product reference code in monospace uppercase
  • Description — the full technical description
  • Price — unit price formatted as {price} € / {unit}
  • Checkbox — to include or exclude the item from the import batch
By default, all results are pre-selected when the modal opens. You can:
  • Deselect individual items by clicking anywhere on a result card or its checkbox.
  • Toggle all at once using the Seleccionar todo master checkbox at the top of the list. The counter next to it shows the current selection as {selected} / {total}.
  • Import the selection by clicking the Añadir productos seleccionados button at the top of the list. The button only appears when at least one result is selected.
After importing via addAllPreocProducts, all selected products are prepended to the catalog (they appear at position 1 on page 1) with IDs in the format preoc-{timestamp}-{index}. The results modal closes automatically and the catalog resets to page 1. The search bar text is not cleared by the bulk import — if you want an unfiltered view of the newly added products, click the X button in the search bar or use Limpiar Filtros.
If you add a single product using the per-card add action (addPreocProduct), the search field is automatically cleared so you can immediately see the new product in the full, unfiltered catalog list. Bulk import via the Añadir N productos seleccionados button does not clear the search field.

Error Handling

The following error conditions are handled and surfaced as alert banners at the top of the screen: Missing API key — If NEXT_PUBLIC_GEMINI_API_KEY is not configured or is invalid, the AI request fails and an error alert is shown asking the user to check the Gemini API key configuration. No results found — If Gemini returns an empty array for a CYPE Precios search, an info alert appears:
“No se encontraron resultados específicos en el Generador de Precios para esta búsqueda.”
For Mercado AI, the info alert reads:
“El Mercado AI no encontró productos específicos para esta búsqueda.”
Network or API error (CYPE) — If the CYPE search request throws an exception, an error alert is displayed:
“Hubo un problema al conectar con el Generador de Precios (CYPE). Asegúrate de que la API Key de Gemini esté configurada correctamente.”
Network or API error (Mercado AI) — If the Mercado AI search request throws an exception, a shorter error alert is shown:
“No se pudo realizar la búsqueda en el Mercado AI en este momento.”
In all error cases, the loading spinner on the triggering button is dismissed and the catalog state remains unchanged.

Required Configuration

Both CYPE Precios and Mercado AI search modes require NEXT_PUBLIC_GEMINI_API_KEY to be set in your .env.local file at the root of the project:
NEXT_PUBLIC_GEMINI_API_KEY=your_api_key_here
The NEXT_PUBLIC_ prefix is required — without it, Next.js will not expose the variable to client-side code and every AI search call will fail. Note that the project’s .env.example lists GEMINI_API_KEY (without the prefix) as a server-side placeholder used by the AI Studio runtime; for local development you must add the NEXT_PUBLIC_ prefix yourself in .env.local. The key is passed directly to new GoogleGenAI({ apiKey: process.env.NEXT_PUBLIC_GEMINI_API_KEY }) on the client side — keep this in mind when deploying to production environments.

Build docs developers (and LLMs) love