Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Edfermachado/proyectoSistemas/llms.txt

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

Tenants are the operational units of UniEvents. Each tenant represents a faculty, department, or student organization within a university and operates as an isolated environment with its own spaces, events, users, and event managers. Categories provide a cross-cutting taxonomy that groups tenants by discipline — making it easy for end-users to browse by area of interest.

What Is a Tenant?

A tenant corresponds to a single faculty or student organization. Its tenantId is embedded in the JWT session for every tenant_admin, event_manager, and access_control account associated with it, ensuring complete data isolation at the row level.
// src/db/schema.ts
export const tenants = pgTable('tenants', {
  id:           uuid('id').primaryKey().defaultRandom(),
  name:         varchar('name', { length: 255 }).notNull().unique(),
  slug:         varchar('slug',  { length: 300 }).unique(),
  description:  text('description'),
  universityId: uuid('university_id').references(() => universities.id),
  categoryId:   uuid('category_id').references(() => categories.id),
  createdAt:    timestamp('created_at').defaultNow(),
});
FieldDetails
nameDisplay name of the faculty. Must be unique across the platform.
slugAuto-generated URL identifier — never set manually.
descriptionOptional description shown on the faculty’s public page.
universityIdReferences the parent university (nullable — a tenant can exist without a university).
categoryIdReferences a category used to classify the tenant (e.g., “Ingeniería”, “Deportes”).

Creating a Tenant

1

Open the Tenants list

Navigate to /admin/tenants. If no tenants exist, an empty state is shown with an Add Faculty button.
2

Click Nueva Facultad

Click the Nueva Facultad button in the top-right corner. This navigates to /admin/tenants/new.
3

Fill in the form

  • Name (required, unique) — the official faculty or organization name.
  • Description (optional) — a short summary.
  • University (optional) — select the parent university from the dropdown.
  • Category (optional) — select the disciplinary category (must exist before creating the tenant).
4

Submit

Submit the form. The system calls POST /api/tenants, which generates a unique slug and inserts the record.

API — Create a Tenant

POST /api/tenants
Content-Type: application/json
{
  "name": "Facultad de Ingeniería",
  "description": "Ingeniería civil, mecánica, eléctrica y de sistemas.",
  "universityId": "a3f1c2d4-...",
  "categoryId":   "b7e2a1f0-..."
}
Response 201 Created:
{
  "id": "c9d8e7f6-...",
  "name": "Facultad de Ingeniería",
  "slug": "facultad-de-ingenieria",
  "description": "Ingeniería civil, mecánica, eléctrica y de sistemas.",
  "universityId": "a3f1c2d4-...",
  "categoryId":   "b7e2a1f0-...",
  "createdAt": "2024-08-16T09:00:00.000Z"
}

Editing and Deleting Tenants

Editing

Navigate to /admin/tenants/[id]/edit or click the edit icon on the tenants table. The PUT endpoint accepts partial updates for name, description, and categoryId. The slug is regenerated if the name changes.
PUT /api/tenants/{id}
Content-Type: application/json

{
  "description": "Ingeniería civil, mecánica, eléctrica, sistemas y computación."
}
Response 200 OK — returns the updated tenant object.

Deleting

Click the delete icon in the tenants table. The DELETE endpoint returns 204 No Content on success.
DELETE /api/tenants/{id}

Tenant Isolation

Every resource (spaces, events, attendees, scan logs) is scoped to a tenantId. When a tenant_admin logs in, the tenantId is written into the JWT cookie by createSession. All subsequent API calls in the faculty-admin portal read session.tenantId to filter data — no cross-tenant data is ever exposed.
// Session payload (lib/auth.ts)
{ userId, role, tenantId, email, expiresAt }
The tenantId field is null for superadmin accounts because they operate across all tenants globally.

Managing Categories

Categories classify tenants so end-users can filter faculties and events by discipline. Navigate to /admin/categories to view, create, and delete categories.
// src/db/schema.ts
export const categories = pgTable('categories', {
  id:        uuid('id').primaryKey().defaultRandom(),
  name:      varchar('name', { length: 255 }).notNull().unique(),
  slug:      varchar('slug',  { length: 300 }).unique(),
  icon:      varchar('icon',  { length: 100 }), // Google Material Symbols icon name
  createdAt: timestamp('created_at').defaultNow(),
});
FieldDetails
nameCategory label (e.g., “Ingeniería”, “Medicina”, “Deportes”). Must be unique.
slugAuto-generated from the name.
iconA Google Material Symbols icon name rendered as <span class="material-symbols-outlined">{icon}</span>.

Creating a Category

1

Navigate to /admin/categories

If no categories exist, click Crear Categoría from the empty state.
2

Click Nueva Categoría

Click the Nueva Categoría button to open the creation form at /admin/categories/new.
3

Fill in name and icon

Enter a name and a Material Symbols icon identifier.
4

Submit

The form calls POST /api/categories, which generates a slug and stores the record.
POST /api/categories
Content-Type: application/json

{
  "name": "Ingeniería",
  "icon": "engineering"
}
Response 200 OK:
{
  "id": "f4a3b2c1-...",
  "name": "Ingeniería",
  "slug": "ingenieria",
  "icon": "engineering",
  "createdAt": "2024-08-16T10:00:00.000Z"
}

Deleting a Category

DELETE /api/categories/{id}
Returns { "success": true } on success.
Category icons use Google Material Symbols names. Some useful examples:
CategoryIcon name
Engineering / Scienceengineering, science, biotech
Sportssports_soccer, fitness_center, sports_basketball
Arts & Musicmusic_note, palette, theater_comedy
Medicine / Healthhealth_and_safety, medical_services
Businessbusiness_center, attach_money
Browse the full list at fonts.google.com/icons.

All API Endpoints

Tenants

GET    /api/tenants           # List all tenants (ordered by createdAt desc)
POST   /api/tenants           # Create a new tenant
GET    /api/tenants/{id}      # Get a single tenant by UUID
PUT    /api/tenants/{id}      # Update name, description, or categoryId
DELETE /api/tenants/{id}      # Delete tenant (returns 204)

Categories

GET    /api/categories        # List all categories
POST   /api/categories        # Create a new category (name + icon)
DELETE /api/categories/{id}   # Delete a category by UUID

Build docs developers (and LLMs) love