Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JoseOlivares19/Proyecto-PC3-JavaScript-Avanzado/llms.txt

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

The SmartStock360 Spring Boot service exposes two REST endpoints under the /api/productos path. The first returns the full product catalog from MySQL. The second accepts a product feature payload, proxies it unchanged to the Python FastAPI AI service, and returns the raw JSON string response directly to the caller. Both endpoints are served by the embedded Tomcat container on port 8080. Base URL: http://localhost:8080

GET /api/productos

Fetches all product records from the producto MySQL table and returns them as a JSON array. No authentication, query parameters, or request body are required.

Request

GET /api/productos
This endpoint takes no parameters and no request body. It calls ProductoRepository.findAll() internally and serialises the result using Jackson’s default camelCase naming strategy.

Response Fields

id
number
Surrogate primary key, auto-assigned by MySQL.
nombre
string
Product display name.
precio
number
Unit price (decimal).
stockActual
number
Current units available in inventory.
ventas7d
number
Number of units sold in the last 7 days.
descuentoPct
number
Active discount percentage applied to this product (0–100).
temporada
number
Season code — 0 = normal, 1 = campaign, 2 = holiday/high demand.
diasSinReabastecer
number
Number of days elapsed since the last restock event.
ratingProducto
number
Average customer rating on a 0.0–5.0 scale.

Example Response

[
  {
    "id": 1,
    "nombre": "Zapatillas Deportivas",
    "precio": 129.90,
    "stockActual": 80,
    "ventas7d": 420,
    "descuentoPct": 20,
    "temporada": 2,
    "diasSinReabastecer": 18,
    "ratingProducto": 4.6
  },
  {
    "id": 2,
    "nombre": "Auriculares Bluetooth",
    "precio": 59.90,
    "stockActual": 150,
    "ventas7d": 210,
    "descuentoPct": 10,
    "temporada": 0,
    "diasSinReabastecer": 5,
    "ratingProducto": 4.2
  }
]
curl -X GET http://localhost:8080/api/productos \
  -H "Accept: application/json"

POST /api/productos/predict

Accepts a PredictDto JSON body containing the product’s feature vector, forwards the payload verbatim to the Python FastAPI service at http://127.0.0.1:8001/predict/smart-stock using Spring’s RestTemplate, and returns the raw AI response JSON to the caller.
The Python FastAPI AI service must be running at http://127.0.0.1:8001 before calling this endpoint. If the process is not started, RestTemplate will throw a connection-refused exception and the endpoint will return an HTTP 500 error.

Request

POST /api/productos/predict
Content-Type: application/json

Request Body Parameters

precio
number
required
Unit price of the product. Used as a price-sensitivity signal by the AI model.
stock_actual
integer
required
Current units in stock. Low values relative to ventas_7d indicate restock urgency.
ventas_7d
integer
required
Units sold in the last 7 days. Primary demand velocity signal.
descuento_pct
number
required
Active discount percentage (0.0–100.0). Influences demand uplift prediction.
temporada
integer
required
Season code passed directly to the model — 0 = normal, 1 = campaign, 2 = holiday/high demand.
dias_sin_reabastecer
integer
required
Days elapsed since the last restock. High values increase predicted stockout risk.
rating_producto
number
required
Average customer rating (0.0–5.0). Higher ratings correlate with higher predicted demand.

Example Request Body

{
  "precio": 129.90,
  "stock_actual": 80,
  "ventas_7d": 420,
  "descuento_pct": 20,
  "temporada": 2,
  "dias_sin_reabastecer": 18,
  "rating_producto": 4.6
}
curl -X POST http://localhost:8080/api/productos/predict \
  -H "Content-Type: application/json" \
  -d '{
    "precio": 129.90,
    "stock_actual": 80,
    "ventas_7d": 420,
    "descuento_pct": 20,
    "temporada": 2,
    "dias_sin_reabastecer": 18,
    "rating_producto": 4.6
  }'

Response

The Spring Boot controller method signature is public String predecirStock(...), and produces = "application/json" is set on the @PostMapping. This means the endpoint returns the raw JSON string that RestTemplate receives from the Python FastAPI service, forwarded byte-for-byte to the caller with a Content-Type: application/json response header.
The shape of the JSON body in the response is defined entirely by the Python FastAPI AI service, not by the Spring Boot layer. Refer to the SmartStock AI model reference for the Python-side response contract.

How the Proxy Works

Understanding the internal flow helps when debugging prediction failures:
Client

  │  POST /api/productos/predict  { PredictDto JSON }

ProductoController  (Spring Boot, port 8080)

  │  ProductoService.predecirStock(request)
  │  restTemplate.postForObject(
  │      "http://127.0.0.1:8001/predict/smart-stock",
  │      request, String.class
  │  )

Python FastAPI AI Service  (port 8001)

  │  Returns prediction JSON

ProductoController  →  raw JSON String response  →  Client
ProductoService constructs a RestTemplate instance directly and issues a synchronous POST. The raw response string from Python is returned as-is, with produces = "application/json" on the controller method ensuring the correct Content-Type header is set in the reply.

Build docs developers (and LLMs) love