A full‑stack SaaS that lets you chat with your PDF documents using AI. Upload a PDF, ask questions, and get answers in real time.
PDFSnap turns PDFs into interactive documents. After upload, documents are chunked and embedded, stored in a vector database, and queried with an LLM so you can ask questions and get relevant answers.
| Layer | Technology | Purpose |
|---|---|---|
| Framework | Next.js 13.5 (App Router) | SSR, API routes, file-based routing |
| Language | TypeScript | Type safety across the app |
| API | tRPC | Type-safe API layer and React Query integration |
| Database | MongoDB + Prisma | Document storage and ORM |
| Auth | Kinde | OAuth, login, and registration |
| Payments | Stripe | Subscriptions and billing |
| File Upload | UploadThing | PDF upload and storage |
| AI | OpenAI + LangChain | Embeddings and chat completion |
| Vector Store | Pinecone | Semantic search over document chunks |
| Styling | Tailwind CSS + shadcn/ui | Layout and components |
-
Upload flow – Users upload PDFs via UploadThing. Files are stored, and server-side processing:
- Loads the PDF with LangChain
- Splits it into chunks
- Creates embeddings with OpenAI
- Stores vectors in Pinecone for retrieval
-
Chat flow – Questions are sent to the API route. It:
- Retrieves relevant chunks from Pinecone
- Builds a prompt with the document context
- Streams the LLM response back to the client
-
Data model – Prisma models:
User(from Kinde),File(metadata and status),Message(chat history).
- Chat with PDFs using AI
- Free and Pro plans via Stripe
- PDF viewer with chat sidebar
- Streaming responses for low latency
- Infinite scroll for chat history
- Drag-and-drop uploads
- Responsive UI with shadcn/ui
- Node.js 18+
- MongoDB
- Accounts for: Kinde, OpenAI, Pinecone, Stripe, UploadThing
git clone https://github.com/Aziiz01/PDF.git
cd PDF
npm installCreate a .env file with:
# Database
DATABASE_URL="mongodb+srv://user:[email protected]/dbname?retryWrites=true&w=majority"
# Kinde
KINDE_CLIENT_ID=
KINDE_CLIENT_SECRET=
KINDE_ISSUER_URL=
KINDE_SITE_URL=
KINDE_POST_LOGIN_REDIRECT_URL=
KINDE_POST_LOGOUT_REDIRECT_URL=
# OpenAI
OPENAI_API_KEY=
# Pinecone
PINECONE_API_KEY=
# Stripe
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
# UploadThing
UPLOADTHING_SECRET=
UPLOADTHING_APP_ID=
npx prisma db push
npm run devsrc/
├── app/ # Next.js App Router pages
│ ├── api/ # API routes (tRPC, auth, webhooks)
│ ├── dashboard/ # Dashboard and file chat pages
│ ├── pricing/ # Pricing page
│ └── sign-in/ # Sign-in page
├── components/ # React components
├── config/ # Stripe plans, infinite query config
├── lib/ # Shared utilities and integrations
└── trpc/ # tRPC router and procedures