Skip to content

DocuChat is an intelligent document assistant that lets you have conversations with your PDF files. Instead of reading through hundreds of pages, simply upload your PDF and ask questions in plain English!

Notifications You must be signed in to change notification settings

darwin808/DocuChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š DocuChat - Chat with Your PDF Documents

Upload any PDF document and ask questions about it using AI. Get instant answers backed by the content of your documents!

🎯 What is DocuChat?

DocuChat is an intelligent document assistant that lets you have conversations with your PDF files. Instead of reading through hundreds of pages, simply upload your PDF and ask questions in plain English!

Example:

  • Upload a research paper β†’ Ask "What are the main findings?"
  • Upload a manual β†’ Ask "How do I reset the device?"
  • Upload a contract β†’ Ask "What are the payment terms?"

✨ Features

  • πŸ“„ Upload PDF Files - Supports any PDF document up to 10MB
  • πŸ’¬ Ask Questions - Get instant answers from your documents
  • 🎯 Accurate Responses - AI answers based only on your document content
  • πŸ“Š Source Citations - See which parts of the document were used to answer
  • πŸš€ Fast & Private - Everything runs on your computer
  • πŸ’Ύ No Cloud Required - Your documents stay on your machine

🎬 How It Works (Simple Explanation)

  1. You upload a PDF β†’ DocuChat reads and understands it
  2. You ask a question β†’ DocuChat searches for relevant information
  3. AI generates an answer β†’ Based only on your document's content
  4. You get the answer β†’ With references to where it found the information

Think of it as having a super-smart assistant who has read your entire document and can instantly answer any question about it!


πŸ“‹ What You Need Before Starting

Required Software

  1. Node.js - The engine that runs DocuChat

    • Download from: https://nodejs.org/
    • Choose the "LTS" (Long Term Support) version
    • Version needed: 18 or higher
  2. Ollama - The AI brain that understands and answers questions

System Requirements

  • Operating System: Windows, Mac, or Linux
  • RAM: At least 8GB (16GB recommended)
  • Storage: 5GB free space
  • Internet: Only needed for initial setup

πŸš€ Installation Guide (Step-by-Step)

Step 1: Install Node.js

  1. Go to https://nodejs.org/
  2. Click the big green button that says "LTS"
  3. Download and run the installer
  4. Follow the installation wizard (click "Next" through the steps)
  5. Verify installation:
    • Open Terminal (Mac/Linux) or Command Prompt (Windows)
    • Type: node --version
    • You should see something like v20.x.x

Step 2: Install Ollama

  1. Go to https://ollama.ai/
  2. Click "Download"
  3. Choose your operating system (Mac/Windows/Linux)
  4. Install the application
  5. Ollama will start automatically after installation

Step 3: Download AI Models

These are the AI "brains" DocuChat needs to work:

Open Terminal/Command Prompt and run:

# This downloads the model that understands document content
ollama pull nomic-embed-text

# This downloads the model that answers questions
ollama pull llama3.2:3b

Wait time: Each download takes 5-10 minutes depending on your internet speed.

Step 4: Download DocuChat

Option A - If you have Git:

git clone https://github.com/your-repo/docuchat.git
cd docuchat

Option B - Download ZIP:

  1. Download the ZIP file from the repository
  2. Extract it to a folder (like Documents/docuchat)
  3. Open Terminal/Command Prompt
  4. Navigate to that folder:
    cd path/to/docuchat

Step 5: Install DocuChat Dependencies

