Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JuseAR27/Unisierra-eats/llms.txt

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

The UniSierra Eats product catalog is powered by a Productos SQLite table and a single REST endpoint that computes live averages and review counts on every request. Students can browse the full catalog, filter by category, or navigate directly to an individual product detail page to read reviews and pricing information.

Data Model

Products are stored in the Productos table with the following fields:
FieldTypeDescription
id_productoINTEGERPrimary key
nombreTEXTDisplay name of the product
precioREALNumeric price in Mexican pesos (MXN)
precioNivelTEXTPrice tier stored in the DB ($, $$, $$$); overridden by the frontend — see note below
descripcionTEXTShort description shown in cards and search results
imagenTEXTURL to the product image
categoriaTEXTCategory slug: comidas, bebidas, snacks, sanas
calificacionREALComputed average rating (not stored; derived via JOIN)
numResenasINTEGERComputed review count (not stored; derived via JOIN)
Although precioNivel is stored in the database and accepted by POST /api/productos, the frontend function obtenerProductosAPI() overwrites it at runtime using only two tiers: "$" for products under 40 MXN and "$$" for everything else. The $$$ value stored in the DB is therefore never displayed to students.

Frontend Price Tiers

The obtenerProductosAPI() function in app.js computes the displayed price tier from the numeric precio field:
precioNivel: p.precio < 40 ? "$" : "$$"
SymbolPrice Range
$Under 40 MXN
$$40 MXN and above

Categories

Comidas

Main dishes and hot meals served at the cafeteria — tortas, chilaquiles, and other cooked plates.

Bebidas

Hot and cold drinks including café americano, agua fresca, and other beverages.

Snacks

Quick bites and light snacks such as papas a la francesa and galletas con chispas.

Sanas

Healthy options including salads and fruit cocktails for health-conscious students.

API Endpoint

GET /api/productos

Returns the full list of products. Each product includes a live-computed average rating and total review count, calculated via a LEFT JOIN on the Resenas table so products with zero reviews still appear with calificacion: 0 and numResenas: 0. Response (200 OK):
[
  {
    "id_producto": 1,
    "nombre": "Torta de Asada",
    "precio": 65,
    "precioNivel": "$$",
    "descripcion": "Deliciosa torta de carne asada con frijoles...",
    "imagen": "https://...",
    "categoria": "comidas",
    "calificacion": 4.5,
    "numResenas": 12
  }
]

SQL Query

The server runs the following query on every GET /api/productos request to compute averages in real time:
SELECT p.*, 
       IFNULL(AVG(r.calificacion), 0) as calificacion,
       COUNT(r.id) as numResenas
FROM Productos p
LEFT JOIN Resenas r ON p.id_producto = r.producto_id
GROUP BY p.id_producto
IFNULL ensures that products without any reviews return 0 rather than NULL for calificacion.

Frontend Integration

The obtenerProductosAPI() function in app.js fetches all products from the API and normalizes the response for the frontend. It overwrites precioNivel using the two-tier formula above and applies a fallback image URL for products with no imagen value set:
async function obtenerProductosAPI() {
    try {
        const res = await fetch('/api/productos');
        const prods = await res.json();
        return prods.map(p => ({
            ...p,
            id_producto: p.id_producto,
            precio_actual: p.precio,
            imagen: p.imagen || 'https://images.unsplash.com/photo-1554118811-1e0d58224f24?auto=format&fit=crop&w=500&q=60',
            precioNivel: p.precio < 40 ? "$" : "$$",
            etiquetas: ["Disponible"]
        }));
    } catch (e) {
        console.error("Error cargando productos:", e);
        return [];
    }
}

Product Detail Page

Each product has a dedicated detail page accessible at:
detalle_producto.html?id=<id_producto>
The page loads the matching product from obtenerProductosAPI() by matching id_producto, then separately fetches that product’s active reviews from GET /api/resenas/producto/:producto_id. It displays:
  • Product name, description, and image
  • Star rating and total review count
  • A progress-bar breakdown of ratings from 5 stars down to 1
  • A chronological list of student review comments
  • A Escribir Reseña button (requires an active session)

Seeded Sample Products

The database is pre-populated with the following products. Note that precioNivel shown in the UI is always computed by the frontend from precio, not read from the database.
NamePrice (MXN)Frontend DisplayCategory
Torta de Asada$65$$comidas
Chilaquiles Rojos$55$$comidas
Café Americano$20$bebidas
Agua Fresca de Jamaica$15$bebidas
Papas a la Francesa$35$snacks
Galleta con Chispas$15$snacks
Ensalada de Pollo$75$$sanas
Coctel de Frutas$40$$sanas

Build docs developers (and LLMs) love