Skip to main content
Full-Stack AI Application · RAG Architecture
Source-Verified Implementation

AI Learning & Research Platform (ChaiBook)

Multi-modal research workspace featuring retrieval-augmented generation (RAG), Pinecone vector similarity search, document chunking, and contextual citations.

Role: Full-Stack Developer
AI Learning & Research Platform (ChaiBook) Interface Preview

Project Overview

ChaiBook (developed in the NoteBook-ML repository) is an AI-powered research platform designed to ingest complex multi-modal study materials and provide citation-grounded answers.

Built with Next.js 16, React 19, Express 5, Prisma ORM, and PostgreSQL, the platform integrates Pinecone serverless vector databases and OpenRouter AI SDK models to power semantic retrieval-augmented generation (RAG).

Researchers can upload PDF documents, scrape web articles with Firecrawl, search live research papers via Tavily, and extract YouTube transcripts to build structured, searchable knowledge workspaces with interactive node graphs.

The Problem & Motivation

  • Students and researchers struggle to synthesize information across disparate formats: PDF textbooks, online documentation, web articles, and video lectures.
  • Standard LLMs frequently hallucinate facts or fail to cite specific source passages, making them unreliable for serious academic study or technical research.
  • The technical goal was to build an asynchronous ingestion pipeline that chunks multi-modal sources, computes vector embeddings, and answers queries with verifiable page-level and source-level citations.

Architectural Solution

  • Architected an Express 5 and Prisma backend paired with a modern Next.js 16 client utilizing @xyflow/react for interactive knowledge canvasing.
  • Integrated Pinecone serverless vector indexing with OpenRouter-powered embedding and completion models using the Vercel AI SDK.
  • Engineered a multi-source ingestion pipeline: unpdf for PDF text and page extraction, Firecrawl for clean web scraping, Tavily for real-time web research, and youtube-transcript for video lectures.
  • Incorporated Inngest background job orchestration to decouple heavy document parsing and vector upserting from the main HTTP API loop.
  • Integrated Mem0 for user-specific research memory and Better Auth for session management.

Technology Stack & Evidence

Technologies categorized by source verification and documented implementation scope:

Frontend & Interactive Workspace

Next.js 16
React 19
@xyflow/react (Knowledge Canvas)
TanStack Query
Better Auth Client
Tailwind CSS 4

AI & Semantic Search (RAG)

Vercel AI SDK (ai)
OpenRouter API Provider
Pinecone Vector DB
Mem0 AI (Research Memory)

Document Ingestion & Web Scraping

unpdf (PDF Extraction)
Firecrawl (Web Scraper)
Tavily Core (Web Search)
YouTube Transcript API

Backend & Background Processing

Express 5
TypeScript
Inngest (Background Workers)
Prisma ORM
PostgreSQL

Architecture & System Flow

1

Client Application (client)

Next.js 16
React 19
@xyflow/react
TanStack Query

Split-screen research studio featuring document viewers, node-based mind maps, and interactive chat interface.

2

API & Ingestion Service (server)

Express 5
Prisma ORM
unpdf
Firecrawl
Tavily

Receives document uploads and URLs, extracts clean structured text, and schedules background processing jobs.

3

Background Vector Pipeline

Inngest
Pinecone Vector DB
Embedding Models

Asynchronous workers executing text chunking, embedding generation, and vector index upserts with source metadata.

4

RAG Synthesis & Persistence

OpenRouter AI SDK
Mem0
PostgreSQL
Prisma

Performs cosine similarity searches, injects source context into system prompts, and persists notes and conversations in PostgreSQL.

Core Implemented Features

Multi-Source Document Ingestion

Unified ingestion for PDF textbooks, web links, YouTube videos, and raw notes with automated text sanitization and metadata preservation.

Citation-Grounded RAG Assistant

Retrieval-augmented QA that retrieves relevant chunks from Pinecone and grounds every response in specific document passages with page numbers.

Interactive Knowledge Canvas (@xyflow/react)

Visual node-based diagramming canvas for connecting concepts, sources, and synthesis notes in a freeform spatial layout.

Asynchronous Processing via Inngest

Background workers handle heavy document parsing, chunking, and vector embedding asynchronously, keeping the user interface snappy.

Technical Challenges & Trade-Offs

01.Preserving Page-Level Metadata During PDF Chunking

Challenge

Naive text extractors merge an entire PDF into a monolithic string, stripping out page boundaries and making precise academic citations impossible.

Engineering Approach

Structured ingestion to preserve individual page boundaries via unpdf before applying sliding-window text chunking, tagging generated vectors with page numbers when parsing succeeds (falling back to document-level chunks when inline text extraction does not retain page splits).

Result

Responses cite exact page numbers from original PDF textbooks whenever page boundaries are preserved, allowing researchers to quickly verify claims.

02.Offloading Multi-Modal Ingestion to Prevent HTTP Timeouts

Challenge

Parsing 50+ page PDFs, crawling complex web pages, and generating vector embeddings synchronously blocks Express HTTP threads and triggers gateway timeouts.

Engineering Approach

Decoupled upload from processing using Inngest event triggers: the API immediately returns HTTP 202 with sourceStatus = 'PROCESSING', while Inngest workers execute chunking and vector indexing in the background.

Result

Fast, non-blocking uploads with real-time UI progress updates as sources complete vectorization.

03.Mitigating Hallucinations via Context-Grounded Prompts

Challenge

Standard LLMs answer from pre-trained parametric memory rather than user-provided research sources when questions overlap with general knowledge.

Engineering Approach

Designed prompt constraints and retrieval context injection that direct the model to cite retrieved vector chunks or state when source materials do not contain sufficient evidence.

Result

Grounded answers anchored to retrieved vector passages, with transparent citation chips indicating source locations.

Key Engineering Takeaways

Developed deep proficiency in building production-grade RAG pipelines combining vector databases with traditional relational data.
Learned how to handle diverse multi-modal source formats (PDFs, web DOMs, video transcripts) in a normalized data architecture.
Implemented spatial interactive user interfaces with React 19 and @xyflow/react for complex knowledge organization.