SmartStock360 is organized as a classic three-tier web application where each tier has a single, well-scoped responsibility: the React frontend handles all user interaction and visualization, the Spring Boot middleware owns the REST contract, business data persistence, and cross-tier orchestration, and the Python FastAPI service owns all machine-learning inference. No tier reaches past its immediate neighbor — React never calls Python directly, and Python never touches the MySQL database. This separation makes each tier independently deployable, testable, and replaceable.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.
Architecture Diagram
The diagram below shows the full call path from a user action in the browser to an AI prediction and back. Port assignments, protocol boundaries, and the five model endpoints are all reflected here.Tier 1: React Frontend
The frontend is a Vite-bundled React 19 single-page application written in TypeScript. It runs on port5173 (Vite’s default dev server) and has no direct connection to either the MySQL database or the Python AI service — all communication is mediated by Spring Boot.
The entire API surface consumed by the frontend is defined in src/services/api.ts:
obtenerProductos()— issuesGET /api/productosto retrieve the product catalog from MySQL via Spring Boot.predecirDemanda(datosProducto)— issuesPOST /api/productos/predictwith a product payload; Spring Boot proxies this to the Python AI service and returns the prediction.
The
API_URL in api.ts points to the production deployment at https://swifttask.tech/universidad/api/productos. For local development, change this value to http://localhost:8080/api/productos to route requests to your local Spring Boot instance.package.json):
| Package | Version | Role |
|---|---|---|
react | ^19.2.7 | UI framework |
react-dom | ^19.2.7 | DOM renderer |
axios | ^1.18.1 | HTTP client |
vite | ^8.1.1 | Dev server & bundler |
typescript | ~6.0.2 | Type safety |
Tier 2: Spring Boot Middleware
Spring Boot acts as the sole gateway between the browser and all back-end resources. It runs on port8080, exposes the REST API that the React frontend consumes, persists and retrieves product data through JPA, and proxies AI prediction requests to the Python service.
Maven coordinates (pom.xml):
| Dependency | Role |
|---|---|
spring-boot-starter-data-jpa | ORM and repository abstraction over MySQL |
spring-boot-starter-webmvc | REST controllers and HTTP layer |
mysql-connector-j | JDBC driver for MySQL |
lombok | Boilerplate reduction for entity and DTO classes |
application.properties):
ddl-auto=update, Hibernate automatically creates or alters tables on startup to match the current JPA entity definitions — no manual SQL schema migration is required for local development.
REST endpoints exposed by Spring Boot:
| Method | Path | Description |
|---|---|---|
GET | /api/productos | Returns the full product catalog from MySQL |
POST | /api/productos/predict | Accepts a product payload, proxies to Python /predict/smart-stock, returns the AI prediction |
ProductoController is annotated with @CrossOrigin(origins = "*"), allowing requests from any origin — including the React dev server on port 5173 and the production frontend deployment.
The proxy target for prediction requests is http://127.0.0.1:8001/predict/smart-stock — the Smart Stock 360 demand classification model running on the Python AI service. Spring Boot uses RestTemplate to forward the request and relay the response.
Spring Boot proxies only to
/predict/smart-stock. The other four Python model endpoints (/predict/fraud-shield, /predict/cyber-sentinel, /predict/utp-risk, /predict/talent-match) are available directly on the Python service at port 8001 and are not exposed through the Spring Boot gateway. Spring Boot does not include Swagger — interactive API documentation is provided only by the Python FastAPI service at http://localhost:8001/docs.Tier 3: Python FastAPI AI Service
The Python service is the intelligence layer of the platform. It runs on port8001, exposes five prediction endpoints and two support endpoints, and requires no external model registry or file-based model loading. All five classifiers are trained from scratch every time the service starts.
Python dependencies (requirements.txt):
In-Memory Model Training
All five models share the same training pipeline. Thetrain_pack function generates synthetic training data, fits a RandomForestClassifier, and registers the resulting ModelPack in the MODELS dictionary during the FastAPI startup event:
Prediction Endpoints
All prediction routes accept aPOST request with a JSON body validated by a Pydantic model, run the corresponding classifier, and return a structured response:
| Endpoint | Model Key | Training Samples | Output Classes |
|---|---|---|---|
POST /predict/smart-stock | smart-stock | 300 | DEMANDA_ALTA_REABASTECER, DEMANDA_MEDIA_MONITOREAR, DEMANDA_BAJA_OPTIMIZAR |
POST /predict/fraud-shield | fraud-shield | 320 | FRAUDE_PROBABLE, REVISION_MANUAL, TRANSACCION_SEGURA |
POST /predict/cyber-sentinel | cyber-sentinel | 300 | CRITICO, ALTO, MEDIO, BAJO |
POST /predict/utp-risk | utp-risk | 260 | RIESGO_ALTO, RIESGO_MEDIO, RIESGO_BAJO |
POST /predict/talent-match | talent-match | 320 | FRONTEND_REACT, BACKEND_SPRING, DATA_ANALYST_JUNIOR, FULLSTACK_JUNIOR |
Support Endpoints
http://localhost:8001/docs — no additional tooling required.
Request Lifecycle: Demand Prediction
The following steps trace the complete path of a single demand prediction request from user gesture to rendered result.User triggers prediction in React
The user views a product in the React dashboard and clicks “Ejecutar Predicción IA”. The
predecirDemanda(datosProducto) function in src/services/api.ts fires an Axios POST to /api/productos/predict on the Spring Boot server at port 8080.Spring Boot receives the request
The
ProductoController (annotated @CrossOrigin(origins = "*")) accepts the incoming JSON payload and passes it to ProductoService.predecirStock(), which forwards it directly to the Python AI service.Spring Boot proxies to Python FastAPI
ProductoService uses RestTemplate to issue an HTTP POST to http://127.0.0.1:8001/predict/smart-stock, passing the product data as a JSON body. The Python service receives the request and deserializes it into a StockRequest Pydantic model.Random Forest inference
The Python service builds a feature vector from the seven
StockRequest fields — precio, stock_actual, ventas_7d, descuento_pct, temporada, dias_sin_reabastecer, rating_producto — and runs RandomForestClassifier.predict() and predict_proba() to obtain the class label, confidence score, and full probability ranking.Structured response is assembled
The Python endpoint constructs the response envelope:
caso, prediccion, confianza, ranking, recomendaciones (three actionable strings), and the original entrada for auditability. This JSON is returned to Spring Boot.Spring Boot relays the response to React
Spring Boot returns the Python response body as the HTTP response to the original Axios call. The React component receives the structured JSON and renders the prediction label, confidence percentage, probability ranking, and recommendations list in the dashboard.
Explore Further
Backend (Spring Boot)
JPA entities, REST controllers, proxy configuration, and MySQL schema details.
Frontend (React)
Component structure, Axios service layer, and dashboard UX patterns.
AI Models
Input features, label definitions, recommendation logic, and response schemas for all five models.
Quickstart
Get all three tiers running locally with step-by-step setup instructions.