A sophisticated, full-stack web application engineered to transform Word documents (.doc, .docx) into professional PDF format, featuring an intuitive user interface complemented by robust serverless backend architecture.
This application demonstrates modern web development practices through a comprehensive document conversion solution. The frontend leverages React's component-based architecture whilst the backend utilises Express.js within a serverless paradigm, specifically optimised for Vercel's cloud infrastructure.
- Instantaneous Word document to PDF transformation
- Intuitive drag-and-drop file upload mechanism
- Real-time conversion progress monitoring
- Automated file retrieval following successful conversion
- Responsive design optimised across diverse device specifications
- Secure file management with automatic resource cleanup
- Comprehensive support for .doc and .docx file formats
- File size validation enforcing 10MB threshold
- Contemporary user interface incorporating fluid animations
- Toast notification system providing immediate user feedback
- Rate limiting mechanisms safeguarding API integrity
- Cross-Origin Resource Sharing (CORS) and security middleware implementation
- React 18 - Contemporary React framework utilising hooks and functional components
- Vite - High-performance build tool and development server
- Tailwind CSS - Utility-first CSS framework for rapid interface development
- Axios - Promise-based HTTP client for API communication
- React Hot Toast - Elegant toast notification library
- React Icons - Comprehensive iconography collection
- Node.js - JavaScript runtime environment
- Express.js - Minimalist web application framework
- Multer - Middleware facilitating multipart/form-data file uploads
- Mammoth - Library extracting textual content from Word documents
- PDF-lib - Sophisticated PDF document creation library
- Helmet - Security middleware establishing protective HTTP headers
- CORS - Cross-Origin Resource Sharing middleware
- Express Rate Limit - Request throttling middleware
Prior to installation, ensure the following dependencies are satisfied:
- Node.js: Version 18.x or subsequent release
- npm: Version 8.x or subsequent release
Verify installed versions via terminal:
node -v
npm -vgit clone https://github.com/nayandas69/word-to-pdf-converter.git
cd word-to-pdf-converterInstall dependencies across all project segments (root, backend, frontend):
npm run install-depsThis command executes the following operations:
- Root dependency installation
- Backend dependency installation
- Frontend dependency installation
The backend requires environment variables for operational configuration. A default .env file exists within the backend directory configured for development:
# Server Configuration
PORT=3000
NODE_ENV=development
# CORS Configuration
FRONTEND_URL=http://localhost:5173
# File Upload Configuration
MAX_FILE_SIZE=10485760
ALLOWED_FILE_TYPES=.doc,.docx
# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100For production deployment, modify the FRONTEND_URL parameter to correspond with your deployed frontend URL.
Execute both frontend and backend development servers simultaneously:
npm run devThis initiates:
- Backend server: http://localhost:3000
- Frontend server: http://localhost:5173
Backend server exclusively:
npm run serverFrontend client exclusively:
npm run clientGET /healthReturns API operational status and version information.
Response Structure:
{
"status": "OK",
"message": "Word to PDF Converter API is running",
"timestamp": "2025-12-30T08:25:02.985Z",
"version": "1.0.0",
"endpoints": {
"health": "/health",
"convert": "/convert (POST)"
}
}POST /convertRequest Specification:
- Method:
POST - Content-Type:
multipart/form-data - Body: Form data containing
filefield with Word document
Response Specification:
- Success: Binary PDF file stream
- Error: JSON-formatted error message
cURL Example:
curl -X POST \
https://<your-domain>/convert \
-H 'Content-Type: multipart/form-data' \
-F 'file=@/path/to/document.docx'The backend has undergone substantial architectural modifications to accommodate Vercel's serverless function paradigm:
Major Architectural Changes:
- Serverless Function Adaptation - Transformed traditional Express server into serverless-compatible export
- File System Modifications - Migrated from persistent storage to ephemeral
/tmpdirectory - Route Configuration - Restructured routing to eliminate
/apiprefix duplication - Lifecycle Management - Removed long-running processes incompatible with serverless execution
- Entry Point Creation - Established
api/index.jsas Vercel function entry point
Critical Implementation Notes:
- The
app.listen()invocation remains commented in production code - File storage utilises
/tmpdirectory exclusively in serverless environment - Background cleanup processes have been disabled for serverless compatibility
- Maximum execution duration constrained by Vercel's function timeout limits
The frontend application requires static hosting infrastructure:
-
Build Production Assets:
cd frontend npm run build -
Deploy Compiled Assets - Upload
distdirectory to hosting provider (Vercel, Netlify, Cloudflare Pages) -
Environment Configuration - Update API base URL to reference deployed backend endpoint
-
Repository Integration:
- Link GitHub repository to Vercel dashboard
- Import project and configure deployment settings
-
Configuration Parameters:
- Set Root Directory:
backend - Configure Build Command: Leave empty (auto-detected)
- Configure Output Directory: Leave empty
- Set Root Directory:
-
Environment Variables: Navigate to Vercel project settings and configure:
NODE_ENV=productionFRONTEND_URL=https://your-frontend-domain.vercel.appMAX_FILE_SIZE=10485760ALLOWED_FILE_TYPES=.doc,.docxRATE_LIMIT_WINDOW_MS=900000RATE_LIMIT_MAX_REQUESTS=100
-
Deployment Execution:
- Commit changes to repository
- Vercel automatically triggers deployment pipeline
- Monitor deployment logs for successful completion
Serverless Constraints:
- Function execution timeout: 10 seconds (Hobby tier), 60 seconds (Pro tier)
- Request payload limitation: 4.5MB (Hobby tier)
- Ephemeral file system:
/tmpdirectory only - No persistent storage without external service integration
For applications requiring extended execution duration or persistent storage:
- Railway: Supports persistent storage and prolonged execution periods
- Render: Complimentary tier with comprehensive Node.js support
- Fly.io: Global distribution with persistent volume capabilities
- DigitalOcean App Platform: Scalable infrastructure with persistent storage options
The application incorporates multiple security layers:
- Helmet.js - Configures security-oriented HTTP response headers
- CORS - Restricts resource access to designated frontend origin
- Rate Limiting - Implements IP-based request throttling (100 requests per 15-minute window)
- File Validation - Validates file type, dimensions, and content integrity
- Automatic Cleanup - Removes uploaded files post-processing
- Input Sanitisation - Validates and sanitises all user inputs
Comprehensive error handling encompasses:
{
"success": false,
"message": "Descriptive error message",
"error": "ERROR_CODE",
"timestamp": "2025-12-30T08:25:02.985Z"
}UPLOAD_ERROR- File upload operation failedVALIDATION_ERROR- File validation criteria not satisfiedCONVERSION_ERROR- PDF conversion process encountered failureFILE_TOO_LARGE- File exceeds maximum size thresholdINVALID_FILE_TYPE- Unsupported file format submitted
- File size limitations preventing excessive resource consumption
- Automatic cleanup routines eliminating orphaned temporary files
- Rate limiting mechanisms preventing server resource exhaustion
- Minified production builds reducing bandwidth requirements
- Component lazy loading improving initial page load performance
- Asset optimisation reducing overall application footprint
- Fork repository via GitHub interface
- Create feature branch (
git checkout -b feature/enhancement-name) - Commit modifications (
git commit -m 'Implement enhancement description') - Push to branch (
git push origin feature/enhancement-name) - Submit Pull Request with comprehensive description
This project operates under the MIT Licence. Refer to the LICENSE file for complete terms and conditions.
Should you encounter difficulties or require clarification:
- Examine the Issues section
- Create a detailed issue report including reproduction steps
- Contact repository maintainer: Nayan Das
- Mammoth - Word document text extraction
- PDF-lib - PDF generation capabilities
- React - Frontend framework
- Tailwind CSS - Utility-first CSS framework
- Express.js - Backend web framework
- Vercel - Serverless deployment platform