AskPDF is an AI-powered document question-answering application that allows users to upload PDFs, ask conversational questions about their documents, receive grounded answers, and seamlessly navigate directly to cited pages.
🚀 Live Demo: https://ask-pdf-vert.vercel.app/
💻 GitHub: https://github.com/Jyatin/AskPDF
📧 Contact: singhjyatin@gmail.com
- 📄 PDF Upload & Text Extraction: Upload PDF documents and extract textual content accurately.
- 🧩 Document Chunking: Automatically divides documents into optimal segments for context retrieval.
- 🔍 Embedding-based Semantic Retrieval: Finds the most relevant document sections using vector embeddings and cosine similarity.
- 🧠 RAG & Gemini-Powered QA: Uses Retrieval-Augmented Generation with the Gemini API to provide highly accurate, grounded answers.
- 📑 Page-Aware Retrieval: Understands queries like "What is mentioned on page 20?" and retrieves the exact page context.
- 🎯 Page-Based Source Citations: AI responses include precise page references for fact-checking.
- 🔗 Clickable Citations: Clicking a citation in the chat instantly navigates the built-in PDF viewer to that exact page.
- 💬 Conversational Context: Handles follow-up questions gracefully (e.g., "Can you elaborate on that?").
- 🛡️ Graceful Error Handling: Robust handling of Gemini API rate limits and errors.
- 🧹 Temporary PDF Cleanup: Automatically removes temporary files from backend storage after processing.
- 🔒 Production Validation & CORS: Validates required environment variables on startup and secures API access via CORS.
- 📱 Responsive Frontend: Clean, modern, and fully responsive user interface.
Frontend:
- React
- TypeScript
- Vite
- Tailwind CSS
- TanStack Query
- Axios
Backend:
- Node.js
- Express.js
- TypeScript
- MongoDB / Mongoose
- Gemini API
- pdf-parse
AI / RAG:
- RAG (Retrieval-Augmented Generation)
- Embeddings
- Cosine similarity
- Page-aware retrieval
- Gemini
Deployment:
- Vercel (Frontend)
- Render (Backend)
- MongoDB Atlas (Database)
The application follows a standard RAG (Retrieval-Augmented Generation) pipeline, enhanced with page-aware logic:
User uploads PDF
↓
Text extraction + page offsets calculated
↓
Document chunking
↓
Embeddings generated via Gemini
↓
User asks a question
↓
Semantic retrieval OR Page-aware retrieval
(Extracts relevant chunks based on meaning or specific page requests)
↓
Relevant context injected into prompt
↓
Gemini API generates grounded answer + sources
↓
UI renders answer with clickable PDF page navigation
AskPDF/
├── client/ # React + Vite frontend
│ ├── public/ # Static assets
│ └── src/ # Frontend source code
│ ├── assets/ # Images and global styles
│ ├── components/ # Reusable UI components
│ ├── lib/ # Utility functions and API clients
│ └── pages/ # Main application views/routes
├── server/ # Node.js + Express backend
│ ├── src/ # Backend source code
│ │ ├── config/ # Database connection configuration
│ │ ├── constants/ # App-wide constants
│ │ ├── controllers/ # Route controllers
│ │ ├── middleware/ # Express middlewares (CORS, Multer)
│ │ ├── models/ # Mongoose database schemas
│ │ ├── routes/ # Express API routes
│ │ ├── services/ # Core business logic (RAG, Chat, PDF parsing)
│ │ ├── utils/ # Helper utilities
│ │ └── workers/ # Background tasks/workers
│ └── uploads/ # Temporary local storage for uploaded PDFs
├── AskPDF.postman_collection.json # API testing collection
└── README.md # Project documentation
- Node.js (v18+)
- MongoDB connection string (e.g., MongoDB Atlas)
- Gemini API Key
git clone https://github.com/Jyatin/AskPDF.git
cd AskPDFcd server
npm installCreate a .env file in the server directory (see Environment Variables section below).
Start the development server:
npm run dev(Runs on http://localhost:5000)
Open a new terminal window:
cd client
npm install
npm run dev(Runs on http://localhost:5173)
To build the projects for production:
Backend:
cd server
npm run buildFrontend:
cd client
npm run buildCreate a .env file in the server directory. Real secrets must never be committed to version control.
# Required
MONGO_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/askpdf
GEMINI_API_KEY=your_gemini_api_key
PORT=5000
# Required in Production (Matches your frontend URL)
CORS_ORIGIN=https://ask-pdf-vert.vercel.appThe application is deployed across the following services:
- Frontend: Vercel
- Backend: Render (Web Service)
- Database: MongoDB Atlas
- AI Engine: Gemini API
Production URLs:
- Frontend: https://ask-pdf-vert.vercel.app/
- Backend API:
https://askpdf-backend-xt83.onrender.com - Health Check:
https://askpdf-backend-xt83.onrender.com/health(Returns 200 OK status)
There is currently no formal automated test suite. The repository includes an AskPDF.postman_collection.json file at the root for manual API testing and verification.
- Conversation history is stored in the frontend React state and is lost after a page reload.
- Semantic retrieval currently calculates cosine similarity in application memory rather than using a dedicated vector database.
- Retrieval is not optimized for very large document collections.
- Uploaded PDFs use temporary backend local storage (
/uploads) during processing before being cleaned up.
The following features are planned for future releases:
- Persistent conversations (saving chat history to the database)
- Multi-document conversations
- Improved retrieval and ranking pipelines
- Scalable vector search integration (e.g., Pinecone, Milvus)
- Streaming AI responses for lower perceived latency
- User authentication and accounts
- Persistent cloud document storage (e.g., AWS S3)
- Background document processing for massive PDFs
- Rate limiting and API security improvements
- Advanced document understanding (tables, images, complex layouts)
Contributions, suggestions, bug reports, issues, and pull requests are always welcome!
Feel free to reach out via email: singhjyatin@gmail.com
Jyatin Singh
- GitHub: https://github.com/Jyatin/AskPDF
- Live Demo: https://ask-pdf-vert.vercel.app/
- Email: singhjyatin@gmail.com
License: To be determined.