FormaTeX

The Stripe of LaTeX compilation — a SaaS REST API that turns .tex files into PDFs in seconds

// At a glance

Problem

Setting up a LaTeX toolchain — TeX Live, engine selection, timeouts, security sandboxing — is heavy for teams that just want "give me a PDF from this .tex file." FormaTeX exposes that as a usage-based REST API.

Solution

Built a Go/Gin REST API with JWT auth and hashed API keys, backed by an async job queue (Redis/Asynq) that dispatches compilations to a horizontally-scaled Dockerized worker pool running pdflatex/xelatex/lualatex/latexmk. PostgreSQL handles users, plans, API keys, and usage metering; Polar.sh is integrated as merchant of record for checkout and plan billing; a Next.js/TypeScript dashboard covers API key management, usage tracking, billing, and docs.

// Key highlights

  • Full plan-enforcement system gating engine access
  • monthly compilation quotas per tier
  • API keys are SHA-256 hashed and shown only once — never stored or logged in raw form
  • Dockerized worker pool running
  • horizontally scaled behind Nginx
  • Polar integrated as merchant of record
  • customer portal
  • four tiers

// Demo // In action

https://formatex.io

Live site

https://formatex.io

Open site ↗

Overview

FormaTeX is a production SaaS platform that exposes a dead-simple REST API for compiling LaTeX documents into PDFs. Think of it as "the Stripe of LaTeX compilation" — developers send a .tex file, get a PDF back, and never touch TeX Live again.

The platform is live at formatex.io.

Architecture

A Docker Compose stack on an Oracle VM orchestrates five services:

  • latex-api — Go/Gin HTTP server
  • latex-worker — Go/Asynq background worker
  • latex-postgres — PostgreSQL 16
  • latex-redis — Redis 7 backing the Asynq job queue
  • latex-frontend — Next.js 16 dashboard

Tech Stack

Backend

  • Go 1.25 + Gin framework
  • PostgreSQL 16 with pgx and connection pooling
  • Redis 7 + Asynq for async job queuing
  • Auth: JWT
  • Deployment: Docker Compose on Oracle VM

Frontend

  • Next.js 16 App Router
  • React 19 + TypeScript 5 strict
  • Tailwind CSS v4 + shadcn/ui
  • Framer Motion 12 animations
  • TanStack React Query 5 for server state
  • React Hook Form 7 + Zod 4 for form validation

Key Features

  • Multi-engine compilation: pdflatex, xelatex, lualatex, latexmk — plan-gated
  • Async jobs: heavy compilations are queued via Redis/Asynq; results polled or streamed
  • API key management: create named keys, revoke anytime, raw key shown once (stored as hash)
  • Plan enforcement: per-plan compilation limits, engine access, timeout and file-size caps — hard block on Free, soft block on paid
  • Usage metering: every compilation logged (engine, status, duration, input size)
  • Billing portal: Polar.sh checkout + customer portal wired to plan upgrades/downgrades via webhooks
  • Admin panel: user management, plan assignment, usage inspection

Security

  • Compilation files are ephemeral — deleted immediately after the response is sent
  • User LaTeX content is never logged
  • JWT expiry + auto-logout on 401 on the frontend

Have a project in mind?

Let's build something great together.

Tell me what you need and I'll get back to you with a clear, honest estimate.

HassanOSSYS-00
SECURE CHANNEL · ACTIVE
INIT://