This is a SAFE PUBLIC DEMO project designed to showcase a production-style Node.js Express backend architecture. It contains:
- ✅ No real secrets or API keys
- ✅ No production integrations or external services
- ✅ Mock-only PDF processing operations
- ✅ Safe for public GitHub repositories and Trust & Safety reviews
This project serves as a demonstration backend for PDFLines, a hypothetical SaaS platform for PDF processing operations. It implements clean architecture principles with modular routing, controllers, and services to illustrate best practices for building scalable Node.js APIs.
The API provides mock implementations of common PDF operations (merge, split) that simulate real processing without any actual file manipulation or external dependencies.
This project demonstrates a production-style Express.js backend with clean architecture principles, including:
- Modular routing, controllers, and services
- Request logging and validation
- Mock PDF processing endpoints
- Professional project structure
- Comprehensive error handling
- POST /merge: Mock PDF merging functionality
- POST /split: Mock PDF splitting functionality
- GET /health: Health check endpoint
- GET /version: API version information
- Clean architecture with separation of concerns
- Request logging with Morgan
- Input validation with express-validator
- Request ID tracking for debugging
- Comprehensive error handling
src/
├── routes/ # Route definitions
├── controllers/ # Request handlers
├── services/ # Business logic (mock implementations)
├── app.js # Express app configuration
└── server.js # Server startup
- Clone the repository
- Install dependencies:
npm install
- Copy environment file:
cp .env.example .env
- Start the development server:
npm run dev
http://localhost:3000
Returns the current status of the API service.
GET /healthResponse (200 OK):
{
"status": "ok",
"timestamp": "2023-12-01T12:00:00.000Z",
"service": "PDFLines API",
"version": "1.0.0"
}Returns version information about the API.
GET /versionResponse (200 OK):
{
"version": "1.0.0",
"name": "pdflines-api",
"description": "Demo backend API for PDFLines",
"environment": "development"
}Combines multiple PDF files into a single document.
POST /merge
Content-Type: application/json
{
"files": ["document1.pdf", "document2.pdf", "document3.pdf"]
}Request Body:
files(array of strings, required): Array of PDF filenames to merge (minimum 2 files)
Response (200 OK):
{
"message": "PDFs merged successfully",
"output": "merged.pdf",
"processingTime": "150ms",
"fileCount": 3,
"totalPages": 30
}Error Response (400 Bad Request):
{
"error": "Validation failed",
"details": [
{
"msg": "Files must be an array with at least 2 items",
"param": "files",
"location": "body"
}
]
}Extracts specific pages from a PDF file into separate documents.
POST /split
Content-Type: application/json
{
"file": "input.pdf",
"pages": [1, 3, 5, 7]
}Request Body:
file(string, required): Name of the PDF file to splitpages(array of integers, required): Array of page numbers to extract (minimum 1 page)
Response (200 OK):
{
"message": "PDF split successfully",
"output": ["page1.pdf", "page3.pdf", "page5.pdf", "page7.pdf"],
"processingTime": "120ms",
"pagesExtracted": 4,
"originalFile": "input.pdf"
}Error Response (400 Bad Request):
{
"error": "Validation failed",
"details": [
{
"msg": "Each page must be a positive integer",
"param": "pages.0",
"location": "body"
}
]
}This project follows clean architecture principles:
- Routes: Define API endpoints and delegate to controllers
- Controllers: Handle HTTP requests, perform validation, and call services
- Services: Contain business logic (mocked for this demo)
- App.js: Configures Express middleware and routes
- Server.js: Starts the HTTP server
- Node.js
- Express.js
- Morgan (logging)
- express-validator (validation)
- dotenv (environment variables)
This is a demonstration project only. It contains no real PDF processing, secrets, or production integrations. All responses are mocked for illustrative purposes.
MIT