S1 Backend is a Node.js/Express REST API that acts as an aggregation gateway between PDN front-end applications and a network of federated government data providers. Each provider independently hosts asset declaration records for public servants under their jurisdiction. Rather than requiring clients to query every provider individually, S1 Backend exposes a single, uniform interface that fans out requests across the registered provider network, acquires OAuth 2.0 tokens per provider, and returns a consolidated response — all in a single round-trip for the caller.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PDNMX/s1_backend/llms.txt
Use this file to discover all available pages before exploring further.
Context: PDN Sistema 1
Mexico’s Plataforma Digital Nacional (PDN) is a national anti-corruption transparency platform that surfaces public information across six systems. Sistema 1 focuses on asset declarations (declaraciones patrimoniales) submitted by public servants at federal, state (estatal), and municipal (municipal) levels. Because these records are held by dozens of independent institutions — each operating its own API — a gateway layer is essential to provide unified access without coupling clients to the ever-changing provider landscape.Architectural Role
S1 Backend sits between PDN-facing user interfaces (or any HTTP client) and the federated government data suppliers:- Provider registry — On startup the gateway reads
endpoints.json, which lists every registered provider along with its OAuth 2.0 credentials, API URLs, and coverage levels. - Request filtering — Incoming queries may be scoped by
nivel_gobierno(government level:federal,estatal,municipal) or by a specific institution (supplier_id). The gateway filters the provider list accordingly. - Token acquisition — For each selected provider the gateway calls
getToken()inroutes/rest_data.js, performing an OAuth 2.0 password-grant flow against the provider’stoken_url. - Fan-out queries — All provider calls are dispatched in parallel via
Promise.all(), each sending aPOSTrequest with the query options and aBearertoken in theAuthorizationheader. - Aggregation — Responses are merged into a single array and returned to the caller. Per-provider errors are isolated and returned alongside successful responses so a single failing provider does not suppress results from the rest.
HTTP Endpoints
S1 Backend exposes five routes:| Method | Path | Description |
|---|---|---|
GET | / | Health check — returns API title and version. |
GET | /v1/providers | Lists all registered providers with their IDs, names, levels, and status. |
POST | /v1/summary | Fan-out count query across providers. Returns pagination metadata per provider for name-based filtering. |
POST | /v1/search | Detailed paginated search against a single specified provider (supplier_id required). |
POST | /v1/logger | Accepts client-side log entries and writes them through log4js. |
Before starting the server you must create
endpoints.json from the provided endpoints.json.example template and populate it with real provider credentials. The application will fail to load if this file is missing.Quick Navigation
Quickstart
Run the gateway locally and make your first API call in five steps.
Configuration
Full reference for
.env and the endpoints.json provider registry schema.API Reference
Detailed documentation for every endpoint, request body, and response shape.
Docker Deployment
Containerise and deploy S1 Backend with Docker or Docker Compose.
How It Works
The diagram below traces the life of a/v1/summary request end-to-end:
supplier_id, supplier_name, levels, and a totalRows: "No disponible" marker — while all other providers continue to contribute their results normally.
Technology Stack
| Package | Role |
|---|---|
| Node.js | JavaScript runtime |
| Express 4 | HTTP server and router (express ~4.16.0) |
| axios | HTTP client for provider token and data requests (^1.6.0) |
| log4js | Structured application logging (^6.4.0) |
| dotenv | Loads PORT from .env into process.env (^8.2.0) |
| cors | CORS middleware applied globally to all routes (^2.8.5) |
| qs | URL-encodes OAuth token request bodies (^6.9.7) |
| morgan | HTTP request logging in development (~1.9.0) |
| nodemon | Auto-restart on file changes during development (^2.0.3) |