Skip to content

Aaqilyousuf/DocuMind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DocuMind πŸ§ πŸ“„

Intelligent Document Interaction Platform

DocuMind is a powerful AI-driven document management and interaction platform that allows users to upload, manage, and chat with their documents using advanced Retrieval Augmented Generation (RAG) technology. Built with React and Flask, it provides secure, user-isolated document processing with real-time AI-powered conversations.

✨ Features

πŸ” User-Isolated Document Management

  • Secure user authentication with cookie-based sessions
  • Complete user isolation - users can only access their own documents
  • Real-time document synchronization across components

πŸ“„ Multi-Format Document Support

  • PDF - Extract text from PDF documents
  • DOCX - Process Microsoft Word documents
  • TXT - Handle plain text files
  • CSV - Parse comma-separated values

πŸ€– AI-Powered Chat Interface

  • Chat with your documents using natural language
  • Context-aware responses based on document content
  • Powered by Groq's fast inference engine
  • Real-time conversation interface

⚑ Advanced RAG Pipeline

  • Document Processing: Upload β†’ Text Extraction β†’ Chunking β†’ Embeddings β†’ Vector Storage
  • Smart Chunking: Intelligent text segmentation for optimal retrieval
  • Vector Search: Fast similarity search using Pinecone vector database
  • Embedding Models: Support for multiple embedding providers

🎨 Modern User Interface

  • Clean, responsive design with Tailwind CSS
  • Real-time file upload with progress indicators
  • Intuitive chat sidebar with document management
  • Delete functionality with confirmation dialogs

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   React Client  β”‚    β”‚   Flask Server  β”‚    β”‚  External APIs  β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚ β€’ Upload UI     │◄──►│ β€’ File Routes   │◄──►│ β€’ Pinecone DB   β”‚
β”‚ β€’ Chat Interfaceβ”‚    β”‚ β€’ Query Routes  β”‚    β”‚ β€’ Groq LLM      β”‚
β”‚ β€’ Document List β”‚    β”‚ β€’ RAG Pipeline  β”‚    β”‚ β€’ Appwrite      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Docker and Docker Compose (Recommended)
  • Node.js (v16 or higher) - if running manually
  • Python (v3.8 or higher) - if running manually
  • Git

🐳 Docker Setup (Recommended)

The easiest way to get DocuMind running is with Docker:

# 1. Clone the repository
git clone <repository-url>
cd DocuMind

# 2. Setup environment variables
cp .env.example .env
# Edit .env with your API keys (see Environment Variables section below)

# 3. Start everything with Docker
docker-compose up --build

# Or run in background
docker-compose up -d --build

That's it! Your application will be running at:

# To stop services
docker-compose down

# To view logs
docker-compose logs -f

# To restart services
docker-compose restart

πŸ”§ Manual Setup (Alternative)

If you prefer to run without Docker:

πŸ’» Manual Setup (Alternative)

If you prefer to run without Docker:

Backend Setup

# Navigate to server directory
cd docuMind_server

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows

# Install dependencies
pip install -r requirements.txt

# Setup environment variables
cp .env.example .env
# Edit .env with your API keys

# Run the server
python app/main.py

Frontend Setup

# Navigate to client directory (in new terminal)
cd docuMind_client

# Install dependencies
npm install

# Start development server
npm run dev

Access the application:

πŸ”§ Environment Variables

Create a .env file in the docuMind_server directory with the following variables:

# Pinecone Configuration (Required)
PINECONE_API_KEY=your_pinecone_api_key_here

# Groq Configuration (Required)
GROQ_API_KEY=your_groq_api_key_here

# Appwrite Configuration (Required)
APPWRITE_ENDPOINT=your_appwrite_endpoint_here
APPWRITE_PROJECT_ID=your_appwrite_project_id_here
APPWRITE_API_KEY=your_appwrite_api_key_here
APPWRITE_BUCKET_ID=your_appwrite_bucket_id_here

API Keys Setup

  1. Pinecone (Vector Database)

    • Sign up at pinecone.io
    • Create a new project and get your API key
    • Create an index with 768 dimensions (cosine similarity)
  2. Groq (LLM Inference)

    • Sign up at groq.com
    • Get your API key from the dashboard
  3. Appwrite (File Storage)

    • Sign up at appwrite.io
    • Create a new project
    • Set up a storage bucket
    • Generate API keys

πŸ“‚ Project Structure

