How shrived00/chatwithpdf works
Project type and purpose
• This is a full-stack Next.js application (Next.js 13 “app” router) that provides a chat interface with file/PDF upload and AI-driven embeddings/search.
• It uses server-side API routes for chat creation and messaging, a relational database via Drizzle ORM, vector search via Pinecone, file storage (S3), and Firebase for authentication.
File structure
• Top level: next.config.mjs, drizzle.config.ts, tailwind.config.ts, middleware.ts.
• src/app: React pages & layouts (app/page.tsx, app/layout.tsx), nested routes for /chat/[chatId], /sign-in, /sign-up.
• src/app/api: serverless routes chat (route.tsx) and create-chat (route.ts).
• src/components: reusable UI (ChatComponent, ChatSideBar, FileUpload, PDFViewer) and a local “ui” primitives library.
• src/lib: business logic & data layer
• lib/context.ts – React context/provider
• lib/db – Drizzle ORM schema & index
• lib/embeddings.ts – OpenAI embedding logic
• lib/pinecone.ts – Pinecone vector store integration
• lib/s3-server.ts – AWS S3 file storage helper
• lib/utils.ts – misc utilities
• firebase.ts: Firebase SDK initialization for auth.
• drizzle.config.ts: configuration for relational database.
Extract insights from README
• Bootstrapped with create-next-app, uses Next.js features and API routes, deployed on Vercel.
Elements
• Clear labels: “Browser (React)”, “Next.js API: create-chat”, “Next.js API: chat”, “Relational DB (Drizzle)”, “Vector DB (Pinecone)”, “File Storage (S3)”, “Auth (Firebase)”, “AI Service (OpenAI)”.
• From Browser to API routes (with HTTP verbs e.g. POST /api/chat)
• From API routes to each service or library layer
• Back from services to API then to Browser
• Blue rectangles for internal components (frontend, API)
• Orange clouds for external services (Firebase, Pinecone, S3, OpenAI)