Skip to content

Latest commit

Β 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“„ AskPDF

Chat with your PDFs. Get grounded answers. Jump straight to the source.

An AI-powered document intelligence application that combines RAG, semantic retrieval, Gemini, and page-aware citations to turn static PDFs into interactive, conversational knowledge.


Live Demo GitHub




✨ What is AskPDF?

AskPDF turns a PDF from a file you read into a document you can talk to.

Upload a document, ask a question in natural language, and AskPDF retrieves the most relevant context before asking Gemini to generate a grounded answer. When the answer comes from a specific part of the document, the application can surface the page reference directly in the conversation and let you jump to that page in the PDF viewer.

The project combines:

  • πŸ“„ PDF text extraction
  • 🧩 document chunking
  • πŸ”Ž embedding-based semantic retrieval
  • 🧠 Retrieval-Augmented Generation (RAG)
  • πŸ“‘ page-aware retrieval
  • 🎯 source/page citations
  • πŸ”— clickable citation navigation
  • πŸ’¬ conversational follow-up questions

The current implementation uses a React + TypeScript frontend and a Node.js + Express + TypeScript backend, with MongoDB for persistence and Gemini for AI capabilities. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L42-L64


πŸŽ₯ Live Demo

πŸ‘‰ Open AskPDF

Upload a PDF β†’ ask a question β†’ inspect the source.


🌟 Why AskPDF?

Most document chat applications stop at:

β€œHere is an answer generated from your PDF.”

AskPDF is designed around a more useful workflow:

β€œHere is the answer β€” and here is where it came from.”

That means the system is not only focused on answering questions, but also on making those answers easier to verify, navigate, and trust.


πŸš€ Features

πŸ“„ Document Intelligence
  • PDF upload and text extraction
  • Page offset calculation
  • Automatic document chunking
  • Temporary file cleanup after processing
  • Support for document-grounded conversational queries
πŸ” Semantic Retrieval
  • Embedding-based retrieval
  • Cosine-similarity ranking
  • Meaning-aware search instead of simple keyword matching
  • Relevant context selection before generation
πŸ“‘ Page-Aware Retrieval

Ask questions such as:

What is mentioned on page 20?

AskPDF can use the requested page context instead of treating the entire document as an undifferentiated text corpus.

🎯 Grounded Answers & Citations
  • Answers are generated from retrieved document context
  • Source pages are surfaced with responses
  • Citations can be clicked to navigate to the relevant PDF page
  • Designed to make answers easier to fact-check
πŸ’¬ Conversational UX

Ask follow-up questions naturally:

What is the main argument?

Can you explain that in simpler terms?

What evidence supports that?

The application is designed to preserve the conversational context needed for follow-up interactions.

πŸ›‘οΈ Reliability & Production Considerations
  • Gemini API error/rate-limit handling
  • Required environment-variable validation
  • CORS configuration
  • Temporary upload cleanup
  • Production frontend/backend deployment

🧠 How AskPDF Works

AskPDF follows a Retrieval-Augmented Generation (RAG) pipeline with additional page-aware logic.

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚     Upload PDF      β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Extract Text      β”‚
                         β”‚ + Page Information  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Chunk Document    β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Generate Embeddings β”‚
                         β”‚      via Gemini     β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   User Question     β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β–Ό                     β–Ό
                Semantic Retrieval      Page Retrieval
                         β”‚                     β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Relevant Context    β”‚
                         β”‚   Selected/Ranked   β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Gemini Generation β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Grounded Answer +   β”‚
                         β”‚ Page Citations      β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Click Citation β†’    β”‚
                         β”‚ Jump to PDF Page    β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The repository describes this flow as text extraction with page offsets, chunking, embedding generation, semantic or page-aware retrieval, context injection, grounded Gemini generation, and clickable PDF navigation. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L107-L131


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         ASKPDF PLATFORM                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚          FRONTEND            β”‚             BACKEND               β”‚
β”‚                              β”‚                                  β”‚
β”‚  React + TypeScript          β”‚  Node.js + Express + TypeScript β”‚
β”‚  Vite                        β”‚                                  β”‚
β”‚  Tailwind CSS                β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  TanStack Query              β”‚  β”‚ Controllers / Routes       β”‚  β”‚
β”‚  Axios                       β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                              β”‚                β”‚                  β”‚
β”‚  PDF Viewer                  β”‚                β–Ό                  β”‚
β”‚  Chat Interface              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  Citation Navigation         β”‚  β”‚ RAG / PDF / Chat Services β”‚  β”‚
β”‚                              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚                 β”‚
               β”‚                                β”‚                 β”‚
               └────────────── HTTP β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
                                                β”‚                 β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
                         β”‚                      β”‚               β”‚ β”‚
                         β–Ό                      β–Ό               β–Ό β”‚
                    MongoDB                 Gemini          pdf-parse
                         β”‚                      β”‚               β”‚ β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The repository is organized around a React/Vite client and a Node/Express server with configuration, controllers, middleware, models, routes, services, utilities, and workers. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L139-L164


πŸ› οΈ Tech Stack

Layer Technology Purpose
Frontend React Interactive document/chat UI
Language TypeScript Type-safe application code
Build Tool Vite Fast frontend development/builds
Styling Tailwind CSS UI styling
Data Fetching TanStack Query Server-state management
HTTP Axios API communication
Backend Node.js + Express API and application server
Database MongoDB + Mongoose Persistence
AI Gemini API Embeddings and generation
PDF pdf-parse PDF text extraction
Deployment Vercel + Render Frontend/backend hosting
Database Hosting MongoDB Atlas Managed MongoDB

