How elliott-chong/chatpdf-yt works
Main Components
A. Client-Side (Frontend) Layer:
• Next.js Pages and Components
• React Query for state management
• PDF Viewer component
• Chat Interface components
B. Server-Side (Backend) Layer:
• Next.js API Routes
• Authentication System (Clerk)
• File Storage (AWS S3)
• Database (PostgreSQL with Drizzle ORM)
• Vector Database (Pinecone)
• AI Integration (OpenAI)
• Payment Processing (Stripe)
┌─ Client Layer ─────────────────────┐
• Pages (/, /chat/[chatId], etc.) │
• React Components │
• UI Components │
• ┬───────────────────┘
• ↓
┌─ API Layer ────────────────────────┐
• Authentication Middleware │
• API Routes (/api/*) │
• Webhook Handlers │
• ┬───────────────────┘
• ↓
┌─ Service Layer ─────────────────────┐
• PDF Processing │
• Chat Management │
• Subscription Handling │
• File Storage Operations │
• ┬───────────────────┘
• ↓
┌─ External Services ────────────────┐
• Clerk Auth │
• AWS S3 │
• OpenAI │
• Pinecone │
• Stripe │
• ┬───────────────────┘
• ↓
┌─ Database Layer ────────────────────┐
• PostgreSQL (via Drizzle ORM) │
• Schema (users, chats, messages) │
• ┘
Key Flows to Highlight
A. PDF Processing Flow:
User → FileUpload → S3 Storage → Pinecone Embeddings → Database
B. Chat Flow:
User → ChatComponent → API Routes → OpenAI → Database → Response
C. Subscription Flow:
User → SubscriptionButton → Stripe API → Webhook → Database
Important Details
• Relationship between components in /src/components and their corresponding API routes
• How the middleware.ts file handles authentication across the application
• Demonstrate the connection between the database schema (schema.ts) and the API routes
• How the Providers component wraps the application for global state and authentication