Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/luiss811/Backend-Airguide/llms.txt

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

AirGuide uses PostgreSQL as its database and Prisma ORM to manage the schema, run migrations, and generate a type-safe client. All database tooling is available through npm scripts. You only need to run these commands once during initial setup; after that, you run migrations whenever the schema changes.

Initial database setup

1

Generate the Prisma client

After installing dependencies, generate the Prisma client so all services can import it:
npm run prisma:generate
This reads prisma/schema.prisma and outputs a typed client to node_modules/@prisma/client. Re-run this command whenever you change the schema.
2

Run migrations

Apply the schema to your database by running Prisma’s dev migration command:
npm run prisma:migrate
This creates the migration history in prisma/migrations/ and applies all pending migrations to the database specified in DATABASE_URL.
3

Seed the database

Populate the database with initial campus data — buildings, classrooms, cubicles, and sample routes:
npm run prisma:seed
To also seed the extended building route data, run:
npm run prisma:seed-newbuildings

Available database scripts

ScriptCommandDescription
Generate clientnpm run prisma:generateRegenerates the Prisma client from the schema
Run migrationsnpm run prisma:migrateApplies pending migrations in dev mode
Push schemanpm run prisma:pushPushes schema changes without creating a migration file
Seed datanpm run prisma:seedSeeds campus buildings, rooms, and routes
Seed new buildingsnpm run prisma:seed-newbuildingsSeeds extended building route data
Open Studionpm run prisma:studioLaunches the Prisma Studio GUI at http://localhost:5555
Use prisma:push for rapid prototyping when you want to apply schema changes without generating a migration history. Switch to prisma:migrate before deploying to production so you have a reproducible migration trail.
Prisma Studio gives you a browser-based table editor for every model in your schema. Run npm run prisma:studio and open http://localhost:5555 to browse, filter, and edit rows without writing SQL.

Database schema

The schema defines 11 models organized around users, campus locations, navigation, events, and security.
ModelTableDescription
UsuariousuariosUser accounts with roles (rector, admin, profesor, alumno) and approval status
EdificioedificiosCampus buildings with geolocation coordinates and type classification
SalonsalonesClassrooms within a building, tagged by floor and type (aula, laboratorio, auditorio)
CubiculocubiculosProfessor office cubicles located within a building
ProfesorprofesoresProfessor profiles linked one-to-one to a Usuario account
EventoeventosCampus events with scheduling metadata used by the AI conflict resolver
RutarutasNavigation routes between any two campus locations (buildings, rooms, cubicles, or events)
RutaDetalleruta_detalleOrdered waypoints for each route, each with lat/lon and a navigation instruction
LogAccesologs_accesoLogin access log entries recording IP and device per user session
CodigoOtpcodigos_otpTime-limited OTP codes issued during the two-factor authentication flow
CaminoGeograficocaminos_geograficosWalkable paths (footways, steps) imported from OpenStreetMap via Overpass Turbo

Model highlights

usuarios — Every user has a role and an estado field (pendiente, activo, rechazado). New accounts start as pendiente and require admin approval before they can log in. edificios — Stores latitud and longitud as Decimal(10,8) / Decimal(11,8) for precise geolocation. Buildings are typed as academico, administrativo, or recreativo. rutas / ruta_detalle — A route connects any origin type to any destination type using TipoOrigen and TipoDestino enums. Waypoints in ruta_detalle are ordered by an orden field and carry both coordinates and a text instruction. eventos — Includes prioridad_evento, total_invitados, and asistentes_confirmados fields used by the TensorFlow.js scheduling model to evaluate and resolve time conflicts. caminos_geograficos — Stores the GeoJSON LineString geometry for campus footpaths as a Json field, enabling the map endpoint to return a combined GeoJSON feature collection.

Build docs developers (and LLMs) love