This stack reflects the repository's documented frontend, backend, AI/RAG, and deployment technologies. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L69-L103


πŸ“ Project Structure

AskPDF/
β”‚
β”œβ”€β”€ client/                         # React + Vite frontend
β”‚   β”œβ”€β”€ public/                     # Static assets
β”‚   └── src/
β”‚       β”œβ”€β”€ assets/                 # Images and global styles
β”‚       β”œβ”€β”€ components/             # Reusable UI components
β”‚       β”œβ”€β”€ lib/                    # Utilities and API clients
β”‚       └── pages/                  # Main views/routes
β”‚
β”œβ”€β”€ server/                         # Node + Express backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/                 # Configuration/database setup
β”‚   β”‚   β”œβ”€β”€ constants/              # Shared constants
β”‚   β”‚   β”œβ”€β”€ controllers/            # Request handlers
β”‚   β”‚   β”œβ”€β”€ middleware/             # Express middleware
β”‚   β”‚   β”œβ”€β”€ models/                 # Mongoose models
β”‚   β”‚   β”œβ”€β”€ routes/                 # API routes
β”‚   β”‚   β”œβ”€β”€ services/               # RAG, chat, PDF logic
β”‚   β”‚   β”œβ”€β”€ utils/                  # Helper utilities
β”‚   β”‚   └── workers/                # Background processing
β”‚   └── uploads/                    # Temporary PDF storage
β”‚
β”œβ”€β”€ AskPDF.postman_collection.json  # API testing collection
β”œβ”€β”€ DEVELOPMENT.md                  # Development notes/log
└── README.md                       # Project documentation

The repository also includes a Postman collection for manual API testing. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L24-L26


πŸš€ Getting Started

Prerequisites

  • Node.js: v18+
  • MongoDB: local MongoDB or MongoDB Atlas
  • Gemini API Key
  • npm

These prerequisites match the project's documented setup. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L173-L183

1. Clone

git clone https://github.com/Jyatin/AskPDF.git
cd AskPDF

2. Backend

cd server
npm install

Create server/.env, then start the backend:

npm run dev

Backend development server:

http://localhost:5000

3. Frontend

Open another terminal:

cd client
npm install
npm run dev

Frontend development server:

http://localhost:5173

The repository documents these backend/frontend development flows and ports. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L173-L233


πŸ”‘ Environment Variables

Create server/.env:

# Required
MONGO_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/askpdf
GEMINI_API_KEY=your_gemini_api_key
PORT=5000

# Required in production
CORS_ORIGIN=https://ask-pdf-vert.vercel.app

πŸ”’ Never commit real credentials or API keys to Git.

The repository currently documents these environment variables, including the production CORS origin. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L261-L275


πŸ“¦ Production Build

Backend

cd server
npm run build

Frontend

cd client
npm run build

These production build commands are part of the documented workflow. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L235-L257


☁️ Deployment

AskPDF is currently documented as deployed using:

Frontend       β†’ Vercel
Backend        β†’ Render
Database       β†’ MongoDB Atlas
AI             β†’ Gemini API

Production

Frontend

https://ask-pdf-vert.vercel.app/

Backend API

https://askpdf-backend-xt83.onrender.com

Health Check

https://askpdf-backend-xt83.onrender.com/health

The repository documents the Vercel frontend, Render backend, MongoDB Atlas database, and Gemini-based AI deployment. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L281-L296


πŸ§ͺ Testing

AskPDF currently does not have a formal automated test suite.

For API testing and manual verification, the repository includes:

AskPDF.postman_collection.json

This matches the current project documentation. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L300-L304


⚠️ Current Limitations

AskPDF is actively evolving. Current documented limitations include:

  • Conversation history is currently stored in 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 during processing.

These are explicitly documented in the current project README. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L308-L315


πŸ—ΊοΈ Roadmap β€” V2

[x] PDF upload + extraction
[x] Document chunking
[x] Semantic retrieval
[x] RAG-based QA
[x] Page-aware retrieval
[x] Clickable page citations
[ ] Persistent conversations
[ ] Multi-document conversations
[ ] Improved retrieval/ranking
[ ] Dedicated vector database
[ ] Streaming responses
[ ] User authentication
[ ] Persistent cloud document storage
[ ] Large-document background processing
[ ] Advanced table/image understanding

The planned V2 direction currently includes persistent conversations, multi-document support, improved ranking, scalable vector search, streaming responses, authentication, cloud storage, background processing, security improvements, and richer document understanding. ξˆ€fileciteξˆ‚turn13file0ξˆ‚L319-L334


🀝 Contributing

Contributions, ideas, bug reports, issues, and pull requests are welcome.

git checkout -b feature/your-feature

# make your changes

git add .
git commit -m "feat: describe your change"
git push origin feature/your-feature

Then open a Pull Request with:

  • what changed
  • why it changed
  • how it was tested
  • screenshots or recordings for UI changes

πŸ“Œ Project Status

🟒 Active Development

AskPDF is an evolving project focused on making document interaction more grounded, navigable, and useful through retrieval-augmented AI.


πŸ‘¨β€πŸ’» Author

Jyatin Singh

Full-Stack Developer Β· AI Builder Β· Open Source Contributor

GitHub LinkedIn Email


⭐ Support AskPDF

If AskPDF is useful or interesting, consider giving the repository a ⭐.

It helps the project get discovered and encourages continued development.

Upload. Ask. Retrieve. Verify.

πŸ“„ AskPDF


πŸ“„ License

No license is currently specified in the repository.

Add a LICENSE file when you are ready to define how the project may be used, modified, and distributed.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages