Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/devdavco/backend_1/llms.txt

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

This guide walks you through standing up the CoworkingBooking API on your local machine and making your first three API calls — creating a user, registering a coworking space, and booking that space — from scratch.
Prerequisites before you begin:
  • Java 21 (the project targets java.version=21 in pom.xml)
  • Apache Maven 3.9+ (or use the included mvnw wrapper — no separate install needed)
  • PostgreSQL 14+ running and accessible (local instance or a hosted provider such as Supabase)
1

Clone the repository

Download the project source and move into the backend directory:
git clone https://github.com/devdavco/backend_1.git
cd backend_1
The Maven wrapper (mvnw / mvnw.cmd) is included, so no separate Maven installation is required.
2

Set environment variables

The API reads all database credentials from environment variables at startup. Create a file named .env (or export them in your shell) with the following values substituted for your environment:
DB_HOST=localhost
DB_PORT=5432
DB_NAME=coworking_db
DB_USER=coworking_usr
DB_PASSWORD=supersecretpassword
If you are using Supabase, find these values in your project’s Settings → Database page. The DB_PORT for Supabase is typically 5432 (direct connection) or 6543 (connection pooler).
Never commit real credentials to version control. Add .env to your .gitignore before pushing.
To export the variables in a Unix shell session directly:
export DB_HOST=localhost
export DB_PORT=5432
export DB_NAME=coworking_db
export DB_USER=coworking_usr
export DB_PASSWORD=supersecretpassword
3

Run the application

Start the Spring Boot application using the Maven wrapper.Linux / macOS:
./mvnw spring-boot:run
Windows:
mvnw.cmd spring-boot:run
Maven will download dependencies on the first run. Once startup is complete you should see output similar to:
Started CoworkingbookingApplication in 3.4 seconds (process running for 3.8)
The API is now listening at http://localhost:8080. Verify with the built-in ping endpoints — one per resource group — each returns the plain string "pong":
curl http://localhost:8080/espacios/ping   # → pong
curl http://localhost:8080/reserva/ping    # → pong
curl http://localhost:8080/usuarios/ping   # → pong
4

Create a user

Register the first user by posting to /usuarios/create:
curl -X POST http://localhost:8080/usuarios/create \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "María García",
    "email": "[email protected]",
    "password_hash": "secret",
    "rol": "usuario"
  }'
Sample response (201 Created):
{
  "id": 1,
  "nombre": "María García",
  "email": "[email protected]",
  "rol": "usuario"
}
Note the returned id — you will reference it when creating a booking in Step 6.
5

Register a coworking space

Add a meeting room to the system via /espacios/create:
curl -X POST http://localhost:8080/espacios/create \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Sala A",
    "tipo": "sala_reunion",
    "capacidad": 10,
    "minutos_limpieza": 15
  }'
Sample response (201 Created):
{
  "id": 1,
  "nombre": "Sala A",
  "tipo": "sala_reunion",
  "capacidad": 10,
  "minutos_limpieza": 15
}
minutos_limpieza is the buffer added after a session ends before the space becomes available again. The total end time of a booking (horaFinTotal) should equal horaFinUsuario plus this cleaning duration.
6

Book the space

Create a reservation linking the user (usuarioId: 1) to the space (espacioId: 1):
curl -X POST http://localhost:8080/reserva/create \
  -H "Content-Type: application/json" \
  -d '{
    "usuarioId": 1,
    "espacioId": 1,
    "horaInicio": "2024-09-01 09:00",
    "horaFinUsuario": "2024-09-01 10:00",
    "horaFinTotal": "2024-09-01 10:15",
    "estado": "confirmada"
  }'
Sample response (201 Created):
{
  "id": 1,
  "usuarioId": 1,
  "espacioId": 1,
  "horaInicio": "2024-09-01 09:00",
  "horaFinUsuario": "2024-09-01 10:00",
  "horaFinTotal": "2024-09-01 10:15",
  "estado": "confirmada",
  "version": 0
}
The version field is managed by Hibernate for optimistic locking. The 15-minute gap between horaFinUsuario and horaFinTotal reflects the minutos_limpieza value set on the space.
7

Update a reservation's status

Use the PUT /reserva/update/{id} endpoint to change the status of an existing reservation. Only the id and estado fields are required in the request body:
curl -X PUT http://localhost:8080/reserva/update/1 \
  -H "Content-Type: application/json" \
  -d '{
    "id": 1,
    "estado": "cancelada"
  }'
Sample response (200 OK):
{
  "id": 1,
  "estado": "cancelada"
}
Open http://localhost:8080/swagger-ui.html in your browser for a fully interactive version of every endpoint. You can fill in request bodies, execute calls, and inspect responses without leaving the page — no curl required.

Build docs developers (and LLMs) love