An intelligent PDF analysis tool that leverages AI to extract, analyze, and provide insights from PDF documents.
pdf-analyzer/
├── api/ # Serverless API endpoints
│ └── health.js # Health check endpoint
├── public/ # Static files
│ ├── css/ # Stylesheets
│ │ └── styles.css # Main stylesheet
│ └── index.html # Landing page
├── index.js # Express server configuration
├── package.json # Project dependencies
├── vercel.json # Vercel deployment configuration
└── README.md # Project documentation
-
Install Dependencies
npm install
-
Environment Variables Create a
.envfile in the root directory with:PORT=3004 GEMINI_API_KEY=your_api_key_here GEMINI_API_ENDPOINT=your_api_endpoint_here -
Start Development Server
npm run dev
The server will start on http://localhost:3004
-
View Landing Page
- Open your browser and navigate to http://localhost:3004
- You should see the PDF Analyzer landing page
- The page is responsive and will adapt to different screen sizes
- When deployed, the landing page will be accessible at https://parsepdf.io
-
Install Vercel CLI
npm install -g vercel
-
Configure Domain
- Log into your Vercel account
- Add
parsepdf.ioas a custom domain - Configure DNS settings as provided by Vercel
-
Environment Variables Set the following environment variables in your Vercel project settings:
GEMINI_API_KEY: Your Google Gemini API keyGEMINI_API_ENDPOINT: Your Google Gemini API endpoint
-
Deploy
vercel
For production deployment:
vercel --prod
PORT: Server port (default: 3004)GEMINI_API_KEY: Your Gemini API key (get it from Google AI Studio)NODE_ENV: Environment setting (development/production)
Create a .env file in the root directory:
# Server Configuration
PORT=3004
# Gemini API Configuration
GEMINI_API_KEY=your-api-key- Go to your project settings in the Vercel dashboard
- Navigate to the Environment Variables section
- Add the required variables:
GEMINI_API_KEYGEMINI_API_ENDPOINT
- Deploy your project to apply the changes
The application supports PDF file upload through:
- Drag and drop interface
- Traditional file picker
When a file is selected:
- The file name and size are displayed
- Only PDF files are accepted
- An "Analyze PDF" button appears
- Base fee: $1.00 per document
- Per record: $0.10
-
Local Testing
- Start the development server:
npm run dev - Open http://localhost:3004 in your browser
- Try uploading a PDF file by: a. Dragging and dropping a PDF onto the upload zone b. Clicking the upload zone and selecting a PDF
- Verify that:
- The file name and size are displayed
- Non-PDF files are rejected
- The "Analyze PDF" button appears after selection
- Start the development server:
-
Production Testing
- Visit the deployed site
- Perform the same upload tests as above
- Verify the upload interface is responsive on mobile devices
GET /api/health: Health check endpoint- Returns:
{ status: 'healthy', timestamp: '...' }
- Returns:
POST /api/analyze: Upload and analyze a PDF file- Content-Type:
multipart/form-data - Body:
pdf: PDF file (required)
- Size Limit: 10MB
- Returns:
{ "success": true, "message": "File successfully processed", "data": { "sessionId": "uuid-v4", "filename": "example.pdf", "size": 1234567, "mimeType": "application/pdf", "base64Preview": "...", "base64": "full-base64-string" } }
- Content-Type:
- Visit the landing page
- Upload a PDF file using drag-and-drop or file picker
- Click "Analyze PDF"
- Check the response in the UI
- Create a new POST request to
/api/analyze - Set the request type to
multipart/form-data - Add a field named
pdfand select a PDF file - Send the request
- Verify the JSON response includes:
- Success status
- Session ID
- Summary of the PDF content
- Structured data extracted from the PDF
curl -X POST \
-F "pdf=@/path/to/your/file.pdf" \
http://localhost:3004/api/analyze- File too large (>10MB):
{ "success": false, "message": "File too large" } - Invalid file type:
{ "success": false, "message": "Only PDF files are allowed" }