Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/alvarezlautaro/BancoAlimentos/llms.txt

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

This guide takes you from zero to a working API session. The fastest path uses Docker and Docker Compose, which handle the MySQL database and the Spring Boot application together. If you prefer to run the application directly on your machine, a local Maven option is also covered in the Deployment page.

Prerequisites

Docker path

Local path

  • JDK 21+
  • Maven 3.9+ (or use the included mvnw wrapper)
  • MySQL 8 running locally

Steps

1

Clone the repository

Download the source code from GitHub.
git clone https://github.com/alvarezlautaro/BancoAlimentos.git
cd BancoAlimentos
2

Create an environment file

The docker-compose.yml reads all sensitive values from environment variables. Create a .env file in the project root to supply them:
.env
MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_DATABASE=Banco_Alimentos
DB_USER=bancouser
DB_PASSWORD=bancopassword
JWT_SECRET=5a8d7f8b2c3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f
JWT_EXPIRATION=86400000
Replace JWT_SECRET with a strong, randomly generated value before deploying to any shared or production environment. The value above is the application default and is publicly known.
3

Start the stack with Docker Compose

Build the application image and bring up both services (MySQL and the Spring Boot app). The app service waits for MySQL’s health check to pass before starting.
docker compose up --build
Watch for the Spring Boot startup banner in the logs. The API is ready when you see output similar to:
Started BancoAlimentosApplication in X.XXX seconds
The application listens on port 8080.
On the first start, DataInitializer runs and seeds the database with all roles, permissions, and the three default user accounts. Because ddl-auto is set to create-drop, the schema and seed data are recreated on every restart.
4

Log in and obtain a JWT token

Use the POST /api/auth/login endpoint with one of the three seeded credentials. The deposito user has the broadest permissions and is a good starting point.
UsernamePasswordRole
depositodeposito123USER_DEPOSITO
tesoreriatesoreria123USER_TESORERIA
institucionalinstitucional123USER_INSTITUCIONAL
Log in as deposito
curl -s -X POST http://localhost:8080/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username": "deposito", "password": "deposito123"}'
A successful response returns a JSON object containing your bearer token:
Login response
{
  "token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJkZXBvc2l0byIsImlhdCI6..."
}
Copy the value of token — you will send it as a Bearer header on every subsequent request.
5

Make your first authenticated request

Fetch the list of donors with the token you just received. Replace <YOUR_TOKEN> with the actual value from the login response.
List all donors
curl -s http://localhost:8080/api/donantes \
  -H "Authorization: Bearer <YOUR_TOKEN>"
On a fresh install DataInitializer does not seed any donor data, so you will receive an empty array. The important thing is the 200 OK status — confirming that authentication and authorisation are working:
GET /api/donantes response
[]
Open the interactive Swagger UI at http://localhost:8080/swagger-ui/index.html to browse and try all available endpoints without leaving your browser. Use the Authorize button to paste your token once and have it applied to every request automatically.

Next steps

Authentication overview

Understand how JWT tokens are generated, what claims they carry, and how the security filter validates each request.

Deployment options

Configure environment variables, switch to a persistent database schema, and run the application locally with Maven.

Build docs developers (and LLMs) love