How zalwan/pdf-splitter works
Project type and purpose
• This is a monolithic, server-rendered web application (full-stack) written in Golang using the Gin framework.
• Its single business purpose is to accept a user-uploaded PDF, split it into single-page files (using pdfcpu), rename them per user input, bundle them into a ZIP, and present the ZIP for download.
File structure
• Top level:
• main.go → application entry point; sets up the Gin router and handlers
• go.mod, go.sum → dependency management (Gin, pdfcpu, etc.)
• Dockerfile → containerization setup
• .github/workflows/go.yml → CI pipeline (build/test)
• templates/ → HTML templates for the web UI
• Runtime (per README):
• uploads/ → storage for incoming PDF files
• temp_outputs/ → workspace for individual page files before zipping
README insights
• Confirms architecture is a single Gin HTTP server
• Lists core dependencies: pdfcpu for PDF operations; HTML templates for the view layer
• No external services or databases—only local file I/O and streaming response
Main components and their relationships
a. Browser (Client)
– Renders templates/index.html
– Submits multipart/form-data to /split endpoint
b. Gin Web Server (main.go)
– Routes:
• GET / → serve upload form
• POST /split → handler logic
– Invokes pdfcpu library to split PDF pages
– Renames pages based on user input
– Invokes ZIP compressor to bundle split files
– Serves the ZIP as an HTTP response
c. File Storage
– uploads/ (persistent or ephemeral storage for raw uploads)
– temp_outputs/ (transient directory for split page files)
d. PDF Processing Library
– pdfcpu (API calls inside handler)
e. ZIP Compressor
– Go’s archive/zip or custom packer within handler
Key architectural patterns and design principles
• Layered (Presentation → Business Logic → Storage)
• Single-responsibility handlers (one endpoint uploads, one splits)
• Temporary workspace for heavy I/O operations, cleaned up post-request
• Containerized build/deploy via Dockerfile + GitHub Actions