InsightPDF is a Next.js application that allows users to chat with their PDF documents using AI. Upload any PDF and start asking questions about its content.
- 📄 PDF file upload and processing

- 💬 Real-time chat interface

- 🔍 Semantic search within PDFs

- 👤 User authentication

- 📱 Responsive design

- 💾 Persistent chat history
Before you begin, ensure you have:
- Node.js 18+ installed
- PostgreSQL database
- AWS S3 bucket
- Pinecone account
- OpenAI API key
- Clerk account
Create a .env file in the root directory with the following variables:
# Database
DATABASE_URL="your-postgresql-connection-string"
# AWS S3
AWS_ACCESS_KEY_ID="your-aws-access-key"
AWS_SECRET_ACCESS_KEY="your-aws-secret-key"
AWS_REGION="your-aws-region"
NEXT_PUBLIC_S3_BUCKET_NAME="your-bucket-name"
# Pinecone
PINECONE_API_KEY="your-pinecone-api-key"
PINECONE_INDEX_NAME="your-pinecone-index-name"
# OpenAI
OPENAI_API_KEY="your-openai-api-key"
# Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="your-clerk-publishable-key"
CLERK_SECRET_KEY="your-clerk-secret-key"- Clone the repository:
git clone <repository-url>
cd insightpdf- Install dependencies:
npm install- Set up the database:
npm run db:push- Run the development server:
npm run dev- Open http://localhost:3000 with your browser.
src/
├── app/ # Next.js app router
│ ├── api/ # API routes
│ ├── chat/ # Chat interface
│ └── page.tsx # Home page
├── components/ # React components
├── lib/ # Utility functions
│ ├── db/ # Database configuration
│ ├── pinecone.ts # Pinecone setup
│ └── s3-server.ts # AWS S3 configuration
POST /api/create-chat- Create new chat sessionPOST /api/chat- Handle chat messagesGET /api/get-context- Get PDF contextPOST /api/add-message- Save chat messages
To run tests:
npm run testTo run linting:
npm run lint- Build the application:
npm run build- Start the production server:
npm start- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.