Skip to content

samwasted/semanticPDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SemanticPDF

RAG-powered PDF chat application with semantic query capabilities

Next.js TypeScript tRPC OpenAI Supabase

🌐 Live Demo: https://semanticpdf.vercel.app

A modern web application that enables semantic querying of PDF documents through natural language conversations. Built with RAG (Retrieval-Augmented Generation) architecture for contextually accurate responses.

Screenshot 2025-06-22 011551

πŸ”§ Core Features

  • 🧠 Semantic Query Engine: Advanced RAG implementation for contextual document understanding
  • πŸ’¬ Real-time PDF Chat: Live conversations with uploaded documents using OpenAI models
  • πŸ” Vector Embeddings: Document chunking and embedding storage in Pinecone
  • πŸ’³ Subscription Management: Tiered access with Razorpay payment integration
  • πŸ›‘οΈ Type-safe APIs: Full-stack TypeScript with tRPC for end-to-end type safety

βš™οΈ Tech Stack

Frontend

  • Next.js 15 (App Router)
  • TypeScript
  • Tailwind CSS + shadcn/ui
  • React-PDF for document rendering
  • Tanstack Query for data fetching
  • Lucide React icons
  • Sonner notifications

Backend & Infrastructure

  • tRPC for type-safe API layer
  • Supabase (PostgreSQL)
  • Kinde Auth for authentication
  • OpenAI API (GPT + Embeddings)
  • Pinecone vector database
  • Razorpay payment processing

πŸ“‹ Prerequisites

  • Node.js 18+
  • OpenAI API key
  • Pinecone API key
  • Supabase project
  • Kinde Auth application
  • Razorpay account

πŸ“‹ Application Flow

1. πŸ“„ PDF Upload & Processing

Users upload PDFs through the dashboard interface. Documents are processed, chunked, and embedded using OpenAI's text-embedding model, then stored in Pinecone for semantic retrieval.

Screenshot 2025-06-22 011527

2. πŸ” Semantic Query Processing

// Simplified query flow
1. User input β†’ Embedding generation
2. Vector similarity search in Pinecone
3. Context retrieval + RAG prompt construction
4. OpenAI completion with streaming response
5. Real-time UI updates

3. πŸ’¬ Get Answers from PDF

Users can now interact with their uploaded documents through natural language queries. The system provides contextually accurate responses by leveraging the processed embeddings and semantic understanding of the document content.

Screenshot 2025-06-23 111323

πŸ’° Subscription Architecture

πŸ’Ž Pricing Tiers

Screenshot 2025-06-22 011326

Two-tier subscription model with flexible limits and self-managed billing through the dashboard interface.

🧾 Billing Management

Screenshot 2025-06-21 235313

  • Razorpay integration (test mode)

  • Subscription lifecycle management

  • Usage tracking and limits enforcement

  • One-click cancellation with immediate effect

    Note to test payments

    • click on upgrade now
    • fill details (random details work, but you wouldnt get updates through mail or sms)
    • Enter the credit card no. 5267 3181 8797 5449, add another details randomly, choose save card
    • Enter otp, you can also skip it
    • Click on success to confirm payment

πŸ—οΈ Key Implementation Details

πŸ”„ RAG Pipeline

PDF Upload β†’ Text Extraction β†’ Chunking β†’ Embedding β†’ Vector Storage
                                                              ↓
User Query β†’ Query Embedding β†’ Similarity Search β†’ Context Retrieval β†’ LLM Response

πŸ—„οΈ Database Schema

  • User profiles and authentication state
  • Document metadata and processing status
  • Chat conversations and message history
  • Subscription and billing records
  • Usage analytics and rate limiting

πŸ” Authentication Flow

Kinde Auth provides secure OAuth implementation with session management and protected route handling.

πŸ’³ Payment Processing

Razorpay handles subscription creation and management with self-service cancellation through the dashboard. Payment verification links are provided for transaction transparency, with all payments cryptographically verified for enhanced security.

πŸ“ Project Structure

src/
β”œβ”€β”€ app/                    # Next.js 15 App Router
β”œβ”€β”€ components/             # Reusable UI components
β”‚   β”œβ”€β”€ chat/              # Chat interface components
β”‚   └── ui/                # shadcn/ui base components
β”œβ”€β”€ client/                # Client-side utilities
β”œβ”€β”€ config/                # Configuration files
β”œβ”€β”€ db/                    # Database utilities
β”œβ”€β”€ generated/             # Auto-generated files
β”œβ”€β”€ lib/                   # Core utilities and helpers
β”œβ”€β”€ polyfill/              # Browser polyfills
β”œβ”€β”€ trpc/                  # tRPC client configuration
β”œβ”€β”€ types/                 # TypeScript definitions
└── middleware.ts          # Next.js middleware

prisma/                    # Database schema and migrations
public/                    # Static assets

πŸš€ Development Highlights

  • πŸ”’ Full-stack TypeScript: End-to-end type safety from database to UI
  • ⚑ Modern React Patterns: Server components, streaming, and optimistic updates
  • πŸ“ˆ Performance Optimized: Edge functions and efficient vector searches
  • 🎨 Sleek UI: Modern interface built with shadcn/ui and React-PDF integration
  • πŸ” Crypto-verified Payments: Razorpay transactions secured with cryptographic verification

Made by samwasted for CSOC 25

hohfGGW

About

PDF chat powered by RAG, OpenAI responses, Razorpay subscriptions, and a sleek modern UI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors