Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doc-Engine-API

A high-performance, containerized Node.js REST API microservice optimized for programmatically compiling dynamic HTML templates into production-grade PDFs. It processes JSON arrays and maps complex data fields into customized, highly polished document layouts at scale.

Project Context

This microservice serves as an automated report layout manager. It is designed to decouple document generation workflows from main application engines, leveraging headless browser rendering inside an ultra-lean deployment environment.


Technical Highlights

  • Automated PDF Compilation: Utilizes Puppeteer to orchestrate a headless Chromium instance, instantly transforming dynamically rendered HTML/CSS data templates into pixel-perfect PDF documents.
  • Streamlined Containerization: Packaged entirely using Docker with an Alpine Linux base image, minimizing container size, ensuring isolation, and reducing runtime memory overhead.
  • Dynamic Mapping Engine: Parses and maps structured complex JSON arrays into specified template layouts on the fly, rendering tables, lists, invoice parameters, and structural markers.
  • RESTful Microservice Architecture: Exposes secure, lightweight HTTP endpoints built using Node.js and Express.js, making it easy to plug into any frontend or backend ecosystem.

Architecture & Tech Stack

  • Runtime Environment: Node.js
  • Backend Framework: Express.js
  • Automation Engine: Puppeteer (Headless Chromium)
  • DevOps & Infrastructure: Docker, Docker Compose, Alpine Linux
  • Testing Tooling: Postman, Jest

Repository File Tree

├── config/             # Puppeteer and browser launch options
├── controllers/        # Document layout handlers and JSON parsing logic
├── templates/          # HTML/CSS skeleton layouts for report variations
├── routes/             # RESTful API route definitions (e.g., /api/generate)
├── utils/              # Clean helper functions (file I/O, base64 data streams)
├── Dockerfile          # Multi-stage optimized Alpine Linux container build
├── docker-compose.yml  # Local multi-service orchestrator setup
└── server.js           # Microservice bootstrapper and application entry

Local Quickstart

Prerequisites

Approach 1: Running with Docker (Recommended)

  1. Clone the project repository:
    git clone https://github.com
    cd doc-engine-api
  2. Spin up the isolated container microservice:
    docker-compose up --build
    The microservice server instance will initialize at http://localhost:5000.

Approach 2: Native Node.js Run

  1. Install backend dependencies:
    npm install
  2. Execute the local server build:
    npm start

🔌 API Reference Outline

Compile PDF from Layout Template

  • Endpoint: POST /api/documents/generate
  • Headers: Content-Type: application/json
  • Payload Structure:
{
  "templateName": "invoice_standard",
  "dataFields": {
    "invoiceId": "INV-2026-089",
    "issuedDate": "2026-08-20",
    "items": [
      { "description": "Consulting Services", "hours": 12, "rate": 75 }
    ]
  }
}
  • Success Output: Returns a raw binary .pdf file stream or a base64 encoded document download string.

📄 License

Distributed open-source under the MIT License.

About

A high-performance, containerized Node.js REST API microservice utilizing Docker (Alpine Linux) and Puppeteer to programmatically compile dynamic HTML templates into clean PDFs and map JSON arrays directly into downstreamable Excel files. 1 . Nodejs, express, docker, puppeteer, zod, rest-api, backend-developer

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages