See it here: https://docu-chat-tau.vercel.app
A Next.js application that allows users to upload documents and chat with an AI assistant about their content. The system provides an intuitive interface for document-based question answering using Vercel's AI SDK.
- Document Upload: Support for DOC, DOCX, TXT, and MD files
- AI Chat Interface: Clean, modern chat UI for asking questions about documents
- Real-time Processing: Immediate feedback during document upload and processing
- Streaming AI Responses: Real-time streaming responses using Vercel AI SDK
- Responsive Design: Works seamlessly on desktop and mobile devices
- Document Management: View uploaded documents and remove them as needed
This is a production-ready implementation that includes:
- Frontend UI components with document upload and chat interface
- Vercel AI SDK integration with OpenAI GPT models
- Streaming AI responses for better user experience
- File upload handling with API endpoints
- Responsive design using Tailwind CSS and shadcn/ui components
- Node.js 18+
- npm, yarn, or pnpm
- OpenAI API key (get one from OpenAI Platform)
- Clone the repository:
git clone <your-repo-url>
cd anon-chat- Install dependencies:
npm install
# or
yarn install
# or
pnpm install- Set up environment variables:
Create a
.env.localfile in the root directory:
# OpenAI API Key - Get one from https://platform.openai.com/api-keys
OPENAI_API_KEY=your_openai_api_key_here
# Optional: Set a different model
# OPENAI_MODEL=gpt-4o-mini- Run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev- Open http://localhost:3000 in your browser.
- Upload Documents: Click the upload button to select and upload your documents
- Wait for Processing: The system will process your documents through the API
- Start Chatting: Ask questions about your documents using natural language
- Get AI Responses: Receive streaming, context-aware answers based on your document content
- "What are the main points in these documents?"
- "Can you summarize the key findings?"
- "What does the document say about [specific topic]?"
- "Compare the different approaches mentioned in the documents"
- "Find information about [specific term or concept]"
- Frontend: Next.js 15, React 19, TypeScript
- AI Integration: Vercel AI SDK, OpenAI GPT models
- Styling: Tailwind CSS, shadcn/ui components
- Icons: Lucide React
- State Management: React hooks (useState, useEffect, useRef)
- Streaming: Real-time AI response streaming
├── app/
│ ├── api/
│ │ ├── chat/route.ts # AI chat responses with streaming
│ │ └── upload/route.ts # Document upload handling
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Main page
├── components/
│ ├── ai-chat.tsx # Main AI chat component
│ ├── chat-room.tsx # Original chat room (unused)
│ └── ui/ # shadcn/ui components
├── lib/ # Utility functions
├── styles/ # Additional styles
└── package.json # Dependencies and scripts
- Method: POST
- Purpose: Generate AI responses about uploaded documents
- Features: Streaming responses, document context awareness
- Body:
{ message: string, documents: Document[] }
- Method: POST
- Purpose: Handle document uploads and processing
- Features: Multiple file support, file validation
- Body: FormData with files
| Variable | Description | Required |
|---|---|---|
OPENAI_API_KEY |
Your OpenAI API key | Yes |
OPENAI_MODEL |
OpenAI model to use (default: gpt-3.5-turbo) | No |
To make this even more powerful, you could add:
- Text Extraction: Libraries like
pdf-parse,mammothfor actual document content - Vector Database: Pinecone, Weaviate, or Chroma for semantic search
- Embeddings: Store document vectors for better context retrieval
- Multi-modal Support: Handle images, charts, and diagrams
- Tool Calling: Allow AI to use external tools and APIs
- Memory: Persistent conversation history across sessions
- Authentication: User management and document access control
- Rate Limiting: API usage limits and cost management
- Monitoring: Logging, analytics, and performance tracking
-
"OpenAI API key not configured"
- Make sure you have a
.env.localfile with yourOPENAI_API_KEY - Restart your development server after adding environment variables
- Make sure you have a
-
"Failed to get AI response"
- Check your OpenAI API key is valid
- Ensure you have sufficient API credits
- Check the browser console for detailed error messages
-
Document upload fails
- Verify file types are supported (.pdf, .doc, .docx, .txt, .md)
- Check file size limits
- Ensure the upload API endpoint is accessible
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or issues, please open an issue on GitHub or contact the development team.
The system can extract text content from the following file formats:
| File Type | Extension | Processing | Notes |
|---|---|---|---|
| Word Document | .docx |
✅ Full text extraction | Uses mammoth library |
| Word Document (Legacy) | .doc |
✅ Full text extraction | Uses mammoth library |
| Text File | .txt |
✅ Direct text reading | UTF-8 encoding |
| Markdown | .md |
✅ Direct text reading | Preserves formatting |
| Other Formats | Various | ❌ Not supported | Will show helpful error message |
Note: Processing success depends on file format and content. Some files may fail to process due to corruption, password protection, or unsupported formats. The system now focuses on reliable, well-tested extraction methods.