Skip to content

Latest commit

 

History

History
118 lines (89 loc) · 3.24 KB

File metadata and controls

118 lines (89 loc) · 3.24 KB

NotebookChat

A RAG (Retrieval Augmented Generation) chatbot application that allows users to create notebooks, upload documents (PDF, text, websites), and chat with their documents using AI-powered semantic search.

Features

  • User Authentication - Sign up and login with JWT-based authentication
  • Notebook Management - Create and organize multiple notebooks
  • Document Upload - Support for PDF files, pasted text, and website URLs
  • AI Chat - Chat with your documents using semantic search and GPT-4o-mini
  • Streaming Responses - Real-time AI responses via server-sent events

Tech Stack

  • Frontend: Next.js 16, React 19, TailwindCSS 4, Zustand, TanStack Query, Shadcn
  • Backend: Hono (Bun runtime), Prisma, PostgreSQL
  • AI/Vector: OpenAI (GPT-4o-mini, text-embedding-3-small), Qdrant

Prerequisites

  • Node.js or Bun runtime
  • PostgreSQL database
  • Qdrant vector database (local or cloud)
  • OpenAI API key

Quick Start

1. Clone and install dependencies

# Frontend
cd notebookchat-frontend
bun install

# Backend
cd ../notebookchatbot
bun install

2. Set up environment variables

Create a .env file in notebookchatbot/:

DATABASE_URL="postgresql://user:password@localhost:5432/notebookchat"
QDRANT_URL="http://localhost:6333"
ACCESS_TOKEN_SECRET="your-access-token-secret"
REFRESH_TOKEN_SECRET="your-refresh-token-secret"
CORS="http://localhost:3000"
OPENAI_API_KEY="sk-..."

Create a .env.local file in notebookchat-frontend/:

NEXT_PUBLIC_API_URL="http://localhost:3000/api/v1"

3. Set up database

cd notebookchatbot
npx prisma generate
npx prisma db push

4. Run the application

# Backend (terminal 1)
cd notebookchatbot
bun run src/index.ts

# Frontend (terminal 2)
cd notebookchat-frontend
bun run dev

The frontend runs on http://localhost:3000 and the API runs on http://localhost:3000/api/v1.

Project Structure

notebookchat-frontend/     # Next.js frontend
  app/                     # App router pages
  components/              # React components
  hooks/                   # TanStack Query hooks
  stores/                  # Zustand stores
  api/                     # API client functions

notebookchatbot/           # Hono backend
  src/
    controllers/           # Route handlers
    routes/                # API route definitions
    middleware/            # Auth middleware
    utils/                 # Utilities (PDF, vector, etc.)
    lib/                   # Prisma, encryption
    schema/                # Zod validation schemas
  prisma/                  # Database schema

API Endpoints

Method Endpoint Description Auth
POST /api/v1/auth/signup Register new user No
POST /api/v1/auth/login User login No
POST /api/v1/auth/refresh Refresh access token No
GET /api/v1/notebooks List user notebooks Yes
POST /api/v1/notebooks Create notebook Yes
POST /api/v1/upload/:notebookId/pdf Upload PDF Yes
POST /api/v1/upload/:notebookId/text Upload text Yes
POST /api/v1/upload/:notebookId/website Upload website Yes
POST /api/v1/chat/:notebookId Chat with notebook Yes

License

MIT