work/Backend · Integration

Pantheon Middleware

A production-grade integration service connecting a webshop to the Pantheon ERP - with automated Croatian fiscalization and invoice delivery, all the way from order to emailed invoice.

Role

Backend architecture + Integration build

Stack

NestJS · BullMQ · PostgreSQL

Year

2026

architecture · forward-only
SourceWebshop
canonical JSON
Process 01HTTP Receiver
202 · enqueue
BrokerRedis Queue
job
Process 02Worker
stored procs
ERPPantheon
└▶
FINAFiscalization · ZKI / JIR
headless Chromium
DocumentInvoice PDF
SMTP email
RecipientCustomer
0HTTP Accepted - instant ack, async work
0Independent processes, one codebase
0Manual steps - order → fiscalized invoice
The challenge

What it needed to do.

The client's webshop and their Pantheon ERP didn't talk to each other. Orders were re-keyed by hand, invoices were issued manually, and Croatian fiscalization - a legal requirement - sat outside the flow entirely.

They needed a production-grade service that takes an order from the webshop and carries it all the way to a fiscalized, emailed invoice - reliably, and without anyone touching it.

Our approach

How we built it.

We built a forward-only integration service: the webshop sends orders in one direction and the middleware does the rest. A clean contract on the front, safe writes and fiscalization on the back - simple to reason about, hard to knock over.

  • Own API contract - a clean canonical order format, published as an OpenAPI/Swagger spec, so the webshop integrates against a stable, documented interface.
  • Safe ERP writes - every write goes through Pantheon stored procedures (never direct inserts), wrapped in transactions, with ERP-owned document numbering.
  • Croatian fiscalization - in-house ZKI/JIR generation, signed XML and QR codes, integrating with FINA, with a controlled demo → production certificate cutover.
  • Automated invoicing - headless-Chromium-rendered PDF invoices, delivered to the customer by email over SMTP.
  • Resilient & idempotent - a durable job queue with retries and backoff, crash-safe state tracking, dead-letter handling, and ERP-connection auto-reconnect.
  • Observable - structured JSON logging with correlation IDs across the whole request lifecycle, health/readiness probes for every dependency, and a queue dashboard.
Architecture

Two processes, one codebase.

The service runs as two independent processes from a single codebase, so each can scale and fail on its own without taking the other down.

Process 01

HTTP Receiver

Validates and authenticates incoming orders, enqueues them, and returns immediately with 202 Accepted - the webshop never waits on the ERP.

Process 02

Worker

Syncs orders into Pantheon, watches for fiscalization, then renders the PDF invoice and sends the email - with retries and backoff at every step.

Local state - idempotency keys, ID correlation and the audit log - lives in PostgreSQL; the message broker is Redis.
The stack

Chosen for reliability.

Runtime / languageNode.js 20+ · TypeScript 5 (strict)
FrameworkNestJS 10
Job queueBullMQ + Redis
State storePostgreSQL + Prisma
ERP accessMS SQL Server - direct TDS
Invoice PDFHeadless Chromium (Puppeteer)
EmailSMTP (nodemailer)
FiscalizationSigned XML · node-forge · QR codes
Observabilitypino logging · Swagger / OpenAPI
DeliveryDocker + Docker Compose
Engineering quality

Built to be handed over.

  • TypeScript strict mode with extra safety flags, and typed error classes with cause chains.
  • Unit, integration (against a live Pantheon test instance) and end-to-end test suites.
  • Two deployment paths - a self-contained handoff tarball for external operators, or repo-based deploy with redeploy / backup / rollback tooling.
  • Bilingual (EN / HR) deployment and handoff documentation for the client.
Status

Where it stands.

The core flow is built and integration-tested end to end against a live Pantheon instance: order ingest → customer ensure → ERP order & invoice → fiscalization → PDF → email.

Containerized deployment and observability are complete; the production fiscalization-certificate cutover is documented as a runbook, ready for go-live.

integration-tested · live Pantheon instance
  • order ingest
  • customer ensure
  • ERP order & invoice
  • fiscalization (ZKI / JIR)
  • invoice PDF rendered
  • email delivery
  • containerized + observable
  • runbook production cert cutover
Next project

WooCommerce × Pantheon

OPEN FOR NEW PROJECTS

Have a project like this one?

Tell us what you're building. We'll come back within one business day with a clear plan, a timeline, and a real human to talk to.