Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/GuillermoNavarro/Proyecto_comunidades/llms.txt

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

Comunidades Vecinos provides a community-scoped document repository where ADMINs can upload PDF files — meeting minutes, bylaws, insurance policies, contractor quotes — that all residents of the community can view and download. Files are stored directly on the server filesystem, and the database holds the metadata (name, description, upload date, and filename).

Supported Files

PDF only

The backend validates the Content-Type of every uploaded file. Only application/pdf is accepted. Any other MIME type returns 400 Bad Request with the message “Solo se permiten PDF”.

15 MB maximum

The Spring multipart configuration sets a hard limit of 15 MB per file (spring.servlet.multipart.max-file-size=15MB). Uploads exceeding this limit are rejected by the framework before reaching the controller.

The Documento Entity

FieldColumnTypeDescription
idid_documentoLong (auto)Primary key
comunidadid_comunidad (FK)ComunidadThe community this document belongs to
nombrenombreStringHuman-readable display name
descripciondescripcionStringOptional description or summary
fechafechaLocalDateTimeUpload timestamp (set by the database default; updatable)
documentodocumentoStringStored filename on disk (used to construct the download URL)

File Storage

Files are saved to the directory configured by the app.upload.dir property. The default value is:
/var/www/comunidades/documents/
The documento field in the database stores only the filename (e.g., acta_junio_2025.pdf). The frontend constructs the full URL by prepending the VITE_URL_DOCUMENTS environment variable, which should point to the same directory via an HTTP-accessible path.
When deploying behind a reverse proxy such as Nginx, configure a location block to serve the /var/www/comunidades/documents/ directory statically. Set VITE_URL_DOCUMENTS in the frontend’s .env file to the matching public URL (e.g., https://comunidades.example.com/documents/).

Uploading a Document

Documents are uploaded as multipart/form-data. The @ModelAttribute Documento receives the metadata fields (nombre, descripcion) and the @RequestParam("archivo") receives the binary file.
POST /api/documentos
Authorization: Bearer <admin_token>
Content-Type: multipart/form-data
nombre=Acta Junta General Junio 2025
descripcion=Acta de la junta ordinaria celebrada el 10 de junio de 2025
archivo=<binary PDF>
Example curl:
curl -X POST https://api.example.com/api/documentos \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -F "nombre=Acta Junta General Junio 2025" \
  -F "descripcion=Acta de la junta ordinaria celebrada el 10 de junio de 2025" \
  -F "archivo=@/home/admin/acta_junio_2025.pdf"
Successful response:
{
  "id": 23,
  "nombre": "Acta Junta General Junio 2025",
  "descripcion": "Acta de la junta ordinaria celebrada el 10 de junio de 2025",
  "fecha": "2025-06-11T10:30:00",
  "documento": "acta_junio_2025.pdf",
  "comunidad": {
    "id": 1,
    "nombre": "Comunidad Los Pinos"
  }
}

SUPER_ADMIN Cross-Community Upload

A SUPER_ADMIN user can upload a document to any community by providing the optional idComunidadManual query parameter. When this parameter is present and the caller is SUPER_ADMIN, the backend uses it instead of the community ID extracted from the JWT.
POST /api/documentos?idComunidadManual=3
Authorization: Bearer <super_admin_token>
Content-Type: multipart/form-data

Listing Documents

GET /api/documentos
Authorization: Bearer <any_authenticated_token>
Available to USER, ADMIN, and SUPER_ADMIN. The backend scopes the result to the caller’s community (from the JWT). SUPER_ADMIN can override with ?idComunidadManual={id} to list documents for a specific community.
[
  {
    "id": 23,
    "nombre": "Acta Junta General Junio 2025",
    "descripcion": "Acta de la junta ordinaria celebrada el 10 de junio de 2025",
    "fecha": "2025-06-11T10:30:00",
    "documento": "acta_junio_2025.pdf"
  },
  {
    "id": 18,
    "nombre": "Estatutos de la Comunidad",
    "descripcion": "Estatutos aprobados en asamblea constitutiva",
    "fecha": "2024-01-15T09:00:00",
    "documento": "estatutos_comunidad.pdf"
  }
]

Updating Document Metadata

Only the metadata (nombre and descripcion) can be updated after upload. The file itself cannot be replaced; upload a new document and delete the old one instead.
PATCH /api/documentos/{id}
Authorization: Bearer <admin_token>
Content-Type: application/json
{
  "nombre": "Acta Junta General Junio 2025 (versión firmada)",
  "descripcion": "Versión definitiva con todas las firmas de los asistentes."
}
The request body is deserialized as a ModifDocumento DTO. Returns the updated Documento object or 404 if the ID is not found.

Deleting a Document

DELETE /api/documentos/{id}
Authorization: Bearer <admin_token>
Returns 200 OK with "eliminado" on success, or 404 if the document ID does not exist.
Deleting a document via DELETE /api/documentos/{id} permanently removes both the database metadata record and the physical PDF file from disk (/var/www/comunidades/documents/). This action is irreversible. Make sure you have a backup before deleting important community documents.

Access Control Summary

ActionUSERADMINSUPER_ADMIN
List documents
Download / view document
Upload document
Upload to any community
Update document metadata
Delete document

Build docs developers (and LLMs) love