DocuMind/
β”œβ”€β”€ docker-compose.yml          # Docker configuration
β”œβ”€β”€ .env.example               # Environment variables template
β”œβ”€β”€ README.md                  # This file
β”œβ”€β”€ docuMind_client/          # React Frontend
β”‚   β”œβ”€β”€ Dockerfile            # Frontend container setup
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/       # UI Components
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/          # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatSidebar.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ FileList.tsx
β”‚   β”‚   β”‚   └── FileUploadCard.tsx
β”‚   β”‚   β”œβ”€β”€ pages/           # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatPage.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ HomePage.tsx
β”‚   β”‚   β”‚   └── UploadPage.tsx
β”‚   β”‚   └── hooks/           # Custom React hooks
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
β”‚
β”œβ”€β”€ docuMind_server/          # Flask Backend
β”‚   β”œβ”€β”€ Dockerfile            # Backend container setup
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ routes/          # API Routes
β”‚   β”‚   β”‚   β”œβ”€β”€ upload.py    # File upload endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ query.py     # Chat query endpoints
β”‚   β”‚   β”‚   └── files.py     # File management endpoints
β”‚   β”‚   β”œβ”€β”€ services/        # Business Logic
β”‚   β”‚   β”‚   β”œβ”€β”€ file_processor.py  # Document processing
β”‚   β”‚   β”‚   β”œβ”€β”€ file_parser.py     # Text extraction
β”‚   β”‚   β”‚   β”œβ”€β”€ chunking.py        # Text chunking
β”‚   β”‚   β”‚   β”œβ”€β”€ embeddings.py      # Vector embeddings
β”‚   β”‚   β”‚   β”œβ”€β”€ vectorstore.py     # Pinecone operations
β”‚   β”‚   β”‚   β”œβ”€β”€ llm.py            # Groq integration
β”‚   β”‚   β”‚   └── storage.py        # Appwrite integration
β”‚   β”‚   └── main.py          # Flask application
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── .env.example
β”‚
└── README.md                # This file

🐳 Docker Development

Docker Setup Details

DocuMind uses Docker for easy development setup. The configuration includes:

  • Backend Container: Python 3.11 with Flask development server
  • Frontend Container: Node.js 18 with Vite development server
  • Hot Reload: Both containers support live code changes
  • Volume Mounts: Source code is mounted for instant updates

Docker Commands

# Start all services
docker-compose up

# Build and start (after code changes)
docker-compose up --build

# Run in background
docker-compose up -d

# View logs
docker-compose logs -f

# View specific service logs
docker-compose logs -f backend
docker-compose logs -f frontend

# Stop all services
docker-compose down

# Restart services
docker-compose restart

# Access container shell
docker-compose exec backend bash
docker-compose exec frontend sh

Docker Troubleshooting

# Rebuild containers from scratch
docker-compose down
docker-compose build --no-cache
docker-compose up

# Clean up Docker resources
docker system prune -f

# Check container status
docker-compose ps

πŸ”„ API Endpoints

File Management

  • GET /api/v1/files - List user's documents
  • POST /api/v1/upload - Upload a new document
  • DELETE /api/v1/files/<file_id> - Delete a document

Chat Interface

  • POST /api/v1/query - Send chat query to AI

Health Check

  • GET / - API health status

πŸ› οΈ Development

Tech Stack

Frontend:

  • React 18 with TypeScript
  • Vite for build tooling
  • Tailwind CSS for styling
  • Axios for HTTP requests
  • React Router for navigation
  • Shadcn/ui component library

Backend:

  • Flask (Python web framework)
  • Flask-CORS for cross-origin requests
  • Sentence Transformers for embeddings
  • PyPDF2 for PDF processing
  • python-docx for Word documents

External Services:

  • Pinecone (Vector Database)
  • Groq (LLM Inference)
  • Appwrite (File Storage)

Key Features Implementation

  1. User Isolation: All operations are filtered by user_id from cookies
  2. File Processing Pipeline: Upload β†’ Parse β†’ Chunk β†’ Embed β†’ Store
  3. Real-time Updates: Custom events for cross-component synchronization
  4. Error Handling: Comprehensive error handling with user-friendly messages

Adding New Document Types

  1. Update file_parser.py with new extraction logic
  2. Add MIME type support in FileUploadCard.tsx
  3. Update file validation in both frontend and backend

🚨 Troubleshooting

Docker Issues

  1. Port Conflicts

    # If ports 3000 or 5000 are in use, edit docker-compose.yml:
    ports:
      - "3001:3000"  # Frontend
      - "5001:5000"  # Backend
  2. Container Build Failures

    # Clean rebuild
    docker-compose down
    docker-compose build --no-cache
    docker-compose up
  3. Volume Mount Issues

    # On Windows, ensure drive sharing is enabled in Docker Desktop
    # On Linux, check file permissions
    sudo chown -R $USER:$USER .

Application Issues

  1. Import Errors (Manual Setup)

    # Make sure you're in the virtual environment
    pip install -r requirements.txt
  2. CORS Issues

    • Check that Flask-CORS is installed
    • Verify frontend is running on correct port
  3. File Upload Errors

    • Check file type is supported
    • Verify file size limits
    • Check Appwrite bucket permissions
  4. Chat Not Working

    • Verify Groq API key is valid
    • Check Pinecone connection
    • Ensure documents are properly indexed

Debug Mode

With Docker:

# View detailed logs
docker-compose logs -f

# Access container for debugging
docker-compose exec backend bash

Manual Setup:

export FLASK_DEBUG=1
export FLASK_ENV=development

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ’« Acknowledgments

  • Built with modern React and Flask best practices
  • Powered by advanced AI and vector search technologies
  • Designed for scalability and user privacy

Happy document chatting! πŸŽ‰

For support or questions, please open an issue in the repository.

Note: The hosted site includes only the frontend (UI). The backend isn’t hosted because it uses the Nomic open-source local embedding model. However, you can clone this repo and follow the Docker setup steps to run both frontend and backend locally.

About

DocuMind is a powerful AI-driven document management and interaction platform that allows users to upload, manage, and chat with their documents using advanced Retrieval Augmented Generation (RAG) technology.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors