Use this file to discover all available pages before exploring further.
Judicial Backend partitions all business logic into four self-contained domain modules. Each module lives under src/modules/<name>/ and owns its routes, controllers, services, repositories, mappers, and types. No module imports directly from another; shared infrastructure is accessed through database/, shared/, and core/ only.
The apelacion module is the primary intake interface for the court’s second-instance proceedings. It handles the capture and registration of new appeals (apelaciones) submitted to the Oficialía, including their attachments (anexos), folio generation, and Sala/Toca assignment via stored procedures.
Because every dependency is injected at construction time, test suites can supply mock repositories to createApelacionService without any patching framework. Replacing folioRepo with a stub that returns a fixed folio string is sufficient to unit-test the full registration flow in isolation.
Apelación — layer breakdown
Layer
File
Responsibility
Interface
controllers/apelacion.controller.ts
Validates query params, calls service, returns response via responseUtil
Interface
controllers/anexo.controller.ts
Attachment endpoints
Interface
apelacion.routes.ts
Registers routes; applies validateDto middleware
Application
services/apelacion.service.ts
Orchestrates ORM repos + SPs inside a single transaction
The busqueda module provides a parameterized search interface over existing appeals, with results exportable as Excel (.xlsx) or PDF. It offers three independent search sub-modes, each with its own controller, service, repository, mapper, and report builders.
Every service in this module exposes the same four methods:
Method
Signature
Description
obtenerCatalogos()
(): Promise<CatalogosDTO>
Returns drop-down data for the filter form
buscar(filtros)
(filtros: FiltrosDTO): Promise<ResultadoDTO[]>
Paginated and filtered query
exportarExcel(filtros)
(filtros: FiltrosDTO): Promise<Buffer>
Builds an .xlsx workbook buffer from search results
exportarPdf(filtros)
(filtros: FiltrosDTO): Promise<Buffer>
Builds a PDF buffer from search results
Export endpoints stream the buffer directly to the HTTP response using responseUtil.file(), which sets Content-Disposition: attachment and the appropriate MIME type (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet for Excel, application/pdf for PDF).
The estadistica module generates statistical reports on court appeals. All data is retrieved through a single stored procedure (PA_SEL_PCF_EstadisticaApelaciones) and then shaped by mappers into one of two presentation modes before being returned as JSON or exported to Excel.
The auth module implements authentication using a Backend-for-Frontend (BFF) proxy pattern. The backend does not manage users or issue tokens itself; instead, it proxies credential exchanges to an external authentication API and validates the resulting JWTs locally using RS256 public keys fetched via JWKS.
The protect middleware (modules/auth/middlewares/protect.middleware.ts) guards every non-auth route. It runs the following sequence on every incoming request:
Client → GET /api/apelaciones (Authorization: Bearer <token>) │ ▼ protect middleware 1. Extract Bearer token from Authorization header 2. Decode JWT header → read key ID (kid) 3. Fetch JWKS from external provider: GET .../GetJwks 4. Verify RS256 signature, issuer, and audience 5. Attach decoded payload to req.user 6. Call next() │ ▼ ApelacionController / BusquedaController / EstadisticaController