An AI-powered document Q&A application that allows users to upload PDF or text documents and ask natural language questions about their content. The app uses OpenAI's GPT model to generate accurate answers based solely on the uploaded document.
- Document Upload — Support for PDF and TXT files (up to 10MB)
- AI-Powered Q&A — Ask natural language questions and receive context-aware answers
- Question History — All questions and answers are saved per document
- Multiple Documents — Upload and manage multiple documents
- Modern UI — Clean, responsive interface
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose ODM
- AI Integration: OpenAI GPT-3.5-turbo API
- View Engine: Handlebars
- File Processing: Multer (uploads), pdf-parse (PDF text extraction)
- User uploads a PDF or text document
- The application extracts text content from the file
- Document content is stored in MongoDB
- User asks a question about the document
- The question and document content are sent to OpenAI's API
- AI generates an answer based solely on the document content
- Q&A history is saved for future reference
- Node.js (v16 or higher)
- MongoDB (local or MongoDB Atlas)
- OpenAI API Key
- Clone the repository
git clone https://github.com/yourusername/docuquery-ai.git
cd docuquery-ai- Install dependencies
npm install- Create environment file
cp .env.example .env- Configure environment variables in
.env
OPENAI_API_KEY=your_openai_api_key
MONGODB_URI=your_mongodb_connection_string
PORT=3000
- Start the application
npm start- Open
http://localhost:3000in your browser
docuquery-ai/
├── models/
│ └── Document.js # MongoDB document schema
├── routes/
│ └── documentRoutes.js # Express routes
├── services/
│ ├── extractionService.js # PDF/text extraction
│ └── openaiService.js # OpenAI API integration
├── views/
│ ├── layouts/
│ │ └── main.handlebars # Main layout
│ ├── home.handlebars # Home page
│ └── document.handlebars # Document Q&A page
├── public/
│ └── css/
│ └── style.css # Styles
├── uploads/ # Temporary file uploads
├── server.js # Application entry point
├── package.json
└── .env.example
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Home page with upload form |
| POST | /upload |
Upload a new document |
| GET | /document/:id |
View document and Q&A interface |
| POST | /document/:id/ask |
Submit a question |
| POST | /document/:id/delete |
Delete a document |
| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key |
MONGODB_URI |
MongoDB connection string |
PORT |
Server port (default: 3000) |
Ibrahim Al Shouli
Software Engineering Student — University of Doha for Science and Technology