Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ierinconc/billar-pro-backend/llms.txt

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

The included docker-compose.yml spins up a single PostgreSQL 16 container named billarpro-postgres, giving you a fully isolated local database without installing Postgres directly on your machine. The Spring Boot application itself runs outside Docker via Maven, connecting to the containerized database over localhost.

docker-compose.yml

docker-compose.yml
services:
  db:
    image: postgres:16
    container_name: billarpro-postgres
    restart: always
    environment:
      POSTGRES_DB: billardb
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: mcrmael11
    ports:
      - "5433:5432"
    volumes:
      - billarpro_postgres_data:/var/lib/postgresql/data

volumes:
  billarpro_postgres_data:
The POSTGRES_PASSWORD value mcrmael11 is hardcoded directly in docker-compose.yml. Before sharing this file or using it in any environment beyond your own local machine, replace the literal value with an environment variable reference (e.g. ${POSTGRES_PASSWORD}) and supply the actual secret through a .env file or your CI/CD secrets store.

Port mapping

The container exposes PostgreSQL internally on port 5432, but it is bound to host port 5433 to avoid conflicts with any locally installed Postgres instance. Your JDBC URL must therefore target port 5433:
jdbc:postgresql://localhost:5433/billardb

.env.example

Use this file as the template for your local .env. Copy it to .env and fill in your chosen password — Docker Compose automatically loads .env from the project root.
.env.example
POSTGRES_DB=billardb
POSTGRES_USER=postgres
POSTGRES_PASSWORD=tu_password_local

DB_URL=jdbc:postgresql://localhost:5433/billardb
DB_USER=postgres
DB_PASSWORD=tu_password_local

Starting the local stack

1

Create your local .env file

Copy the example file and set a password of your choice:
cp .env.example .env
Open .env and replace tu_password_local with the password you want to use for the local database.
2

Start the PostgreSQL container

Launch the database in detached mode:
docker-compose up -d
Docker Compose reads .env automatically. The container is ready as soon as docker-compose ps shows it as Up.
3

Configure application.yml

Copy the application configuration example and update the credentials to match what you set in .env:
cp src/main/resources/application-example.yml src/main/resources/application.yml
Edit src/main/resources/application.yml and replace TU_CONTRASEÑA_AQUI with your chosen password. The JDBC URL must use port 5433 (the Docker host port), not the default 5432:
src/main/resources/application.yml
spring:
  datasource:
    url: jdbc:postgresql://localhost:5433/billardb
    username: postgres
    password: YOUR_LOCAL_PASSWORD
    driver-class-name: org.postgresql.Driver
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect

server:
  port: 8080
4

Run the Spring Boot application

Start the backend with the Maven wrapper (Java 21 required):
./mvnw spring-boot:run
On first startup, DataSeeder automatically creates six billiard tables and an admin user. Look for the log lines:
Mesas creadas exitosamente
Usuario admin creado exitosamente
5

Verify the API is running

Send a login request to confirm the application is reachable:
curl -s -X POST http://localhost:8080/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"billar123"}'
A successful response returns a JWT token. Store it and pass it as a Bearer token in the Authorization header for all subsequent requests.

Useful Docker commands

CommandPurpose
docker-compose psShow running container status
docker-compose logs dbTail PostgreSQL logs
docker-compose downStop and remove the container (data is preserved in the volume)
docker-compose down -vStop and remove the container and delete the volume
# Check container status
docker-compose ps

# Follow database logs
docker-compose logs -f db

# Stop the container (keeps volume data intact)
docker-compose down
PostgreSQL data is stored in the named Docker volume billarpro_postgres_data. This volume persists across docker-compose down and docker-compose up cycles, so your tables and rows survive container restarts. Only docker-compose down -v (or manually running docker volume rm billarpro_postgres_data) will permanently delete the data.

Build docs developers (and LLMs) love