Judicial Backend is the server-side application powering the Oficialía de Partes Penal de Segunda Instancia — the court clerk’s office that receives, registers, and tracks criminal appeals at the second-instance level. It exposes a structured REST API consumed by the court’s front-end client (Angular), handling everything from authenticating court clerks to registering new appeals, running advanced searches, and producing Excel and PDF statistical reports for the judiciary.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/BladimirGS/judicial-backend/llms.txt
Use this file to discover all available pages before exploring further.
What the system does
When a criminal appeal is filed at a second-instance court, court clerks must record it with full metadata: the originating court (juzgado), the parties involved, the legal typology (tipo de apelación), the room assignment (sala), and any attached annexes. Judicial Backend automates this intake workflow and exposes search, history, and statistics endpoints so supervisors can query case loads, export data to Excel, and generate standardized PDF reports — all without direct database access.Domain modules
The API is organized into four focused modules, each with its own routes, controllers, services, DTOs, mappers, and repository layer:| Module | Base path | Responsibility |
|---|---|---|
auth | /api/auth | Session management — login, token refresh, and logout via BFF pattern |
apelacion | /api/apelaciones | Appeal intake — create appeals, manage annexes, retrieve catalogues |
busqueda | /api/busquedas | Advanced search — filter appeals, historical records, and flat-file views; export to Excel and PDF |
estadistica | /api/estadisticas | Statistical reporting — flat and grouped aggregations, multi-sheet Excel exports with charts |
auth
Handles clerk authentication by delegating credential validation to an external identity provider, receiving a signed JWT in return, and setting a secure HttpOnly refresh-token cookie. The three endpoints are POST /login, POST /refresh, and POST /logout.
apelacion
The core data-entry module. Exposes endpoints to fetch dependent catalogues (matters, courts, municipalities, localities, type lists), register a new appeal with its parties and metadata, and attach scanned-document annexes to an existing record.
busqueda
A read-only module designed for filtering and exporting. It supports three views — current appeals, flat (plano) projections, and historical records — each with its own catalogue/filter endpoint plus Excel and PDF export endpoints streamed directly to the response.
estadistica
Aggregates appeal data by configurable time periods and groups. Provides a flat report, a grouped report, and a multi-sheet Excel export that embeds chart data suitable for managerial dashboards.
Technology stack
Judicial Backend is built on a modern, strongly-typed Node.js stack:- Runtime: Node.js 18+
- Framework: Express 5 — async-native routing with improved error propagation
- Language: TypeScript (strict mode, compiled with
tsc) - ORM: TypeORM 0.3 — entities, repositories, and stored-procedure calls against SQL Server
- Database: Microsoft SQL Server (MSSQL) via the
mssql/tediousdrivers - Document generation: ExcelJS (multi-sheet workbooks with styles and charts) + pdfmake (template-driven PDF output)
- Logging: Pino with
pino-prettyfor structured, high-throughput JSON logs - Validation: class-validator + class-transformer for DTO-level request validation
- API documentation: Swagger UI served at
/api-docs, with spec available as JSON at/api-docs.json - Security: express-rate-limit (global + auth-specific limiters), CORS with configurable origins,
HttpOnly/Securecookies, RS256 JWT verification via JWKS
BFF authentication pattern
Judicial Backend does not own user credentials. Instead it acts as a Backend for Frontend (BFF) that proxies login requests to a separate identity service:- The front-end sends
POST /api/auth/loginwith{ usuario, contrasenia }. - Judicial Backend forwards those credentials — along with the configured
ID_SISTEMA— toEXTERNAL_AUTH_URL. - The external service returns a short-lived access token (JWT) and a refresh token.
- Judicial Backend sets the refresh token in a
Secure; HttpOnlycookie and returns the access token in the response body. - On every subsequent request to a protected route, the
protectmiddleware validates the access token’s signature using the external service’s public JWKS endpoint (/api/AuthJWT/GetJwks), verifying theissandaudclaims againstJWT_ISSUERandJWT_AUDIENCE.
Explore further
Quickstart
Clone, configure, and run the server locally in under 10 minutes.
Architecture Overview
Understand the layered module structure, data-source configuration, and shared utilities.
Authentication Module
Deep-dive into the BFF auth flow, JWT validation, token refresh, and the protect middleware.
Login Endpoint Reference
Full request/response schema for
POST /api/auth/login.