In the Terminal/Command Prompt (make sure you're in the docuchat folder):

npm install

This will take 2-3 minutes. You'll see lots of text scrolling - that's normal!

Step 6: Create Upload Folder

mkdir uploads

This creates a folder where uploaded PDFs are temporarily stored.


▢️ How to Start DocuChat

Starting the Application

  1. Make sure Ollama is running (it usually runs in the background)

  2. Open Terminal/Command Prompt

  3. Navigate to DocuChat folder:

    cd path/to/docuchat
  4. Start DocuChat:

    npm start
  5. Look for this message:

    πŸš€ DocuChat server running on http://localhost:3000
    
  6. Open your web browser and go to:

    http://localhost:3000
    

You should see the DocuChat interface! πŸŽ‰


πŸ“– How to Use DocuChat

Uploading Your First PDF

  1. Click the "Choose File" or "Upload PDF" button
  2. Select a PDF from your computer (max 10MB)
  3. Click "Upload"
  4. Wait for processing (you'll see a progress indicator)
  5. Success! Your document is now ready for questions

Processing Time:

  • Small PDF (< 10 pages): 10-30 seconds
  • Medium PDF (10-50 pages): 30-90 seconds
  • Large PDF (50+ pages): 1-3 minutes

Asking Questions

  1. Type your question in the chat box
  2. Click "Send" or press Enter
  3. Wait for the answer (usually 5-15 seconds)
  4. Read the response with source references

Good Question Examples:

  • "What is the main topic of this document?"
  • "Can you summarize the key points?"
  • "What does it say about [specific topic]?"
  • "Who are the authors?"
  • "What are the conclusions?"

Tips for Better Answers:

  • βœ… Be specific in your questions
  • βœ… Ask one thing at a time
  • βœ… Use keywords from the document
  • ❌ Don't ask about things not in the document
  • ❌ Avoid overly broad questions

Understanding Responses

Each answer includes:

  1. The Answer - AI-generated response based on your document
  2. Sources - Snippets from the document that were used
  3. Page Numbers - Where the information was found
  4. Confidence - How relevant each source is

🎯 Real-World Examples

Example 1: Research Paper

Document: Scientific study on climate change

Questions you can ask:

  • "What was the research methodology?"
  • "What are the main findings?"
  • "What data was collected?"
  • "What are the limitations of this study?"

Example 2: Product Manual

Document: Smartphone user guide

Questions you can ask:

  • "How do I take a screenshot?"
  • "What are the technical specifications?"
  • "How do I reset the device?"
  • "What's the battery life?"

Example 3: Legal Document

Document: Service agreement

Questions you can ask:

  • "What are the payment terms?"
  • "What is the cancellation policy?"
  • "What are my obligations?"
  • "What is the contract duration?"

πŸ› οΈ Troubleshooting

Problem: "Cannot connect to Ollama"

Solution:

  1. Make sure Ollama is installed
  2. Check if Ollama is running (look for Ollama icon in system tray)
  3. Try restarting Ollama
  4. On Mac/Linux, run: ollama serve

Problem: "Models not found"

Solution: Run these commands again:

ollama pull nomic-embed-text
ollama pull llama3.2:3b

Problem: "Port 3000 already in use"

Solution: Something else is using port 3000. Either:

  1. Stop the other application
  2. Or change DocuChat's port:
    PORT=3001 npm start
    Then access at: http://localhost:3001

Problem: "File too large" when uploading PDF

Solution: The PDF is over 10MB. Try:

  1. Compress the PDF using online tools
  2. Split the PDF into smaller parts
  3. Or contact support to increase the limit

Problem: Answers are not accurate

Possible Reasons:

  1. Question too vague - Be more specific
  2. Information not in document - AI can only use what's in the PDF
  3. Complex document - Try asking about smaller sections
  4. Poor PDF quality - Scanned images don't work well

Solutions:

  • Rephrase your question
  • Ask about specific sections
  • Make sure PDF has selectable text (not scanned images)

Problem: Server won't start

Error: "node: command not found"

  • Solution: Install Node.js (see Step 1)

Error: "npm: command not found"

  • Solution: Reinstall Node.js (npm comes with it)

Error: Module not found

  • Solution: Run npm install again

πŸ’‘ Tips for Best Results

PDF Quality

βœ… Good PDFs:

  • Text-based PDFs (you can select and copy text)
  • Well-formatted documents
  • Clear structure with headings

❌ Problematic PDFs:

  • Scanned images (unless OCR processed)
  • Password-protected files
  • Corrupted files
  • PDFs with lots of images and little text

Question Types

βœ… Questions that work well:

  • Factual questions ("What is...?", "Who...?", "When...?")
  • Summary requests ("Summarize...", "What are the key points...?")
  • Specific lookups ("What does it say about X?")
  • Comparisons ("What's the difference between...?")

❌ Questions that don't work well:

  • Questions about things not in the document
  • Requests for opinions or predictions
  • Math calculations (unless explicitly in the document)
  • Questions requiring external knowledge

πŸ”’ Privacy & Security

Your Data is Safe

  • βœ… Everything runs locally on your computer
  • βœ… No cloud uploads - PDFs never leave your machine
  • βœ… No tracking - We don't collect any data
  • βœ… Temporary storage - Files are deleted after processing
  • βœ… Open source - You can review all code

What Gets Stored

  • Temporary: Uploaded PDFs (deleted after processing)
  • In Memory: Document chunks and AI embeddings (cleared when you close the app)
  • Never Stored: Your questions, answers, or any personal data

Network Usage

  • During Setup: Downloads AI models from Ollama
  • During Use: Zero internet needed (everything is local)

πŸ“Š System Monitoring

Checking If Everything Is Running

1. Check Ollama:

  • Look for Ollama icon in system tray (Windows/Mac)
  • Or run: ollama list (should show your models)

2. Check DocuChat:

3. Check Document Count:

Performance Tips

If DocuChat is slow:

  1. Close other applications - AI needs RAM
  2. Use smaller PDFs - Break large documents into sections
  3. Restart DocuChat - Clears memory
  4. Upgrade RAM - 16GB+ recommended for large documents

πŸ“± Advanced Usage (Optional)

Using from Command Line

You can test DocuChat using command-line tools:

Check if server is running:

curl http://localhost:3000/api/health

Upload a PDF:

curl -X POST http://localhost:3000/api/upload \
  -F "pdf=@/path/to/your/document.pdf"

Ask a question:

curl -X POST http://localhost:3000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"question": "What is this document about?"}'

Customization Options

Change AI Model: Edit backend/services/chatService.js and change:

this.chatModel = "llama3.2:3b"; // Try other Ollama models

Change Chunk Size: Edit backend/services/pdfProcessor.js and modify:

chunkSize: 800,      // Make larger for more context
chunkOverlap: 200,   // Adjust overlap

Change Number of Results: Edit backend/services/chatService.js:

this.topK = 3; // Increase to retrieve more context

πŸ—οΈ Technical Architecture (For Developers)

Technology Stack

Backend:

  • Node.js + Express.js
  • LangChain (RAG framework)
  • Ollama (AI models)
  • pdf-parse (PDF processing)

AI Models:

  • nomic-embed-text - Text embeddings (768 dimensions)
  • llama3.2:3b - Language model for answers

Components:

  1. PDF Processor - LangChain PDFLoader + RecursiveCharacterTextSplitter
  2. Embedding Service - Converts text to vectors
  3. Vector Store - In-memory similarity search
  4. Chat Service - RAG pipeline with prompt templates

How RAG Works

PDF Upload β†’ Text Extraction β†’ Chunking β†’ Embedding β†’ Vector Store
                                                            ↓
User Question β†’ Embedding β†’ Similarity Search β†’ Top K Chunks
                                                            ↓
                                    Chunks + Question β†’ LLM β†’ Answer

API Endpoints

See backend/API_DOCUMENTATION.md for complete API reference.


❓ Frequently Asked Questions

General Questions

Q: Is DocuChat free? A: Yes! It's completely free and open-source.

Q: Do I need internet? A: Only for initial setup (downloading models). After that, it works offline.

Q: What PDF size is supported? A: Up to 10MB by default. Can be configured for larger files.

Q: Can I upload multiple PDFs? A: Yes! Upload them one at a time. They'll all be searchable together.

Q: Does it work with scanned PDFs? A: Only if the PDF has been OCR-processed (text is selectable).

Technical Questions

Q: What language is it written in? A: JavaScript (Node.js for backend, vanilla JS for frontend).

Q: Can I use different AI models? A: Yes! Any Ollama-compatible model works.

Q: Is my data encrypted? A: Everything runs locally, so data never leaves your computer.

Q: Can I deploy this to a server? A: Yes! See deployment documentation (for technical users).

Usage Questions

Q: Why does the first question take longer? A: The AI models need to "warm up" on first use.

Q: Can I ask follow-up questions? A: Currently, each question is independent. Conversation memory is a planned feature.

Q: What if my document is in another language? A: Ollama models support many languages! Upload and try.

Q: Can I chat with images in PDFs? A: Currently only text is processed. Image recognition is a future feature.


πŸ†˜ Getting Help

Need Support?

  1. Check Troubleshooting section above
  2. Read API Documentation in backend/API_DOCUMENTATION.md
  3. Check LangChain Integration guide in LANGCHAIN_INTEGRATION.md
  4. Search existing issues on GitHub
  5. Ask the community in Discussions
  6. Report a bug via GitHub Issues

Reporting Issues

When reporting a problem, include:

  • Operating system (Windows/Mac/Linux)
  • Node.js version (node --version)
  • Ollama version (ollama --version)
  • Error messages (copy the exact text)
  • Steps to reproduce the problem
  • Screenshots (if helpful)

πŸ—ΊοΈ Roadmap (Future Features)

Coming Soon

  • Conversation memory (remember previous questions)
  • Support for Word documents (.docx)
  • Support for Excel files (.xlsx)
  • Multiple language support
  • Dark mode
  • Export chat history

Planned Features

  • Image extraction from PDFs
  • Table extraction and analysis
  • Document comparison
  • Batch processing
  • API for developers
  • Mobile app
  • Persistent vector database (Chroma/Qdrant)

Your Ideas?

We'd love to hear your suggestions! Open a discussion on GitHub.


πŸ™ Credits & Acknowledgments

DocuChat is built with amazing open-source technologies:

  • LangChain - RAG framework
  • Ollama - Local AI models
  • Express.js - Web server
  • pdf-parse - PDF processing
  • Node.js - Runtime environment

Special thanks to:

  • The Ollama team for making AI accessible
  • The LangChain community
  • All our contributors

πŸ“„ License

This project is licensed under the ISC License.


πŸš€ Quick Start Checklist

Use this checklist for first-time setup:

  • Install Node.js from https://nodejs.org/
  • Install Ollama from https://ollama.ai/
  • Run ollama pull nomic-embed-text
  • Run ollama pull llama3.2:3b
  • Download/clone DocuChat
  • Run npm install in DocuChat folder
  • Run mkdir uploads to create upload folder
  • Start DocuChat with npm start
  • Open browser to http://localhost:3000
  • Upload a test PDF
  • Ask a question
  • πŸŽ‰ You're ready to go!

πŸ“š Additional Documentation

  • API Documentation: backend/API_DOCUMENTATION.md
  • cURL Examples: backend/CURL_EXAMPLES.md
  • LangChain Integration: LANGCHAIN_INTEGRATION.md

Made with ❀️ for everyone who hates reading long documents

DocuChat - Chat with your PDFs, not through them!

About

DocuChat is an intelligent document assistant that lets you have conversations with your PDF files. Instead of reading through hundreds of pages, simply upload your PDF and ask questions in plain English!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published