A modern document chat application that allows users to upload documents and have intelligent conversations with them using AI. Built with FastAPI backend and Next.js frontend.
- Frontend (Vercel): https://docu-chat-mu.vercel.app/
- Backend (Render): https://docuchat-xurq.onrender.com/
- API Documentation: https://docuchat-xurq.onrender.com/docs
- Document Upload: Support for PDF files with intelligent text extraction
- AI-Powered Chat: Chat with your documents using Google Gemini AI
- Session Management: Persistent chat sessions with configurable TTL
- Modern UI: Beautiful, responsive interface built with Next.js and Tailwind CSS
- Audio Support: Speech-to-text capabilities with Sarvam AI integration
- Real-time Processing: Fast document processing and embedding generation
DocuChat/
βββ backend/ # FastAPI Python backend
β βββ app/ # Main application code
β β βββ routers/ # API endpoints
β β βββ services/ # Business logic
β β βββ schemas/ # Pydantic models
β βββ requirements.txt
βββ frontend/ # Next.js React frontend
βββ app/ # Next.js app directory
βββ components/ # React components
βββ package.json
- FastAPI - Modern Python web framework
- Google Gemini AI - Large language model for chat
- LangChain - AI application framework
- PyPDF2 - PDF text extraction
- Uvicorn - ASGI server
- Next.js 14 - React framework
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS
- Radix UI - Accessible component primitives
- React Hook Form - Form handling
- Python 3.11+ (for backend)
- Node.js 18+ (for frontend)
- Google Gemini API Key (for AI chat)
- Sarvam API Key (optional, for audio features)
-
Navigate to backend directory
cd backend -
Create virtual environment
python -m venv venv
-
Activate virtual environment
Windows:
venv\Scripts\activate
macOS/Linux:
source venv/bin/activate -
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
Create a
.envfile in the backend directory:SESSION_TTL_SECONDS=3600 MAX_FILE_MB=100 EMBED_DIM=1024 SARVAM_API_KEY=your_sarvam_api_key_here GEMINI_API_KEY=your_gemini_api_key_here
-
Start the backend server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
The API will be available at
http://localhost:8000
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Start the development server
npm run dev
The frontend will be available at
http://localhost:3000
POST /upload- Upload and process documentsPOST /chat- Send chat messagesGET /sessions- List chat sessionsPOST /sessions- Create new sessionGET /sessions/{session_id}- Get session detailsPOST /summarize- Generate document summaries
GET /health- API health status
The project includes Docker configuration for easy deployment:
# Build and run with Docker Compose
docker-compose up --build| Variable | Description | Default |
|---|---|---|
SESSION_TTL_SECONDS |
Session timeout in seconds | 3600 |
MAX_FILE_MB |
Maximum file upload size | 100 |
EMBED_DIM |
Embedding dimensions | 1024 |
SARVAM_API_KEY |
Sarvam AI API key | Required for audio |
GEMINI_API_KEY |
Google Gemini API key | Required |
- The backend uses FastAPI with automatic API documentation
- Visit
http://localhost:8000/docsfor interactive API docs - Code is organized with routers, services, and schemas
- Built with Next.js App Router
- Uses TypeScript for type safety
- Tailwind CSS for styling
- Radix UI components for accessibility
Once the backend is running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
-
Virtual environment not activating
- Ensure Python 3.11+ is installed
- Check the activation script path
-
API key errors
- Verify your Google Gemini API key is valid
- Check environment variable names
-
Port conflicts
- Backend runs on port 8000
- Frontend runs on port 3000
- Change ports if needed
-
File upload issues
- Check file size limits
- Ensure PDF files are not corrupted
Ahoy! Welcome aboard the DocuChat ship! π΄ββ οΈ
For more help, check the API documentation or open an issue on GitHub.