Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JuanSebax85/backend-prueba-fullstack/llms.txt

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

The backend is configured entirely through environment variables. No credentials or connection details are hardcoded — all sensitive values are injected at runtime, making it straightforward to target different databases or environments without modifying source code.

Environment variables

The following variables must be set before the application starts. If any are missing, the datasource will fail to initialize.
VariableExample valueDescription
DB_URIjdbc:postgresql://db:5432/pruebaFull JDBC connection string including host, port, and database name
DB_USERpostgresDatabase username
DB_PASSWORD1234Database password
DB_DRIVERorg.postgresql.DriverFully qualified JDBC driver class name

Passing variables via Docker Compose

The docker-compose.yml file passes these variables to the backend service using the environment block:
docker-compose.yml
backend:
  build: .
  container_name: backend_app
  ports:
    - "8080:8080"
  depends_on:
    - db
  environment:
    DB_URI: jdbc:postgresql://db:5432/prueba
    DB_USER: postgres
    DB_PASSWORD: 1234
    DB_DRIVER: org.postgresql.Driver
The values above target the db service defined in the same Compose file. Docker Compose resolves the hostname db automatically within the shared network.

Overriding for a different database host or name

To point the backend at an external PostgreSQL instance, update the environment block:
docker-compose.yml
environment:
  DB_URI: jdbc:postgresql://myhost.example.com:5432/mydb
  DB_USER: myuser
  DB_PASSWORD: mysecretpassword
  DB_DRIVER: org.postgresql.Driver
Replace myhost.example.com, mydb, myuser, and mysecretpassword with your actual values. No other files need to change.
You can also export these variables in your shell and run the JAR directly — Spring Boot reads standard environment variables via ${VARIABLE_NAME} placeholders in application.properties.

Connection pool settings (Hikari)

Spring Boot uses HikariCP as its default connection pool. Two settings are configured explicitly:
application.properties
spring.datasource.hikari.initialization-fail-timeout=0
spring.datasource.hikari.connection-timeout=30000
PropertyValueEffect
initialization-fail-timeout0The pool starts even if the database is not immediately reachable. Useful when the backend container starts before the database is fully ready.
connection-timeout30000Requests for a connection from the pool wait up to 30 seconds before throwing an exception.
Setting initialization-fail-timeout=0 is what allows the depends_on health check in Docker Compose to act as a soft guard — the backend will retry acquiring a connection rather than crashing immediately on startup.

Schema management

application.properties
spring.jpa.hibernate.ddl-auto=update
With ddl-auto=update, Hibernate automatically inspects the database schema on startup and applies any changes needed to match the entity definitions. This means:
  • Tables and columns are created if they do not exist.
  • New columns added to entities are added to existing tables.
  • Columns are not dropped automatically when removed from entities.
update mode is convenient for development but is not recommended for production environments where schema changes should be managed explicitly via migration tools such as Flyway or Liquibase.

CORS configuration

The backend allows cross-origin requests from a single origin:
CorsConfig.java
registry.addMapping("/**")
    .allowedOrigins("http://localhost:3000")
    .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
    .allowedHeaders("*");
This means:
  • Only requests from http://localhost:3000 are allowed by the browser’s CORS policy.
  • All HTTP methods used by the API (GET, POST, PUT, DELETE, OPTIONS) are permitted.
  • All request headers are accepted.
If your frontend runs on a different host or port, update allowedOrigins in CorsConfig.java to match.
The default credentials (postgres / 1234) and CORS origin (http://localhost:3000) are suitable for local development only. Before deploying to any shared or production environment:
  • Change DB_PASSWORD to a strong, randomly generated value.
  • Restrict allowedOrigins to your actual frontend domain.
  • Consider using a secrets manager or .env file excluded from version control instead of plaintext values in docker-compose.yml.

Next steps

Database guide

Understand the schema, tables, and how to connect directly to PostgreSQL.

Docker deployment

Learn how to build and run the full stack with Docker Compose.

Build docs developers (and LLMs) love