Skip to content

Repository files navigation

📝 Doc Chat: AI-Powered PDF Chat

A full-stack SaaS application that allows users to upload PDF documents and engage in intelligent, context-aware conversations with their data.

thumbnail

working-demo chat-preview

📖 How to Use

  1. Upload: Create a free account and upload any standard PDF document (manuals, research papers, textbooks).
  2. Process: The system automatically reads, chunks, and vectorizes the document in seconds.
  3. 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.

🚀 Key Engineering Features

  • 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-pdf to 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.

🛠️ The Tech Stack

  • 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

💻 Local Development Setup

To run this project locally, you will need active accounts/API keys for Clerk, Pinecone, UploadThing, and OpenAI.

  1. Clone the repository:

    git clone [https://github.com/Akash4510/doc-chat.git](https://github.com/Akash4510/doc-chat.git)
    cd doc-chat
  2. Install dependencies:

    npm install
  3. Environment Configuration: Create a .env file 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=
  4. Initialize Database:

    npx prisma generate
    npx prisma db push
  5. Start the development server:

    npm run dev

👏 Acknowledgments

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!

About

An AI-powered document analysis tool using LangChain and Pinecone.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages