What is Kontrak Backend?
Kontrak Backend is a powerful Node.js-based REST API that automates the generation of employment contracts and related documents. Built with Express and TypeScript, it streamlines the contract creation process by transforming employee data into professionally formatted PDF documents.Key Features
Multi-Contract Support
Generate three types of employment contracts: Planilla (standard), Part Time, and Subsidio (substitution)
Batch Processing
Process up to 50 employees at once and download all contracts in a single ZIP file
Automated PDF Generation
Uses Puppeteer and pdf-lib to generate high-quality, legally compliant contract PDFs
Data Validation
Built-in Zod schemas validate employee data to ensure accuracy and completeness
Who Should Use Kontrak Backend?
This system is ideal for:- HR Departments: Automate repetitive contract generation tasks
- Staffing Agencies: Handle large volumes of employee onboarding
- Legal Teams: Ensure consistent, compliant employment documentation
- System Integrators: Build employee management systems with contract generation capabilities
Core Capabilities
Contract Types
Kontrak Backend supports three distinct contract types, each with specific requirements:- PLANILLA
- PART TIME
- SUBSIDIO
Standard full-time employment contracts with complete benefits and long-term engagement.Required Fields:
- Employee personal information (name, DNI, address)
- Position and salary details
- Contract dates (entry and end date)
- Subdivision or parking assignment
Document Generation
For each employee, the system automatically generates:- Employment Contract: Main contract document based on contract type
- Data Processing Agreement: Personal data treatment consent (GDPR compliance)
- Annexes: Additional documentation and forms
Architecture Overview
Technology Stack
- Express 5.1: Modern web framework for API endpoints
- TypeScript 5.9: Type-safe development with latest features
- Zod 4.1: Runtime type validation and schema definition
- Puppeteer 24: Headless Chrome for PDF generation
- pdf-lib: PDF manipulation and generation
- Archiver: ZIP file creation for batch downloads
Project Structure
API Endpoints
Kontrak Backend exposes a RESTful API with the following main endpoints:| Endpoint | Method | Description |
|---|---|---|
/ | GET | Health check and API information |
/api/health | GET | Server health status |
/api/contracts/download-zip | POST | Generate and download contracts as ZIP |
/api/contracts/preview | POST | Preview a single contract PDF |
All contract generation endpoints require validated employee data according to the Zod schemas defined in
src/validators/employee.validator.ts.Data Flow
- Request Reception: Client sends employee data to the API
- Validation: Data is validated against Zod schemas
- Processing: Contract service processes each employee
- PDF Generation: Puppeteer generates PDFs from HTML templates
- Bundling: Documents are organized and archived
- Response: ZIP file is streamed back to the client
Next Steps
Quick Start
Get up and running in 5 minutes
Installation
Detailed installation instructions
API Reference
Complete API documentation
Configuration
Configure your environment