A Next.js application that allows users to upload PDF documents, manage them, and engage in AI-powered conversations about their content.
- PDF file upload with drag-and-drop support
- Document management system
- Real-time chat interface with AI
- Document embedding and indexing
- SQLite database for file tracking
- Pinecone vector database integration
- Markdown rendering in chat
- Responsive design
- Frontend: Next.js, React, TailwindCSS
- Backend: Next.js API Routes
- Database: SQLite (file tracking), Pinecone (vector database)
- AI: OpenAI GPT-4, LangChain, Vercel AI SDK
- File Processing: PDF parsing and chunking
- Styling: TailwindCSS, Lucide Icons
- Node.js (v14 or later)
- pnpm or npm
- OpenAI API key
- Pinecone API key and index
Create a .env.local
file in the root directory with:
OPENAI_API_KEY=your_openai_api_key
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX=your_pinecone_index
- Clone the repository:
git clone https://github.com/hiteshbandhu/ninjachatai-assignment.git
- Install dependencies:
pnpm install
# or
npm install
- Run the development server:
pnpm run dev
# or
npm run dev
src/
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ ├── chat/ # Chat interface
│ └── page.tsx # Home page
├── components/ # React components
├── utils/ # Utility functions
│ ├── db/ # Database utilities
│ └── pinecone/ # Pinecone integration
- Supports PDF files
- Progress tracking
- Duplicate file detection
- File size limit enforcement
- List view of uploaded documents
- Last accessed timestamps
- Quick access to chat interface
- File organization
- Real-time AI responses
- Markdown rendering
- Tool integration
- Context-aware responses
POST /api/fileHandler/saveToServer
- Upload filesPOST /api/fileHandler/embedFilesAndIndex
- Process and index filesGET /api/dbEntries/fetch
- Get file listPOST /api/dbEntries/updateTimestamp
- Update file access timePOST /api/chat
- Handle chat interactions- Use the
text-embedding-3-small
model for embeddings in the pinecone index
CREATE TABLE "FILE_TRACKER" (
id INTEGER PRIMARY KEY AUTOINCREMENT,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
filename TEXT NOT NULL,
namespace TEXT NOT NULL
)