DocSpawn

2025

High-performance document generation platform that transforms templates into production-ready PDFs at scale. Design templates via a visual canvas editor, then generate documents by filling forms, feeding datasets, or authoring rich HTML — all rendered into pixel-perfect PDFs in milliseconds with a Rust-powered rendering engine.

PlatformWeb
StackNuxt 3, Vue 3, NestJS, Rust, Axum, Fabric.js, Tiptap, Prisma, BullMQ, PostgreSQL, DynamoDB, S3, Redis, Docker, Puppeteer
4.9
23verified reviews
21five-star ratings
FiverrUpwork

Case Study

Overview

DocSpawn is a high-performance document generation platform that transforms templates into production-ready PDFs at scale. Users design templates via a visual Fabric.js canvas editor, then generate documents through three distinct modes: form-based single generation, dataset-driven batch generation, or rich HTML authoring. A dedicated Rust microservice (Axum + Tokio + lopdf) handles the CPU-intensive rendering pipeline, achieving sub-second per-document performance while NestJS orchestrates auth, permissions, and business logic.

What Makes It Special?

For Users

  • Visual template editor with drag-and-drop text, images, checkboxes, signatures onto PDF backgrounds with per-field styling
  • Three generation modes: FormToDoc (single), TableToDoc (batch from datasets), and Expert Editor (rich HTML to PDF)
  • Batch generation of hundreds of documents in a single request with per-document failure isolation
  • Shared access links with secure, expiring tokens that let external users generate documents without an account
  • Dynamic file naming via Handlebars templates with variable substitution from data rows
  • Full i18n support across 13 languages including RTL (Arabic) and CJK (Japanese, Korean, Chinese)

For Developers

  • Rust rendering microservice (Axum + Tokio + lopdf) delivering 10-100x throughput over the original Node.js pdf-lib approach
  • Hybrid database architecture: PostgreSQL for relational queries, DynamoDB for large nested JSON template definitions
  • Two-phase quota protocol with atomic reservation before rendering, commit after completion, and partial failure rollback
  • CASL-based authorization with workspace scoping and shared access degradation
  • Event-driven side effects via BullMQ: thumbnails, indexing, audit logs, and emails run async off the hot path
  • Versioned templates in DynamoDB where every save creates a new version and publishing promotes a specific one

Architecture Highlights

Rust PDF Rendering Engine

A dedicated Axum microservice handles CPU-bound rendering: loading background PDFs, scaling coordinate systems, drawing text with embedded TTF font subsets, placing images, creating hyperlink annotations, and uploading to S3. Sub-second per-document performance using Tokio's async runtime with semaphore-controlled parallelism.

Hybrid Database Architecture

Templates have structured metadata (names, permissions, quotas) in PostgreSQL and large nested JSON blobs (canvas definitions, field arrays, versioned snapshots) in DynamoDB. A Rust aggregation layer joins both sources transparently for the API consumer.

Coordinate System Scaling

The frontend canvas works in pixel coordinates while PDFs use point-based units. An in-place scaling system modifies the PDF's MediaBox directly, renders at canvas coordinates, then restores original dimensions, eliminating costly serialize/deserialize cycles.

Event-Driven Processing Pipeline

Document generation triggers async events via BullMQ for thumbnail creation, full-text indexing, audit logging, and email delivery, keeping the hot rendering path fast while ensuring all side effects complete reliably.

Batch Concurrency with Failure Isolation

TableToDoc uses Tokio semaphore-controlled parallelism so one bad row never blocks the batch. Per-document timing metrics are collected for observability, and partial failures release unused quota reservations automatically.

Integrated Tools

Visual Editor

Fabric.js canvas with drag-and-drop fields, multi-page templates, watermarks, and per-field styling

Rust Renderer

Sub-second PDF generation with embedded TTF fonts, images, hyperlinks via lopdf + Axum

Batch Engine

Dataset-driven concurrent generation with semaphore control and per-document failure isolation

HTML Editor

Tiptap-based rich text editor with variable placeholders rendered to PDF via headless Chrome

Data Sources

CSV upload or manual tabular datasets with versioned schemas and column-to-field mapping

Shared Links

Secure, expiring SHA-256 hashed tokens for external document generation without accounts

Key Learnings & Challenges Solved

  • 1
    Drew the Rust microservice boundary at the performance bottleneck while keeping NestJS for orchestration, which simplified both systems
  • 2
    Split PostgreSQL and DynamoDB by access pattern (relational vs document) with a transparent aggregation layer in Rust
  • 3
    Built an atomic reserve-then-commit quota protocol to solve race conditions in concurrent batch generation
  • 4
    In-place MediaBox scaling eliminated an entire intermediate PDF generation step for coordinate conversion
  • 5
    Parsed TTF glyph metrics in Rust for accurate text positioning and consistent cross-device font rendering
  • 6
    Preserved custom Fabric.js properties across save/restore cycles without data loss through careful serialization
DocSpawn screenshot 1
DocSpawn screenshot 2
DocSpawn screenshot 3
DocSpawn screenshot 4
DocSpawn screenshot 5
DocSpawn screenshot 6
DocSpawn screenshot 7
DocSpawn screenshot 8
DocSpawn screenshot 9
DocSpawn screenshot 10
DocSpawn screenshot 11
DocSpawn screenshot 12
DocSpawn screenshot 13
DocSpawn screenshot 14
DocSpawn screenshot 15
DocSpawn screenshot 16
DocSpawn screenshot 17
DocSpawn screenshot 18
DocSpawn screenshot 19
DocSpawn screenshot 20
DocSpawn screenshot 21
DocSpawn screenshot 22
DocSpawn screenshot 23
DocSpawn screenshot 24
DocSpawn screenshot 25