rag-chat-app

Production-grade RAG Chat Application built with Next.js 15, Vercel AI SDK, and TailwindCSS

https://github.com/ryanlisse/rag-chat-app

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.7%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Production-grade RAG Chat Application built with Next.js 15, Vercel AI SDK, and TailwindCSS

Basic Info
  • Host: GitHub
  • Owner: RyanLisse
  • License: other
  • Language: TypeScript
  • Default Branch: main
  • Size: 4.53 MB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created 9 months ago · Last pushed 8 months ago
Metadata Files
Readme License Citation Codeowners

README.md

Production-ready RAG Chat Application with citations.

RAG Chat Application with OpenAI Vector Store

A production-ready RAG (Retrieval Augmented Generation) chat application built with Next.js, AI SDK, OpenAI Vector Store, and comprehensive citation support for document-based conversations.

Features · Vector Store · Examples · Model Providers · Running locally


Features

  • RAG with OpenAI Vector Store

    • Upload and process documents (PDF, TXT, DOCX, etc.)
    • Automatic document chunking and embedding generation
    • Semantic search across your knowledge base
    • Source citations with every response
  • Multi-Model Support

    • GPT-4.1 (default)
    • GPT-4 and GPT-4 Turbo
    • Claude 4 (Anthropic)
    • Gemini 2.5 Pro/Flash (Google)
    • o4-mini with reasoning capabilities
  • Advanced Chat Interface

    • Real-time streaming responses
    • Code syntax highlighting
    • Markdown support
    • File attachments
    • Chat history with search
  • Production-Ready Infrastructure

    • Next.js 15 with App Router and Turbopack
    • Turso DB for edge-compatible SQLite database
    • Auth.js for secure authentication
    • Vercel Blob for file storage
    • OpenTelemetry monitoring and observability
  • Developer Experience

    • TypeScript throughout
    • Comprehensive test suite (unit, integration, E2E)
    • CI/CD with GitHub Actions
    • Docker support for containerized deployment

Vector Store

The application integrates with OpenAI's Vector Store for advanced document retrieval:

How It Works

  1. Document Upload: Upload documents through the chat interface
  2. Processing: Documents are automatically:
    • Chunked into optimal segments
    • Converted to embeddings using OpenAI's embedding models
    • Stored in the vector database
  3. Retrieval: When you ask questions, the system:
    • Searches for relevant document chunks
    • Provides context to the AI model
    • Returns answers with source citations

Supported File Types

  • PDF documents
  • Text files (.txt, .md)
  • Word documents (.docx)
  • Code files (.py, .js, .ts, etc.)
  • CSV and JSON data files

Configuration

Set your OpenAI Vector Store ID in the environment variables: env OPENAI_VECTORSTORE_ID=vs_your_vector_store_id

Examples

Example 1: Technical Documentation Assistant

