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 POST /api/productos/predict endpoint accepts a product data payload and acts as a transparent proxy to the Python FastAPI AI service running at http://127.0.0.1:8001/predict/smart-stock. The Spring Boot service receives the PredictDto request body, forwards it verbatim via RestTemplate, and returns the raw JSON prediction string back to the caller. The response content — including demand classification, confidence score, ranked scenarios, and restock recommendations — is generated entirely by the underlying Python machine-learning model.

Endpoint

PropertyValue
MethodPOST
Path/api/productos/predict
Base URLhttp://localhost:8080
Full URLhttp://localhost:8080/api/productos/predict
Content-Typeapplication/json
CORSAll origins (*)
AuthNone
Proxies tohttp://127.0.0.1:8001/predict/smart-stock

Request Body

All fields map directly to the PredictDto class and are required. The Spring Boot layer performs no validation or transformation — the object is serialized and forwarded as-is to the Python AI service via RestTemplate.postForObject.
precio
number
required
Product unit price in local currency.Example: 149.90
stock_actual
integer
required
Current number of units in inventory at the time of the prediction request.Example: 42
ventas_7d
integer
required
Total units sold over the past 7 days. Used as the primary short-term velocity feature.Example: 17
descuento_pct
number
required
Current active discount expressed as a percentage. A value of 0 indicates no active promotion.Example: 10.0
temporada
integer
required
Encoded season / demand-period code. The AI model uses this to weight seasonal demand patterns.
ValueMeaning
0Normal / off-peak
1Campaña (promotional period)
2Feriado / alta demanda
Example: 1
dias_sin_reabastecer
integer
required
Number of calendar days elapsed since the last restock event.Example: 5
rating_producto
number
required
Average customer rating for the product on a scale of 1.0 to 5.0.Example: 4.7

Response

Returns HTTP 200 OK. The Spring Boot controller is declared with produces = "application/json" and returns a raw String — the verbatim JSON body forwarded from the Python AI service with no additional transformation.
caso
string
A short label for the predicted demand scenario, such as "ALTA DEMANDA", "DEMANDA NORMAL", or "BAJA DEMANDA".
prediccion
string
Human-readable summary sentence describing the overall prediction outcome (e.g., "Se recomienda reabastecer antes de 3 días").
confianza
number
Model confidence score for the top prediction, expressed as a decimal between 0.0 and 1.0. Values above 0.80 indicate high model certainty.
ranking
array
Ordered list of the top predicted demand scenarios with their individual probabilities.
recomendaciones
array
List of plain-language action items generated by the AI model based on the prediction (e.g., "Aumentar stock en al menos 50 unidades", "Mantener descuento actual para sostener la demanda").
entrada
object
Echo of the input payload that was sent to the AI model, useful for debugging and audit logging.

Examples

curl --request POST \
  --url http://localhost:8080/api/productos/predict \
  --header "Content-Type: application/json" \
  --data '{
    "precio": 149.90,
    "stock_actual": 42,
    "ventas_7d": 17,
    "descuento_pct": 10.0,
    "temporada": 1,
    "dias_sin_reabastecer": 5,
    "rating_producto": 4.7
  }'

Example Response

{
  "caso": "ALTA DEMANDA",
  "prediccion": "El producto presenta alta rotación. Se recomienda reabastecer antes de 3 días para evitar quiebre de stock.",
  "confianza": 0.91,
  "ranking": [
    {
      "caso": "ALTA DEMANDA",
      "probabilidad": 0.91
    },
    {
      "caso": "DEMANDA NORMAL",
      "probabilidad": 0.07
    },
    {
      "caso": "BAJA DEMANDA",
      "probabilidad": 0.02
    }
  ],
  "recomendaciones": [
    "Reabastecer al menos 80 unidades en los próximos 3 días.",
    "Mantener el descuento actual del 10% para sostener la demanda.",
    "Considerar aumentar el precio ligeramente dado el alto rating del producto."
  ],
  "entrada": {
    "precio": 149.90,
    "stock_actual": 42,
    "ventas_7d": 17,
    "descuento_pct": 10.0,
    "temporada": 1,
    "dias_sin_reabastecer": 5,
    "rating_producto": 4.7
  }
}
This endpoint requires the Python AI service to be running at http://127.0.0.1:8001 before any prediction request can succeed. If the FastAPI service is offline, Spring Boot’s RestTemplate will throw a RuntimeException (connection-refused or RestClientException) and the endpoint will return an HTTP 500 Internal Server Error. Always start the Python service (e.g. uvicorn main:app --port 8001) before making calls to /api/productos/predict.

Build docs developers (and LLMs) love