Whitepaper Finder by Facundo CappellaWhitepaper Finder by Facundo Cappella

Whitepaper Finder

Portfolio project
Facundo Cappella

Whitepaper Agent

A specialized AI agent designed to research and analyze whitepapers using Arxiv, built with Next.js 14, LangChain, and OpenAI.

๐Ÿ“– Documentation

Architecture Overview: Understand how the "Brain" (LangChain), "Library" (Arxiv), and "interface" works together.
Challenges & Limitations: Read about the technical challenges like language barriers (Spanish/English) and static knowledge bases.

Features

๐Ÿง  Intelligent Research Agent: Uses LangChain to reason about queries and decide when to fetch external data.
๐Ÿ“š Arxiv Integration: Automatically searches and retrieves recent scientific papers to answer technical queries.
๐Ÿ’ฌ Smart Context: Maintains conversation history in Local Storage for a seamless experience.
๐Ÿš€ Streaming Responses: Real-time feedback using Server-Sent Events (SSE).
๐ŸŒ Language Bridge: Seamlessly handles Spanish queries by finding relevant English papers and synthesizing answers back in Spanish.
๐ŸŽจ Modern UI: Polished interface with shadcn/ui and responsive design.

Project Structure

src/
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ api/chat/ # Streaming chat API endpoint
โ”‚ โ”œโ”€โ”€ layout.tsx # Root layout with metadata
โ”‚ โ””โ”€โ”€ page.tsx # Main chat page
โ”œโ”€โ”€ components/
โ”‚ โ”œโ”€โ”€ chat/ # Chat-specific components
โ”‚ โ”‚ โ”œโ”€โ”€ chat-container.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ chat-input.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ message-bubble.tsx
โ”‚ โ”‚ โ”œโ”€โ”€ message-list.tsx
โ”‚ โ”‚ โ””โ”€โ”€ typing-indicator.tsx
โ”‚ โ””โ”€โ”€ ui/ # shadcn/ui base components
โ”œโ”€โ”€ hooks/
โ”‚ โ””โ”€โ”€ use-chat.ts # Chat state management hook
โ””โ”€โ”€ lib/
โ”œโ”€โ”€ config/ # Environment configuration
โ”œโ”€โ”€ langchain/ # LangChain client and services
โ”‚ โ”œโ”€โ”€ client.ts # ChatOpenAI singleton
โ”‚ โ”œโ”€โ”€ chat-service.ts
โ”‚ โ””โ”€โ”€ types.ts
โ””โ”€โ”€ prompts/ # Decoupled prompt management
โ”œโ”€โ”€ system-prompts.ts
โ””โ”€โ”€ templates.ts

Getting Started

Prerequisites

Node.js 18+
npm or pnpm
OpenAI API key

Installation

Clone and install dependencies:
cd chatbot-app
npm install
Configure environment variables:
cp .env.example .env.local
Edit .env.local and add your OpenAI API key:
OPENAI_API_KEY=sk-your-api-key-here
Run the development server:
npm run dev
Open http://localhost:3000 in your browser.

Configuration

Environment Variables

Variable Description Default OPENAI_API_KEY Your OpenAI API key Required OPENAI_MODEL Model to use gpt-4o OPENAI_TEMPERATURE Response creativity (0-1) 0.2 OPENAI_MAX_TOKENS Maximum response length 2048

Customizing Prompts

Prompts are decoupled in src/lib/prompts/system-prompts.ts. To add a new prompt:
export const SYSTEM_PROMPTS = {
// ... existing prompts

custom: {
version: '1.0.0',
content: `Your custom system prompt here...`,
},
} as const;
Then use it in the ChatContainer:
<ChatContainer systemPromptKey="custom" />

Best Practices Applied

This project follows best practices from:
React Best Practices - Parallel fetching, Suspense boundaries, memoization
Agentic Patterns - Tools integration, reasoning loops, prompt engineering
UI/UX Guidelines - Accessible components, clean typography, responsive layout

Scripts

npm run dev      # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint

License

MIT

1 like ยท 14 views ยท Mar 29, 2026

AI agent for whitepaper research via Arxiv. Features LangChain reasoning, streaming chat, multilingual support. Built with Next.js 14 & TypeScript.

Tags