Skip to main content
This guide will walk you through setting up TechStore from scratch to making your first API request. You’ll have a fully functional e-commerce backend running locally in minutes.
Prerequisites: Ensure you have Java 21, MySQL, and Maven installed on your system before starting.

Getting Started

1

Clone and Navigate to the Project

First, clone the repository and navigate to the project directory:
git clone <repository-url>
cd tienda-online
2

Set Up the MySQL Database

Create a new MySQL database for TechStore:
mysql -u root -p
Then execute the following SQL commands:
CREATE DATABASE tienda_digital;
USE tienda_digital;
The application uses Hibernate’s ddl-auto=update mode, so tables will be created automatically on first run. No manual schema creation needed!
3

Configure Application Properties

Open src/main/resources/application.properties and configure your database connection:
# Database Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/tienda_digital?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=your_mysql_password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# JPA / Hibernate
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
Replace your_mysql_password with your actual MySQL root password.

Optional: Configure Email Service

For user registration with email verification, add your SMTP credentials:
# Gmail SMTP Configuration
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=your-email@gmail.com
spring.mail.password=your-app-password

# SMTP Properties
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.ssl.trust=smtp.gmail.com

# Brand Customization
app.shop.name=TechStore
app.shop.support-email=support@techstore.com
For Gmail, you’ll need to generate an App Password instead of using your regular password.
4

Build and Run the Application

Use the Maven wrapper to build and start the application:
./mvnw clean install
./mvnw spring-boot:run
On Windows, use:
mvnw.cmd clean install
mvnw.cmd spring-boot:run
The application will start on http://localhost:8080. You should see output indicating successful startup:
Started TiendaOnlineApplication in X.XXX seconds
5

Make Your First API Request

Now that the server is running, let’s test it by registering a new user.

Register a New User

curl -X POST http://localhost:8080/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "John",
    "apellido": "Doe",
    "email": "john.doe@example.com",
    "password": "SecurePass123",
    "telefono": "555-0100",
    "direccion": "123 Main St, City"
  }'
Response:
{
  "message": "Usuario registrado. Revisa tu correo para activar la cuenta."
}
If email is configured, the user will receive a verification email. Otherwise, you’ll need to manually set enabled=true in the database to activate the account.

Verify Account (Manual Method)

For testing without email, activate the account directly in MySQL:
USE tienda_digital;
UPDATE usuarios SET enabled = true WHERE email = 'john.doe@example.com';

Login and Get Access Token

curl -X POST http://localhost:8080/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "john.doe@example.com",
    "password": "SecurePass123"
  }'
Response:
{
  "id": "1",
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "email": "john.doe@example.com",
  "nombre": "John",
  "rol": "ROLE_USER"
}
Save the access_token - you’ll need it to access protected endpoints!
6

Fetch Products

Let’s retrieve the product catalog (public endpoint, no auth required):
curl http://localhost:8080/api/productos/activos
Response:
[
  {
    "id": 1,
    "nombre": "Laptop Pro 15",
    "slug": "laptop-pro-15",
    "descripcion": "High-performance laptop",
    "precio": 1299.99,
    "stock": 50,
    "imagenUrl": "https://example.com/laptop.jpg",
    "activo": true,
    "destacado": true,
    "categoria": {
      "id": 1,
      "nombre": "Electronics"
    }
  }
]
curl http://localhost:8080/api/productos/destacados

Search Products by Name

curl "http://localhost:8080/api/productos/buscar?nombre=laptop"

What’s Next?

API Reference

Explore all available endpoints and their parameters

Authentication

Learn about JWT tokens and RSA encryption

Database Schema

Understand the data models and relationships

Configuration

Advanced configuration options and environment variables

Quick Reference

Base URL

http://localhost:8080

Key Endpoints

MethodEndpointDescriptionAuth Required
POST/api/auth/registerRegister new userNo
POST/api/auth/loginLogin and get JWTNo
GET/api/productosList all productsNo
GET/api/productos/activosList active productsNo
GET/api/productos/{id}Get product detailsNo
GET/api/categoriasList all categoriesNo
POST/api/pedidosCreate new orderYes

Using JWT Authentication

For protected endpoints, include the JWT token in the Authorization header:
curl http://localhost:8080/api/pedidos/usuario/1 \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Need help? Check the troubleshooting section in the installation guide.

Build docs developers (and LLMs) love