``` User: How do I calibrate the RoboRail system?

Citation (CITATION_ARTIFACT_ENHANCEMENTS.md)

# Citation Artifact Enhancements

## Overview
This update ensures that citation artifacts are ALWAYS displayed in a beautiful, prominent way whenever there are search results from the vector store. The artifacts now appear immediately and provide a consistent, visually appealing interface for all search states.

## Key Changes

### 1. Always Create Citation Artifacts
**File**: `lib/ai/tools/file-search.ts`
- Modified to create citation artifacts in ALL cases:
  - ✅ Successful searches with results
  - 📭 Searches with no results  
  - ⚠️ Configuration errors (no vector store)
  - ❌ Search failures

### 2. Immediate Artifact Display
**File**: `artifacts/citation/client.tsx`
- Removed the 50-character threshold
- Artifacts now appear immediately with `isVisible: true`

### 3. Beautiful Visual Design
**File**: `components/artifacts/citation-artifact.tsx`
- Added gradient backgrounds (blue to purple)
- Enhanced citation badges with hover effects and scaling
- Improved sidebar with better shadows and transitions
- Added header with gradient and white text

### 4. Enhanced Statistics Panel
**File**: `components/artifacts/citation-statistics-panel.tsx`  
- Colorful gradient cards for each metric
- Icon containers with colored backgrounds
- Better visual hierarchy and spacing

## Visual Improvements

### Citation Badges
- Larger size (6x6 instead of 5x5)
- Enhanced hover effects with 125% scale
- Gradient backgrounds when highlighted
- Better shadows and transitions

### Main Content Area
- Gradient background from blue to purple
- Content in semi-transparent white cards
- Better contrast and readability

### Statistics Cards
- Each metric has its own color theme:
  - Total Citations: Blue gradient
  - Unique Sources: Green gradient  
  - Relevance Quality: Purple to pink gradient
  - Source Types: Indigo gradient
  - Citation Density: Cyan gradient
  - Quality Insights: Amber gradient

## User Experience

1. **Transparency**: Every search operation creates a visible artifact
2. **Consistency**: Same beautiful UI for all states (success, error, no results)
3. **Feedback**: Clear visual indicators and helpful messages
4. **Accessibility**: Maintained all ARIA labels and keyboard navigation

## Testing

Created a test script that verified:
- Citation artifacts are created for all search states
- Proper event streaming for artifact creation
- Error states still produce artifacts

## Benefits

1. **Always Visible**: Users always see when a document search was performed
2. **Beautiful UI**: Professional gradient design that stands out
3. **Informative**: Clear statistics and source information
4. **Consistent**: Same experience regardless of search outcome
5. **Helpful**: Error states include next steps and suggestions

GitHub Events

Total
  • Issue comment event: 3
  • Push event: 5
  • Pull request review event: 1
  • Pull request review comment event: 4
  • Pull request event: 2
  • Create event: 3
Last Year
  • Issue comment event: 3
  • Push event: 5
  • Pull request review event: 1
  • Pull request review comment event: 4
  • Pull request event: 2
  • Create event: 3

Dependencies

.github/workflows/cd.yml actions
  • 8398a7/action-slack v3 composite
  • actions/checkout v4 composite
  • amondnet/vercel-action v25 composite
  • docker/build-push-action v5 composite
  • docker/login-action v3 composite
  • docker/metadata-action v5 composite
  • docker/setup-buildx-action v3 composite
  • oven-sh/setup-bun v2 composite
.github/workflows/ci.yml actions
  • actions/cache v4 composite
  • actions/checkout v4 composite
  • actions/setup-node v4 composite
  • actions/upload-artifact v4 composite
  • oven-sh/setup-bun v2 composite
.github/workflows/codeowners-validation.yml actions
  • actions/checkout v4 composite
  • mszostok/codeowners-validator v0.7.4 composite
.github/workflows/dependency-update.yml actions
  • 8398a7/action-slack v3 composite
  • actions/checkout v4 composite
  • oven-sh/setup-bun v2 composite
  • peter-evans/create-pull-request v6 composite
.github/workflows/pr-labeler.yml actions
  • actions/github-script v7 composite
  • actions/labeler v5 composite
  • codelytv/pr-size-labeler v1 composite
.github/workflows/release.yml actions
  • 8398a7/action-slack v3 composite
  • actions/checkout v4 composite
  • actions/create-release v1 composite
  • actions/setup-node v4 composite
  • docker/build-push-action v5 composite
  • docker/login-action v3 composite
  • docker/setup-buildx-action v3 composite
  • oven-sh/setup-bun v2 composite
.github/workflows/security.yml actions
  • actions/checkout v4 composite
  • actions/github-script v7 composite
  • actions/upload-artifact v4 composite
  • aquasecurity/trivy-action master composite
  • github/codeql-action/analyze v3 composite
  • github/codeql-action/autobuild v3 composite
  • github/codeql-action/init v3 composite
  • github/codeql-action/upload-sarif v3 composite
  • gitleaks/gitleaks-action v2 composite
  • oven-sh/setup-bun v2 composite
  • returntocorp/semgrep-action v1 composite
  • snyk/actions/node master composite
  • trufflesecurity/trufflehog main composite
.github/workflows/stale.yml actions
  • actions/stale v9 composite
Dockerfile docker
  • oven/bun 1-alpine build
docker-compose.override.yml docker
docker-compose.prod.yml docker
  • nginx alpine
  • postgres 16-alpine
  • redis 7-alpine
docker-compose.yml docker
  • otel/opentelemetry-collector-contrib latest
  • postgres 16-alpine
  • redis 7-alpine
package-lock.json npm
  • 942 dependencies
package.json npm
  • @axe-core/playwright 4.10.2 development
  • @biomejs/biome 1.9.4 development
  • @browserbasehq/stagehand 2.4.0 development
  • @faker-js/faker ^8.4.1 development
  • @playwright/test ^1.50.1 development
  • @tailwindcss/typography ^0.5.15 development
  • @testing-library/jest-dom ^6.4.8 development
  • @testing-library/react ^14.3.1 development
  • @testing-library/user-event ^14.5.2 development
  • @types/d3-scale ^4.0.8 development
  • @types/node ^22.8.6 development
  • @types/papaparse ^5.3.15 development
  • @types/pdf-parse ^1.1.4 development
  • @types/react ^18 development
  • @types/react-dom ^18 development
  • @vitest/coverage-v8 3.2.4 development
  • @vitest/ui 3.2.4 development
  • drizzle-kit 0.31.4 development
  • happy-dom ^12.10.3 development
  • pixelmatch 7.1.0 development
  • pngjs 7.0.0 development
  • postcss ^8 development
  • tailwindcss ^3.4.1 development
  • tsx ^4.19.1 development
  • typescript ^5.6.3 development
  • vitest 3.2.4 development
  • @ai-sdk/anthropic 2.0.0-beta.3
  • @ai-sdk/google 2.0.0-beta.5
  • @ai-sdk/openai 2.0.0-beta.3
  • @ai-sdk/react 2.0.0-beta.3
  • @ai-sdk/xai 2.0.0-beta.2
  • @codemirror/lang-javascript ^6.2.2
  • @codemirror/lang-python ^6.1.6
  • @codemirror/state ^6.5.0
  • @codemirror/theme-one-dark ^6.1.2
  • @codemirror/view ^6.35.3
  • @libsql/client 0.15.9
  • @radix-ui/react-alert-dialog ^1.1.2
  • @radix-ui/react-dialog ^1.1.14
  • @radix-ui/react-dropdown-menu ^2.1.2
  • @radix-ui/react-icons ^1.3.0
  • @radix-ui/react-label ^2.1.0
  • @radix-ui/react-popover ^1.1.14
  • @radix-ui/react-progress ^1.1.7
  • @radix-ui/react-scroll-area 1.2.9
  • @radix-ui/react-select ^2.1.2
  • @radix-ui/react-separator ^1.1.0
  • @radix-ui/react-slot 1.2.3
  • @radix-ui/react-tooltip ^1.1.3
  • @radix-ui/react-visually-hidden ^1.1.0
  • @vercel/analytics ^1.3.1
  • @vercel/blob ^0.24.1
  • @vercel/functions ^2.0.0
  • @vercel/otel 1.13.0
  • @vercel/postgres ^0.10.0
  • ai 5.0.0-beta.3
  • bcrypt-ts ^5.0.2
  • class-variance-authority ^0.7.0
  • classnames ^2.5.1
  • clsx ^2.1.1
  • cmdk 1.1.1
  • codemirror ^6.0.1
  • date-fns ^4.1.0
  • diff-match-patch ^1.0.5
  • dotenv ^16.4.5
  • drizzle-orm 0.44.2
  • fast-deep-equal ^3.1.3
  • framer-motion ^11.3.19
  • geist ^1.3.1
  • lucide-react ^0.446.0
  • nanoid ^5.0.8
  • next 15.3.0-canary.31
  • next-auth 5.0.0-beta.25
  • next-themes ^0.3.0
  • openai ^5.8.2
  • orderedmap ^2.1.1
  • papaparse ^5.5.2
  • postgres ^3.4.4
  • prosemirror-example-setup ^1.2.3
  • prosemirror-inputrules ^1.4.0
  • prosemirror-markdown ^1.13.1
  • prosemirror-model ^1.23.0
  • prosemirror-schema-basic ^1.2.3
  • prosemirror-schema-list ^1.4.1
  • prosemirror-state ^1.4.3
  • prosemirror-view ^1.34.3
  • react 19.0.0-rc-45804af1-20241021
  • react-data-grid 7.0.0-beta.47
  • react-dom 19.0.0-rc-45804af1-20241021
  • react-dropzone-esm 15.2.0
  • react-markdown ^9.0.1
  • react-resizable-panels ^2.1.7
  • redis ^5.5.6
  • remark-gfm ^4.0.0
  • resumable-stream ^2.0.0
  • server-only ^0.0.1
  • sonner ^1.5.0
  • swr ^2.2.5
  • tailwind-merge ^2.5.2
  • tailwindcss-animate ^1.0.7
  • usehooks-ts ^3.1.0
  • winston ^3.11.0
  • zod ^3.23.8