$ show Stirling-Tools/Stirling-PDF
Stirling PDF is a comprehensive, open-source PDF processing platform that provides 50+ document manipulation tools (merge, split, compress, OCR, sign, redact, convert, etc.) via a web UI, REST API, and desktop client (Tauri). The backend is a modular Java Spring Boot application split into core, common, proprietary, and SaaS modules, while the frontend is a React/TypeScript app with Mantine UI and Storybook. The system also includes a Python FastAPI engine for AI-powered features such as document classification, math auditing, and question answering, and an enterprise policy engine for automated document workflows with triggers, pipelines, and output sinks (local, S3, vector DB). It supports self-hosted, SaaS (Supabase/Stripe), and desktop deployment modes with clustering via Valkey/Redis backplane, SSO/OAuth2/SAML2 authentication, and comprehensive billing/licensing (PAYG, subscriptions, enterprise). The architecture is multi-module with clear separation of concerns: `app/common` provides shared utilities (PDF parsing, security, cluster abstractions, temp file management), `app/core` implements core PDF operations, `app/proprietary` adds enterprise features (encrypted storage, policy engine, audit, hardware signing), and `app/saas` handles SaaS-specific billing and team management. The frontend uses a shadowing pattern to swap implementations per build variant (core, proprietary, desktop, SaaS) without conditional imports. The AI engine runs as a separate Python service with streaming progress events and two-round protocols for complex tasks. Key data flows include: PDF upload → tool execution (Java PDFBox/iText) → output download; policy-triggered processing (folder watch, schedule) → pipeline execution → output delivery; AI agent workflows (classification, auditing) with progress streaming. External dependencies include LibreOffice (document conversion), Tesseract (OCR), PDFBox, iText, and various cloud services (Supabase, Stripe, PostHog). The codebase demonstrates high craftsmanship with extensive unit/integration/E2E tests, reusable component patterns (createToolFlow, useBaseTool), and well-abstracted interfaces for storage, signing, licensing, and clustering.
The LLM identified 5 files worth highlighting for reuse:
A utility that detects zip bombs by analyzing compression ratios and entry counts before extraction. It prevents denial-of-service attacks from malicious archives. The implementation is self-contained, uses only standard Java libraries, and can be extracted into any project that handles zip files. It demonstrates non-obvious security engineering by balancing detection thresholds against legitimate archives.
A connection pool for LibreOffice's UNO API that manages a fixed number of office instances, handles connection failures, and provides automatic retry with backoff. It encapsulates the complexity of LibreOffice inter-process communication, including socket management and instance lifecycle. This is a reusable pattern for any application that needs to batch-process documents via LibreOffice without restarting the office process for each file.
An interface defining the contract for cluster coordination primitives: distributed locks, job stores, key-value caches, rate limit stores, and instance registries. The in-process implementation (InProcessClusterBackplane) provides a single-node fallback that can be swapped for a Redis/Valkey-based backplane without changing application code. This pattern is reusable for any multi-node application needing pluggable coordination.
Converts PDF documents to Markdown by extracting text with layout preservation, detecting headings, tables, and lists. It uses PDFBox for content extraction and applies heuristics for structure recognition. The converter is self-contained, handles multi-column layouts, and produces clean Markdown output. This is a non-trivial transformation that can be reused in any document processing pipeline.
A robust executor for external processes that supports configurable timeouts, retry logic with exponential backoff, output capture, and sandboxing policies (e.g., LibreOffice sandbox). It handles process lifecycle, error stream merging, and graceful termination. This is a reusable utility for any Java application that needs to run external commands reliably, especially in containerized or security-sensitive environments.