How julianfbeck/localpdfmerger works
Project type and purpose
• This is a full-stack web application built with Next.js that runs most of its core logic client-side via WebAssembly. Its purpose is to allow users to merge, optimize, extract, and watermark PDF files entirely in their browser (no server-side PDF processing), with an optional payment/donation API.
File structure
• Top-level files:
• Dockerfile + captain-definition: containerized deployment via CapRover
• next.config.js, package.json: Next.js configuration & dependencies
• Directories:
• pages/: Next.js pages and API routes.
• components/: React/Chakra UI building blocks (Header, Footer, Hero, DonationModal, DragDrop, etc.).
• public/: static assets (pdfcpu.wasm, wasm_exec.js, browserconfig, manifest, sitemap).
• scripts/: supporting JS for initializing the Go WASM runtime.
• Patterns:
• Component-based UI in React/Chakra UI
• “pages/api” directory used for serverless functions (e.g. payment.js)
• Client-side WebAssembly module for PDF processing
Extract additional insights from the README
• Uses pdfcpu (Go) compiled to WebAssembly to process PDFs in-browser.
• No user files leave the client machine.
• Hosting: CapRover (Docker), built from this repository.
• UI Framework: Next.js + Chakra UI
• Payment/donation endpoint under pages/api/payment.js
a. Main components:
1. Browser (Client)
• React pages & components (pages/index.js, pages/merge.js, etc.)
• Chakra UI for styling/layout
• pdfcpu.wasm + wasm_exec.js (client-side PDF engine)
2. Next.js Server
• SSR/SSG endpoints (optional)
• API Routes (pages/api/payment.js)
3. External Payment Service (e.g. Stripe)
4. Hosting/Infrastructure
• Docker container
• CapRover orchestration
b. Relationships & interactions:
• Browser → Next.js Server: initial page requests, static asset fetch (WASM, JS, CSS).
• Browser → Browser-WASM: drag-drop file → pdfcpu.wasm processes PDF locally → returns result to UI.
• Browser → Next.js API: donation/payment requests → forwarded to External Payment Service → back.
• Next.js Server → CapRover/Docker: deployed container runs Node/Next.js.
c. Architectural patterns & principles:
• Component-based UI for modularity and reuse
• Client-side PDF processing avoids server overhead & privacy concerns
• Serverless functions (Next.js API routes) for lightweight backend tasks
• Containerized deployment for portability
d. Key technologies & libraries:
• Next.js (React Framework)
• Chakra UI (UI Components)
• Go-compiled WebAssembly (pdfcpu.wasm + wasm_exec.js)
• Docker + CapRover
• (Implied) Payment SDK (e.g. Stripe)