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 uses MariaDB as its primary data store. The Spring Data JPA layer manages the schema automatically via Hibernate’s ddl-auto=update strategy, so no manual migration scripts are required for the initial setup. You only need to create the database and a dedicated user before starting the backend for the first time.

Requirements

  • MariaDB 10.6+ (recommended) or MySQL 8+
  • A database user with ALL PRIVILEGES on the comunidad_vecinos schema
  • The database server must be reachable from the host where the backend runs (default: localhost:3306)

Creating the Database and User

Connect to your MariaDB server as the root user (or any user with CREATE and GRANT privileges) and run the following statements:
CREATE DATABASE comunidad_vecinos CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

CREATE USER 'comunidad_user'@'localhost' IDENTIFIED BY 'your_password';

GRANT ALL PRIVILEGES ON comunidad_vecinos.* TO 'comunidad_user'@'localhost';

FLUSH PRIVILEGES;
Use utf8mb4 rather than utf8 to ensure full Unicode support, including emoji and supplementary characters that may appear in community notices or comments.
After creating the user, set DB_USER=comunidad_user and DB_PASSWORD=your_password in your environment before starting the backend. Hibernate will create all tables automatically on the first run.

Schema Overview

The tables below are created and maintained automatically by Spring Data JPA. The descriptions reflect the real JPA entities in the application.

comunidades

Represents a residential homeowners community (the top-level tenant of the application).
ColumnTypeDescription
id_comunidadBIGINT PKAuto-generated surrogate key.
nombreVARCHARCommunity display name.
direccionVARCHARStreet address.
ciudadVARCHARCity.
cod_postalVARCHARPostal code.

usuarios

Stores all user accounts — residents, administrators, and the super-admin.
ColumnTypeDescription
id_usuarioBIGINT PKAuto-generated surrogate key.
dniVARCHARSpanish national identity number (unique per community).
nombreVARCHARFirst name.
apellidosVARCHARSurname(s).
emailVARCHARLogin email address (used as the JWT subject).
puertaVARCHARApartment or door identifier within the building.
telefonoVARCHARContact phone number.
passwordVARCHARBCrypt-hashed password.
rolVARCHARRole: SUPER_ADMIN, ADMIN, or VECINO.
id_comunidadBIGINT FK → comunidadesThe community this user belongs to.
coeficienteDECIMALOwnership coefficient (participation quota).
estadoBOOLEANWhether the account is active.
cambiar_passBOOLEANFlags that the user must change their password on next login.

cuotas

Represents a fee or levy issued to all residents of a community.
ColumnTypeDescription
id_cuotaBIGINT PKAuto-generated surrogate key.
nombreVARCHARFee name or description.
fecha_emisionDATEIssue date.
fecha_vencimientoDATEDue date.
importe_totalDECIMALTotal amount for the community.
tipoVARCHARFee type (e.g., ordinary, extraordinary).
id_comunidadBIGINT FK → comunidadesThe community this fee belongs to.

recibos

An individual payment receipt — one per resident per fee.
ColumnTypeDescription
id_reciboBIGINT PKAuto-generated surrogate key.
id_cuotaBIGINT FK → cuotasThe parent fee.
id_comunidadBIGINT FK → comunidadesDenormalized community reference.
id_usuarioBIGINT FK → usuariosThe resident this receipt belongs to.
importeDECIMALAmount owed by this resident (total × coefficient).
estadoVARCHARPayment status (e.g., PENDIENTE, PAGADO).

movimientos

A general ledger of financial movements for a community (income, expenses, and fee payments).
ColumnTypeDescription
id_movimientoBIGINT PKAuto-generated surrogate key.
nombreVARCHARDescription of the movement.
id_comunidadBIGINT FK → comunidadesThe community this movement belongs to.
id_usuarioBIGINT FK → usuariosAssociated resident, if applicable (nullable).
fechaDATEDate of the movement.
importeDECIMALMonetary amount.
tipoVARCHARMovement type (e.g., INGRESO, GASTO).
id_reciboBIGINT FK → recibosLinked receipt, if the movement is a fee payment (nullable).

publicaciones

Community announcements or news posts created by administrators.
ColumnTypeDescription
id_publicacionBIGINT PKAuto-generated surrogate key.
tituloVARCHARPost title.
contenidoTEXTBody text of the announcement.
fechaDATETIMEPublication timestamp.
id_comunidadBIGINT FK → comunidadesThe community this post belongs to.
id_usuarioBIGINT FK → usuariosAuthor.

documentos

PDF and other file attachments uploaded to the community document repository.
ColumnTypeDescription
id_documentoBIGINT PKAuto-generated surrogate key.
nombreVARCHARDocument display name.
rutaVARCHARAbsolute filesystem path (under app.upload.dir).
fechaDATETIMEUpload timestamp.
id_comunidadBIGINT FK → comunidadesThe community this document belongs to.

comentarios

Comments left by residents on community publications.
ColumnTypeDescription
id_comentarioBIGINT PKAuto-generated surrogate key.
contenidoTEXTComment body.
fechaDATETIMECreation timestamp.
id_publicacionBIGINT FK → publicacionesThe post being commented on.
id_usuarioBIGINT FK → usuariosAuthor.

Schema Management

The schema is created and kept up to date automatically by Spring Data JPA using spring.jpa.hibernate.ddl-auto=update. You do not need to run any CREATE TABLE scripts manually — starting the backend against an empty comunidad_vecinos database is sufficient.
Never set spring.jpa.hibernate.ddl-auto=create-drop in a production environment. This strategy drops the entire schema on every application shutdown and recreates it on startup, permanently destroying all data.

Seeding the First Admin User

There is no automated seed script. After the backend has started once (and Hibernate has created all the tables), you must insert the first SUPER_ADMIN user directly into the database. This account can then create communities and additional administrators through the application UI. Passwords are hashed with BCrypt. Generate a hash before running the insert:
# Requires Apache httpd-tools (htpasswd)
htpasswd -bnBC 10 "" yourpassword | tr -d ':\n'
Then run the following SQL, replacing the placeholder hash with your real BCrypt output:
-- 1. Create the platform-level pseudo-community for the super-admin
INSERT INTO comunidades (nombre, direccion, ciudad, cod_postal)
  VALUES ('Plataforma', 'Admin', 'Admin', '00000');

-- 2. Insert the SUPER_ADMIN user (id_comunidad = 1 from the row above)
INSERT INTO usuarios (dni, nombre, apellidos, email, password, rol, id_comunidad, coeficiente, estado, cambiar_pass)
  VALUES (
    '00000000A',
    'Admin',
    'Sistema',
    '[email protected]',
    '$2a$10$...your_bcrypt_hash_here...',
    'SUPER_ADMIN',
    1,
    1.0,
    true,
    false
  );
You can also generate a BCrypt hash online (search for “BCrypt generator”) or programmatically via Spring’s BCryptPasswordEncoder: new BCryptPasswordEncoder().encode("yourpassword"). The cost factor used by the application is the BCrypt default (10 rounds).

Build docs developers (and LLMs) love