Skip to content

pitercoding/bookpulse-ai

Repository files navigation

BookPulse AI

Languages:
Portuguese | English

BookPulse AI is a full-stack Next.js application for building a private AI-powered reading library. Users can upload PDF books, organize them in a personal collection, and start voice conversations about each book through an AI assistant.

The system supports:

  • Authentication and user management with Clerk
  • PDF upload with optional custom cover image
  • Automatic text extraction and segmentation for searchable book context
  • Voice-based AI conversations powered by Vapi
  • Subscription-aware limits for books and voice sessions
  • Library search by title or author

Project Motivation

This project was built to turn uploaded books into a more interactive reading experience.

The goal is to combine a clean reading-library workflow with practical AI features:

  • keep each user's library private
  • let users upload their own PDF content
  • make book conversations contextual instead of generic
  • control usage through subscription plans

Current Features

App Platform (Next.js + MongoDB)

  • App Router project using server components, client components, server actions, and route handlers
  • MongoDB persistence for books, book segments, and voice session history
  • Clerk authentication and subscription integration
  • Vercel Blob storage for PDF and cover uploads

Library and Upload Flow

  • Personal library homepage with search by title or author
  • Protected upload page for authenticated users
  • PDF validation with 50MB size limit
  • Optional cover image upload
  • Automatic fallback cover generation from the PDF when available
  • Duplicate-title check per user
  • Automatic slug generation for book routes

AI Reading Experience

  • Voice conversation page for each uploaded book
  • Live microphone controls and call status feedback
  • Streaming transcript for user and assistant messages
  • Book-aware search tool for retrieving relevant text segments during the conversation
  • Configurable assistant voice chosen at upload time

Subscription Rules

  • Free: 1 book, 5 voice sessions/month, 5 minutes/session
  • Standard: 10 books, 100 voice sessions/month, 15 minutes/session
  • Pro: 100 books, unlimited voice sessions, 60 minutes/session
  • Upload and voice-session limits enforced on the server
  • Subscription pricing page integrated with Clerk Pricing Table

BookPulse Flow

  1. Sign in with Clerk
  2. Open Add New
  3. Upload a PDF and optionally a cover image
  4. Choose the assistant voice
  5. Let the app extract and segment the book text
  6. Browse the book in your private library
  7. Open a book and start a voice conversation about its content

Technologies

Core Stack

  • Next.js 16
  • React 19
  • TypeScript
  • Tailwind CSS 4

Platform and Services

  • Clerk
  • MongoDB + Mongoose
  • Vercel Blob
  • Vapi Web SDK
  • PDF.js

UI and Forms

  • shadcn/ui
  • Radix UI
  • React Hook Form
  • Zod
  • Sonner
  • Lucide React

How to Run Locally

  1. Clone the repository:
git clone https://github.com/pitercoding/bookpulse-ai.git
cd bookpulse-ai
  1. Install dependencies:
npm install
  1. Create a .env.local file with your own credentials:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
MONGODB_URI=your_mongodb_connection_string
BLOB_READ_WRITE_TOKEN=your_vercel_blob_token
NEXT_PUBLIC_ASSISTANT_ID=your_vapi_assistant_id
NEXT_PUBLIC_VAPI_API_KEY=your_vapi_public_key
  1. Run the development server:
npm run dev
  1. Open:
  • App: http://localhost:3000

Important Environment Notes

  • Do not commit real secrets to .env.local.
  • Clerk must be configured with the subscription plans used by the app.
  • Vapi must have a compatible assistant configured for book conversations.
  • MongoDB should be reachable by the local app.
  • Vercel Blob is required for PDF and image uploads.

Application Notes

  • Unauthenticated users can browse the landing/library shell, but uploading books and opening voice conversations require sign-in.
  • Books are private to the authenticated Clerk user.
  • Uploaded PDFs are parsed and split into segments so the assistant can search the book content during a conversation.
  • Session limits and book limits depend on the active subscription plan.

Testing Status

Current status:

  • core flows appear to be implemented for manual testing
  • no automated test suite is currently configured in package.json

Recommended next test scope:

  • server action tests for upload, duplicate checks, and subscription limits
  • route handler tests for upload authorization and Vapi tool calls
  • component tests for upload flow, transcript rendering, and subscription gating

Next Improvements

Product and UX

  • Add richer reading progress and per-book insights
  • Add session history and conversation recap UI
  • Add edit/delete flows for uploaded books

AI and Search

  • Improve semantic retrieval for book segments
  • Add summaries, highlights, and chapter-level navigation
  • Expand assistant tools beyond text lookup

Engineering and Quality

  • Add unit and integration tests
  • Add lint/build/test CI pipeline
  • Improve observability and error reporting for upload and voice flows

Deployment

  • Frontend/App runtime: Vercel
  • Database: MongoDB Atlas
  • Auth and billing: Clerk
  • File storage: Vercel Blob

Folder Structure

bookpulse-ai/
|- app/
|  |- (root)/page.tsx                   # Library home and search
|  |- books/
|  |  |- new/page.tsx                   # Upload new book
|  |  \- [slug]/page.tsx                # Voice conversation page
|  |- subscriptions/page.tsx            # Pricing and plan management
|  \- api/
|     |- upload/route.ts                # Blob upload authorization
|     \- vapi/search-book/route.ts      # Tool endpoint for book-aware AI search
|- components/                          # UI and feature components
|- database/
|  |- mongoose.ts                       # MongoDB connection
|  \- models/                           # Mongoose models
|- hooks/
|  \- useVapi.ts                        # Voice session lifecycle and transcript sync
|- lib/
|  |- actions/                          # Server actions
|  |- subscription-*.ts                 # Plan definitions and helpers
|  |- pdf.ts                            # PDF extraction helpers
|  \- search-book-segments.ts           # Book segment retrieval
|- public/
|  \- assets/                           # Static images and branding
|- README.md                            # Documentation (English)
\- README.pt.md                         # Documentation (Portuguese)

License

This project is licensed under the MIT License.

Author

Piter Gomes — Computer Science Student (6th Semester) & Full-Stack Developer

Email | LinkedIn | GitHub | Portfolio