Your DocChat application is now fully functional with:
- Frontend (React) - Modern UI with drag-and-drop upload and chat
- Backend (FastAPI) - REST API connected to your RAG pipeline
- RAG Pipeline - PDF ingestion and Q&A using Gemini + Pinecone
Frontend: https://doc-chat-one.vercel.app
The application is fully deployed!
- Frontend: Hosted on Vercel
- Backend: Hosted on Google Cloud VM
- Database: Pinecone & Google Cloud Storage
- Open your browser to https://doc-chat-one.vercel.app
- Upload a PDF:
- Drag and drop or click "Browse Files"
- Wait for "File uploaded and processed successfully!"
- Ask questions:
- Type your question in the chat
- The AI will answer based on your uploaded documents
POST /upload- Receives PDFs, saves them, callssrc/ingestion.pyto process into PineconePOST /chat- Receives questions, callssrc/graph.py(LangGraph agent) to generate answers
FileUpload.jsx- Handles PDF uploads, sends to/uploadendpointChatInterface.jsx- Handles chat messages, sends to/chatendpointApp.jsx- Main layout with gradient background
config.py- API keys and settingsingestion.py- PDF → chunks → embeddings → Pineconeretrieval.py- Search Pinecone for relevant chunksgraph.py- LangGraph agent that retrieves + generates answers
Backend won't start?
- Make sure you're in the
DocChatdirectory (notfastApi) - Activate conda:
conda activate datacenter
Frontend won't start?
- Make sure you're in the
frontenddirectory - Run
npm installif needed
Upload fails?
- Check that backend is running on port 8000
- Check browser console for errors
Chat doesn't work?
- Make sure you've uploaded a document first
- Check that your
.envfile hasGOOGLE_API_KEYandPINECONE_API_KEY
DocChat/
├── fastApi/
│ └── api.py # FastAPI backend
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── FileUpload.jsx
│ │ │ └── ChatInterface.jsx
│ │ ├── App.jsx
│ │ └── index.css
│ └── package.json
├── src/
│ ├── config.py
│ ├── ingestion.py
│ ├── retrieval.py
│ └── graph.py
├── .env # API keys (create this!)
└── requirements.txt
The frontend is configured for easy deployment to Vercel:
-
Push to GitHub:
cd /home/yaga23/Documents/DocChat/DocChat git add . git commit -m "Configure for Vercel deployment" git push
-
Import to Vercel:
- Go to vercel.com and sign in
- Click "Add New Project"
- Import your GitHub repository
- Set the Root Directory to
frontend - Vercel will auto-detect the Vite configuration
-
Configure Environment Variable:
- In the Vercel project settings, go to "Environment Variables"
- Add:
VITE_API_URL=your-backend-url(e.g.,https://your-api.com) - Click "Deploy"
cd /home/yaga23/Documents/DocChat/DocChat/frontend
npm install -g vercel
vercel login
vercel --prodWhen prompted, set the environment variable:
VITE_API_URL: Your backend API URL
- Backend CORS: Your FastAPI backend must allow requests from your Vercel domain
- Environment Variables: The frontend uses
VITE_API_URLto connect to your backend - Local Development: Without
.envfile, it defaults tohttp://localhost:8000
Deploy your FastAPI backend to a Google Cloud E2 VM instance.
-
Go to Google Cloud Console:
- Navigate to console.cloud.google.com
- Select your project:
do-c-479403
-
Create VM Instance:
- Go to Compute Engine → VM instances
- Click "Create Instance"
- Configure:
- Name:
docchat-backend - Region: Choose closest to your users (e.g.,
us-central1) - Machine type:
e2-medium(2 vCPU, 4 GB memory) - Boot disk: Ubuntu 22.04 LTS, 20 GB
- Firewall: Check "Allow HTTP traffic" and "Allow HTTPS traffic"
- Name:
- Click "Create"
-
Configure Firewall Rule for Port 8000:
- Go to VPC Network → Firewall
- Click "Create Firewall Rule"
- Name:
allow-fastapi - Targets: All instances in the network
- Source IP ranges:
0.0.0.0/0 - Protocols and ports:
tcp:8000 - Click "Create"
-
SSH into your VM:
gcloud compute ssh docchat-backend --zone=us-central1-a
-
Clone your repository:
cd ~ git clone https://github.com/Yash-Yashwant/DocChat.git cd DocChat
-
Run the startup script:
chmod +x startup.sh ./startup.sh
-
Set up environment variables:
cp .env.example .env nano .env
Add your actual API keys:
GOOGLE_API_KEY=your_actual_google_api_key PINECONE_API_KEY=your_actual_pinecone_api_key GOOGLE_APPLICATION_CREDENTIALS=/home/your-username/.config/gcloud/application_default_credentials.json -
Authenticate with Google Cloud (for GCS access):
gcloud auth application-default login
-
Copy service file:
sudo cp docchat.service /etc/systemd/system/
-
Update service file with your username:
sudo nano /etc/systemd/system/docchat.service
Replace
yaga23with your actual username (runwhoamito check) -
Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable docchat sudo systemctl start docchat -
Check service status:
sudo systemctl status docchat
-
Find your VM's external IP:
gcloud compute instances list
Or check in the GCP Console under VM instances
-
Your backend URL:
http://YOUR_VM_EXTERNAL_IP:8000 -
Test it:
curl http://YOUR_VM_EXTERNAL_IP:8000/
Should return:
{"message":"DocChat API is running"}
Since Vercel uses HTTPS, your backend must also use HTTPS to avoid "Mixed Content" errors. The easiest way is using Cloudflare Tunnel.
-
Install Cloudflared on your VM:
wget -q https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb && sudo dpkg -i cloudflared-linux-amd64.deb -
Start the Tunnel:
cloudflared tunnel --url http://localhost:8000
-
Get your HTTPS URL:
- Copy the URL from the output (e.g.,
https://random-name.trycloudflare.com) - Keep this terminal window open!
- Copy the URL from the output (e.g.,
- Go to your Vercel project settings
- Navigate to Environment Variables
- Update
VITE_API_URLto your Cloudflare URL:https://your-tunnel-url.trycloudflare.com - Redeploy your frontend
# Start service
sudo systemctl start docchat
# Stop service
sudo systemctl stop docchat
# Restart service
sudo systemctl restart docchat
# View logs
sudo journalctl -u docchat -f
# Check status
sudo systemctl status docchat- Permanent Tunnel - Configure Cloudflare Tunnel to run as a service
- User Authentication - Add login/signup
- Citations - Show which page/section the answer came from
Make sure your .env file contains:
GOOGLE_API_KEY=your_key_here
PINECONE_API_KEY=your_key_here
You're all set!