SmartStock360 uses a MySQL database namedDocumentation 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.
smartstock to persist the product catalog. Spring Boot connects through a standard JDBC datasource, and Hibernate manages the table schema automatically — so you never have to write DDL statements by hand. This page walks through creating the database, understanding the configuration properties, and seeding initial product data.
Prerequisites
MySQL 8+
A locally running MySQL instance accessible on
localhost:3306. Create a user with full privileges on the smartstock schema.Spring Boot Backend
The application reads
application.properties at startup. Make sure the file is in place before running ./mvnw spring-boot:run.Application Properties
The datasource and JPA settings live insrc/main/resources/application.properties. The full file used by SmartStock360 is:
| Property | Value | Purpose |
|---|---|---|
spring.datasource.url | jdbc:mysql://localhost:3306/smartstock | JDBC connection URL pointing to the smartstock schema |
spring.datasource.username | root | MySQL user (change for non-local environments) |
spring.datasource.password | your_password_here | MySQL password for the above user |
spring.jpa.hibernate.ddl-auto | update | Hibernate auto-creates or alters tables on startup to match entity definitions |
ddl-auto=update is safe for development: Hibernate adds missing columns and creates missing tables but never drops existing columns or data. For a clean schema reset, use create-drop during early prototyping, or manage migrations with Flyway/Liquibase in production.Creating the Database
Before starting the Spring Boot service for the first time, create thesmartstock schema in MySQL. Connect to your MySQL server and run:
producto table the first time the application boots, based on the Producto entity definition.
The Producto Entity and Table Schema
The Producto JPA entity is annotated with @Entity, which maps the Java class to a MySQL table named producto (Hibernate’s default lowercase naming). All fields map to columns of the same name using Hibernate’s default CamelCase → snake_case column naming strategy.
| Column | MySQL Type | Constraints | Description |
|---|---|---|---|
id | BIGINT | PRIMARY KEY, AUTO_INCREMENT | Surrogate primary key |
nombre | VARCHAR(255) | — | Product display name |
precio | DOUBLE | — | Unit price |
stock_actual | INT | — | Current units in stock |
ventas_7d | INT | — | Units sold in the last 7 days |
descuento_pct | INT | — | Active discount percentage (0–100) |
temporada | INT | — | Season code: 0 = normal, 1 = campaign, 2 = holiday/high demand |
dias_sin_reabastecer | INT | — | Days elapsed since last restock |
rating_producto | DOUBLE | — | Average customer rating (0.0–5.0) |
Seeding Product Data
After the schema is created you can populate the table with representative products using standard SQLINSERT statements. Connect to the smartstock database and run your seeds:
Because
id is an AUTO_INCREMENT primary key, you do not need to supply it in INSERT statements — MySQL assigns the next available integer automatically.Verifying the Connection
Once the application is running, you can confirm the datasource is healthy by hitting the product listing endpoint:producto table. If you receive a 500 error, check:
- MySQL is running and reachable on
localhost:3306. - The
smartstockschema exists. - The username and password in
application.propertiesare correct. - The Spring Boot logs for any
HikariCPorHibernateconnection errors.