A full-stack SaaS application that allows users to upload PDF documents and engage in intelligent, context-aware conversations with their data.
- Upload: Create a free account and upload any standard PDF document (manuals, research papers, textbooks).
- Process: The system automatically reads, chunks, and vectorizes the document in seconds.
- Chat: Ask direct questions in the chat interface. The AI will instantly search the document and provide accurate, context-aware answers based strictly on the uploaded file.
- End-to-End Type Safety (tRPC): Instead of relying on fragile REST endpoints, the entire API layer is built with tRPC. This ensures strict, compile-time type safety across the Next.js client and server boundaries, completely eliminating a whole class of runtime errors.
- Vector Search Database (Pinecone): To give the AI "memory" of large documents without exceeding token limits, uploaded PDFs are converted into vector embeddings and stored in Pinecone. This allows for lightning-fast semantic similarity searches whenever a user asks a question.
- AI Orchestration (LangChain): The complex Retrieval-Augmented Generation (RAG) pipeline is orchestrated using LangChain. It seamlessly connects the user's prompt, the retrieved document context from Pinecone, and the LLM to generate highly accurate responses.
- Optimized PDF Rendering: Utilizes
react-pdfto render large documents smoothly directly in the browser. The split-pane UI allows users to read the source material alongside the active AI chat. - Secure File Hosting: Uploaded files are securely managed and served via UploadThing, ensuring fast processing and a clean separation of media storage from the core database.
- Framework: Next.js 13 (App Router), React, TypeScript
- API Layer: tRPC (with React Query)
- AI & Machine Learning: LangChain, OpenAI
- Vector Database: Pinecone
- Relational Database: PostgreSQL, Prisma ORM
- Authentication: Clerk
- UI & Styling: Tailwind CSS, Radix UI Primitives,
react-textarea-autosize
To run this project locally, you will need active accounts/API keys for Clerk, Pinecone, UploadThing, and OpenAI.
-
Clone the repository:
git clone [https://github.com/Akash4510/doc-chat.git](https://github.com/Akash4510/doc-chat.git) cd doc-chat -
Install dependencies:
npm install
-
Environment Configuration: Create a
.envfile in the root directory and populate it with your keys:DATABASE_URL= NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY= CLERK_SECRET_KEY= OPENAI_API_KEY= PINECONE_API_KEY= UPLOADTHING_SECRET= UPLOADTHING_APP_ID=
-
Initialize Database:
npx prisma generate npx prisma db push
-
Start the development server:
npm run dev
Built alongside the in-depth tutorial by Josh Tried Coding. A huge shoutout to Josh for creating such a thorough walkthrough on building end-to-end type-safe SaaS platforms and modern RAG pipelines!


