DocMind is a Retrieval-Augmented Generation (RAG) application that allows you to upload documents and ask questions about their content. Built with Next.js, FastAPI, and Claude.
- Document Upload: Support for PDF, TXT, and DOCX files
- Intelligent Q&A: Ask questions about your documents using natural language
- Source Citations: Every answer includes citations from your documents
- Conversation History: Maintains context across multiple questions
- Clean UI: Modern, responsive interface built with React and Tailwind CSS
- Framework: Next.js 16 with React 19
- Styling: Tailwind CSS with custom sage green theme
- State Management: React hooks with SWR for data fetching
- API Communication: Axios for HTTP requests
- Framework: FastAPI with Python 3.11
- LLM: Claude 3.5 Sonnet via Anthropic API
- Vector Store: Simple in-memory implementation (scalable to Pinecone, Weaviate, etc.)
- Document Processing: PDF/DOCX extraction with text chunking
- Node.js 18+ (for frontend)
- Python 3.11+ (for backend)
- Docker & Docker Compose (optional, for containerized deployment)
- Anthropic API Key (get one at https://console.anthropic.com)
# Install frontend dependencies
pnpm install
# Create Python virtual environment
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cd ..# Copy and update frontend environment
cp .env.local.example .env.local
# Update NEXT_PUBLIC_BACKEND_URL if needed (default: http://localhost:8000)
# Copy and update backend environment
cp backend/.env.example backend/.env
# Add your ANTHROPIC_API_KEYTerminal 1 - Backend:
cd backend
source venv/bin/activate # On Windows: venv\Scripts\activate
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reloadBackend will be available at http://localhost:8000
API docs available at http://localhost:8000/docs
Terminal 2 - Frontend:
pnpm devFrontend will be available at http://localhost:3000
Option 1: Render Backend + Vercel Frontend (Recommended - Free to Start)
- Deploy backend on Render: See RENDER_DEPLOYMENT.md
- Deploy frontend on Vercel: See VERCEL_DEPLOYMENT.md
Option 2: Docker Compose
docker-compose up --build
# Access at http://localhost:3000For detailed deployment instructions, see DEPLOY_NOW.md and DEPLOYMENT.md
# Build images
docker-compose build
# Run services
docker-compose upThe application will be available at:
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:8000 - API Docs:
http://localhost:8000/docs
Set ANTHROPIC_API_KEY before running:
export ANTHROPIC_API_KEY="your-api-key-here"
docker-compose upOr add to a .env file:
ANTHROPIC_API_KEY=your-api-key-here
-
POST /upload - Upload a document
- Request: multipart/form-data with
filefield - Response:
{ filename, size, upload_time, document_id }
- Request: multipart/form-data with
-
POST /chat - Send a query
- Request:
{ query: string, session_id?: string } - Response:
{ response: string, sources: [...], session_id: string }
- Request:
-
GET /documents - List all documents
- Response:
{ documents: [...] }
- Response:
-
DELETE /documents/{document_id} - Delete a document
-
GET /health - Health check
.
├── app/ # Next.js app directory
│ ├── docmind/ # DocMind pages
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Home page
│ └── globals.css # Global styles
├── components/
│ └── docmind/ # DocMind components
│ ├── chat-interface.tsx
│ ├── document-list.tsx
│ ├── document-uploader.tsx
│ └── message.tsx
├── hooks/ # Custom React hooks
│ ├── use-chat.ts
│ └── use-documents.ts
├── backend/ # FastAPI backend
│ ├── app/
│ │ ├── document_processor.py
│ │ ├── rag_engine.py
│ │ └── vector_store.py
│ ├── main.py # FastAPI app
│ ├── requirements.txt
│ ├── Dockerfile
│ └── uploads/ # Uploaded documents
├── docker-compose.yml # Docker Compose config
├── Dockerfile # Frontend Docker config
└── README.md # This file
- Documents are uploaded and processed (text extraction)
- Text is split into chunks for efficient retrieval
- Chunks are stored in a vector store with simple keyword matching
- For production, integrate with Pinecone, Weaviate, or similar
- On each query:
- Retrieved relevant document chunks
- Build context from top-k matches
- Send to Claude with conversation history
- Return response with source citations
- PDF: Extracted using pypdf library
- TXT: Read directly
- DOCX: Basic extraction via zipfile (for production, use python-docx)
- All text saved separately for quick retrieval
- Current: Simple in-memory BM25-like scoring
- Production options:
- Pinecone (semantic search)
- Weaviate (open-source)
- Supabase pgvector (PostgreSQL)
- Chroma (embedded)
- Database: Add PostgreSQL for document storage and metadata
- Vector Embeddings: Use OpenAI/Claude embeddings + Pinecone
- Authentication: Add user accounts with Auth.js or Supabase Auth
- Storage: Move uploads to Vercel Blob or S3
- Caching: Add Redis for session management
- Monitoring: Integrate with Sentry for error tracking
- Rate Limiting: Add rate limiting for API endpoints
- Search Ranking: Implement semantic search with embeddings
- Ensure backend is running on
http://localhost:8000 - Check
NEXT_PUBLIC_BACKEND_URLin.env.local - Frontend network tab should show successful requests to
/api/*
- Backend has CORS middleware configured for
*origins - For production, update
allow_originsinmain.py
- Check file size (adjust if needed)
- Verify file format (PDF, TXT, DOCX only)
- Ensure
/backend/uploadsdirectory exists and is writable
- Vector store is in-memory; for large document sets, use external vector DB
- Consider implementing document pagination/filtering
- Get your Anthropic API key at: https://console.anthropic.com
- Never commit
.envfiles with real keys - Use environment variables in production
- Rotate keys regularly
To improve DocMind:
- Implement semantic search with embeddings
- Add authentication
- Improve document processing (images, tables)
- Add real-time streaming responses
- Implement user profiles and document sharing
This project is open source and available for educational and commercial use.
For issues or questions:
- Check API docs at
http://localhost:8000/docs - Review logs in terminal windows
- Verify environment variables are set correctly