The UZDI backend is a standard NestJS application where each business domain is encapsulated in its own feature module. Every module follows the same internal structure, shares a common set of globally registered pipes, and maps TypeORM entities to named PostgreSQL schemas defined byDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Zapiony/PUCE_UZDI_2026/llms.txt
Use this file to discover all available pages before exploring further.
DDL_UZDI_FINAL.sql. This page describes the architecture, the global bootstrap configuration, and the patterns every module must follow.
Module Anatomy
Each domain module inUZDI_BACK/src contains the following files:
| File | Role |
|---|---|
*.module.ts | NestJS module definition — declares and exports controller, service, and TypeORM feature |
*.controller.ts | Route handlers — maps HTTP verbs and paths to service methods |
*.service.ts | Business logic — interacts with the TypeORM repository |
entities/*.entity.ts | TypeORM entity — maps a TypeScript class to a PostgreSQL table in the correct schema |
dto/create-*.dto.ts | DTO for POST requests — decorated with class-validator constraints |
dto/update-*.dto.ts | DTO for PATCH requests — extends PartialType(CreateDto) making all fields optional |
Registered Domain Modules
All feature modules are imported inAppModule:
AdolescentesModule contains controllers and services for adolescents, expedients, socio-educational measures, infractions, GDO, ethnicity, civil status, and nationality.
Global Bootstrap Configuration (main.ts)
The application bootstrap in src/main.ts applies the following global configuration before the server starts listening:
| Configuration | Value / Behavior |
|---|---|
| Global prefix | api/v1 — all routes are prefixed (e.g., POST /api/v1/auth/login) |
SanitizationPipe | Runs before ValidationPipe; trims whitespace, strips <script> tags via regex, and escapes </> from all string inputs in body, query, and params |
ValidationPipe — whitelist: true | Strips any properties not declared in the DTO |
ValidationPipe — forbidNonWhitelisted: true | Throws 400 Bad Request if unknown properties are present |
ValidationPipe — transform: true | Auto-converts plain objects to DTO class instances and coerces primitive types |
| CORS origin | http://localhost:5174 (Vite dev server) |
| Port | process.env.PORT or 3000 |
Adding a New Module
Generate the module, controller, and service
Use the NestJS CLI from the This scaffolds
UZDI_BACK directory. Replace my-resource with the snake-case domain name:src/my-resource/my-resource.module.ts, my-resource.controller.ts, and my-resource.service.ts with proper decorators and wiring.Create the TypeORM entity
Create
src/my-resource/entities/my-resource.entity.ts. Map the entity to the correct PostgreSQL schema using the @Entity options object:Create the Create DTO
Create
src/my-resource/dto/create-my-resource.dto.ts with class-validator decorators:Create the Update DTO
Create
src/my-resource/dto/update-my-resource.dto.ts extending PartialType:PartialType makes all fields from CreateMyResourceDto optional, which is the correct behavior for PATCH endpoints.Register the entity in the feature module
Import
TypeOrmModule.forFeature([MyResource]) in your module so the repository is available for injection:BooleanVF Value Transformer
All CHAR(1) boolean columns in the DDL are mapped in TypeORM entities using the BooleanVF transformer defined in src/common/transformers/boolean-vf.transformer.ts:
CHAR(1) boolean column:
- Reading from the database:
'V'→true,'F'→false - Writing to the database:
true→'V',false/null/undefined→'F'
boolean values and never need to know about the 'V'/'F' encoding.
TypeORM Entity Schema Mapping
Every entity must target its named PostgreSQL schema explicitly. The schema name matches the domain schema defined inDDL_UZDI_FINAL.sql:
schema option causes TypeORM to default to the public schema, where none of the UZDI tables reside.
PartialType for Update DTOs
PartialType from @nestjs/mapped-types is used in every Update DTO. It copies all fields and their validation decorators from the Create DTO but marks them all as optional, which is the correct shape for PATCH semantics (partial updates):
PartialType from @nestjs/mapped-types is not the same as TypeScript’s built-in Partial<T>. It also carries the class-validator metadata forward, so validation still runs on any field that is provided in the request body.