HTML to PDF Generation Microservice
Stateless Node.js microservice converting dynamic HTML, MathJax/LaTeX mathematical formulas, dynamic charts, and large documents into publication-grade PDFs.
Problem Statement
Generating high-fidelity PDF reports containing dynamic SVG charts, tabular data, and complex mathematical notation (KaTeX / MathJax) in high-volume environments frequently destabilizes standard application servers due to headless browser memory leaks, zombie processes, and CPU spikes. This project delivered a dedicated, isolated, and scalable document-generation microservice engineered for high throughput and bulletproof process stability.
System Architecture
The microservice is built on Node.js and Express.js, backed by headless Chromium controlled via Puppeteer. Asynchronous conversion jobs are managed through BullMQ queues running over Redis to isolate heavy document rendering from primary API response cycles. Finished PDF artifacts are automatically streamed to AWS S3 storage with expiring signed URLs returned to clients.
Client Application (HTTP Request)
│
▼
Express.js REST Microservice
├── Payload Validation & Security Sanitization
└── Job Enqueueing
│
▼
BullMQ Task Queue (Redis Backed)
│
▼
Worker Process Pool
│
├── Browser Instance Pool (Lifecycle Manager)
│ │
│ ▼
│ Puppeteer / Headless Chromium
│ ├── HTML/CSS Rendering
│ ├── KaTeX / LaTeX Formula Evaluation
│ ├── Chart & SVG Render Synchronization
│ └── PDF Buffer Generation
│
▼
AWS S3 Object Storage
│
▼
Expiring Pre-Signed Download URL ResponseTechnical Challenges & Reliability Engineering
Stack