Skip to content

DocuMind is a document intelligence app where users can upload files, extract knowledge, and query them in natural language, combining semantic search (Qdrant), graph insights (Neo4j), and LLM reasoning.

Notifications You must be signed in to change notification settings

kanugurajesh/DocuMind

Repository files navigation

Documind - AI-Powered Document Intelligence Platform

Transform documents into intelligent knowledge with AI-powered semantic search and graph visualization

Next.js TypeScript Tailwind CSS Clerk

πŸš€ Overview

Documind is a cutting-edge document intelligence platform that transforms your documents into an interactive, searchable knowledge base. Upload documents, extract insights, and interact using natural language queries powered by advanced AI technologies.

✨ Key Features

  • πŸ€– AI-Powered Q&A: Ask questions in natural language and get intelligent answers with source citations
  • πŸ“Š Interactive Knowledge Graph: Visualize relationships between entities with advanced filtering and layout options
  • πŸ” Semantic Search: Find relevant information using vector-based similarity search
  • πŸ“„ Multi-Format Support: Process PDFs, Word documents, and text files seamlessly
  • πŸ” Secure & Private: Complete user data isolation with enterprise-grade security
  • ⚑ Real-time Processing: Background document processing with live status updates
  • πŸŽ›οΈ Smart Filtering: Customizable graph views with entity type filters and confidence thresholds
  • πŸ”§ Resilient Architecture: Graceful error handling with fallback options for all services

Photos

Screenshot 2025-09-25 093745 Screenshot 2025-09-25 093751 Screenshot 2025-09-25 093821 Screenshot 2025-09-25 093828 Screenshot 2025-09-25 094350 Screenshot 2025-09-25 094401 Screenshot 2025-09-25 093908

πŸ—οΈ Architecture

Documind employs a sophisticated multi-database architecture designed for scalability and performance:

πŸ“ High-Level Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Frontend Layer                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β€’ Next.js 15 with App Router (React 19)                        β”‚
β”‚  β€’ TypeScript for type safety                                   β”‚
β”‚  β€’ Tailwind CSS v4 for styling                                  β”‚
β”‚  β€’ Radix UI components                                          β”‚
β”‚  β€’ Clerk for authentication                                     β”‚
β”‚  β€’ Cytoscape.js for graph visualization                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β•‘
                                 β•‘ API Routes
                                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Backend Layer                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β€’ Next.js API Routes                                           β”‚
β”‚  β€’ Middleware for authentication                                β”‚
β”‚  β€’ AI Processing Pipeline (LangChain + OpenAI)                  β”‚
β”‚  β€’ File processing (PDF, Word, Text)                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β•‘
         β”Œ---------------────────╫────────--------------┐
         β–Ό                       β•‘                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β•«β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   File Storage  β”‚    β”‚    AI Services  β”‚      β”‚   Databases     β”‚
β”‚                 β”‚    β”‚                 β”‚      β”‚                 β”‚
β”‚  β€’ AWS S3       β”‚    β”‚  β€’ OpenAI GPT   β”‚      β”‚  β€’ MongoDB      β”‚
β”‚  β€’ Presigned    β”‚    β”‚  β€’ Embeddings   β”‚      β”‚  β€’ Qdrant       β”‚
β”‚    URLs         β”‚    β”‚  β€’ LangChain    β”‚      β”‚  β€’ Neo4j        β”‚
β”‚  β€’ Secure       β”‚    β”‚  β€’ Text         β”‚      β”‚  β€’ Multi-DB     β”‚
β”‚    Storage      β”‚    β”‚    Processing   β”‚      β”‚    Architecture β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ—„οΈ Database Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    MongoDB      β”‚    β”‚     Qdrant      β”‚    β”‚     Neo4j       β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚  β€’ Documents    β”‚    β”‚  β€’ Vector       β”‚    β”‚  β€’ Knowledge    β”‚
β”‚    metadata     β”‚    β”‚    embeddings   β”‚    β”‚    Graph        β”‚
β”‚  β€’ User data    β”‚    β”‚  β€’ Semantic     β”‚    β”‚  β€’ Entities     β”‚
β”‚  β€’ Processing   β”‚    β”‚    search       β”‚    β”‚  β€’ Relations    β”‚
β”‚    status       β”‚    β”‚  β€’ Similarity   β”‚    β”‚  β€’ Topics       β”‚
β”‚  β€’ File refs    β”‚    β”‚    matching     β”‚    β”‚  β€’ Clusters     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Technology Stack

Frontend

  • Next.js 15: React framework with App Router
  • TypeScript: Type-safe development
  • Tailwind CSS v4: Modern utility-first styling
  • Radix UI: Accessible component primitives
  • React Hot Toast: User notifications
  • Cytoscape.js: Interactive graph visualization

Backend & APIs

  • Next.js API Routes: RESTful endpoints
  • Clerk: Authentication and user management
  • OpenAI: Embeddings and language model
  • LangChain: AI orchestration framework

Processing Pipeline

  • Mammoth.js: Word document processing
  • PDF-Parse: PDF text extraction
  • Text Chunking: Intelligent content segmentation
  • Entity Extraction: NER with relationship mapping

🌊 Data Flow Architecture

1. User Authentication (Clerk)
   ↓
2. File Upload to S3
   ↓
3. Background Processing:
   β€’ Text extraction
   β€’ AI analysis (OpenAI)
   β€’ Vector generation (Qdrant)
   β€’ Entity extraction (Neo4j)
   β€’ Metadata storage (MongoDB)
   ↓
4. Real-time Status Updates
   ↓
5. Interactive Features:
   β€’ Semantic search
   β€’ AI chat
   β€’ Graph visualization
   β€’ Document management

πŸ”„ Document Processing Flow

File Upload β†’ Text Extraction β†’ AI Processing β†’ Multi-DB Storage
     β”‚              β”‚               β”‚              β”‚
     β”‚              β”‚               β”‚              └─→ Vector embeddings (Qdrant)
     β”‚              β”‚               β”‚                 Entity extraction (Neo4j)
     β”‚              β”‚               β”‚                 Metadata storage (MongoDB)
     β”‚              β”‚               β”‚
     β”‚              β”‚               └─→ LangChain + OpenAI processing
     β”‚              β”‚                   Topic modeling
     β”‚              β”‚                   Entity recognition
     β”‚              β”‚
     β”‚              └─→ PDF/Word/Text extraction
     β”‚                  Mammoth.js for Word docs
     β”‚                  pdf-parse for PDFs
     β”‚
     └─→ AWS S3 secure storage
         Presigned URLs

πŸ›οΈ Component Architecture

Frontend Structure:
β”œβ”€β”€ Pages:
β”‚   β”œβ”€β”€ / (Landing page)
β”‚   β”œβ”€β”€ /dashboard (Main interface)
β”‚   β”œβ”€β”€ /chat (AI Q&A interface)
β”‚   β”œβ”€β”€ /graph (Knowledge graph visualization)
β”‚   └── /sign-in & /sign-up (Authentication)
β”‚
β”œβ”€β”€ Components:
β”‚   β”œβ”€β”€ ui/ (Radix UI components)
β”‚   β”œβ”€β”€ chat/ (Chat interface)
β”‚   β”œβ”€β”€ documents/ (File management)
β”‚   β”œβ”€β”€ graph/ (Cytoscape visualization)
β”‚   └── layout/ (Navigation, headers)
β”‚
└── API Routes:
    β”œβ”€β”€ /upload (File upload & processing)
    β”œβ”€β”€ /documents (CRUD operations)
    β”œβ”€β”€ /search (Semantic search)
    β”œβ”€β”€ /chat (AI Q&A)
    └── /graph (Graph data & operations)

πŸ“‹ Prerequisites

Before running Documind, ensure you have:

  • Node.js (v18 or higher)
  • npm or yarn package manager
  • MongoDB instance (local or cloud)
  • Qdrant vector database
  • Neo4j graph database
  • AWS S3 bucket
  • OpenAI API key
  • Clerk account for authentication

πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/yourusername/documind.git
cd documind

2. Install Dependencies

npm install

3. Environment Configuration

Copy the example environment file and configure your services:

cp .env.example .env.local

Update .env.local with your service credentials:

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your_key
CLERK_SECRET_KEY=sk_test_your_key
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboard

# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/documind
MONGODB_DB_NAME=documind

# Qdrant Vector Database
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=your_qdrant_api_key

# Neo4j Graph Database
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=your_neo4j_password

# AWS S3 Storage
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your_aws_access_key_id
AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
AWS_S3_BUCKET_NAME=your-bucket-name

# OpenAI API
OPENAI_API_KEY=sk-your_openai_key
OPENAI_MODEL=gpt-4o-mini

# Application Configuration
NEXT_PUBLIC_APP_URL=http://localhost:3000
MAX_FILE_SIZE_MB=10
MAX_CHUNK_SIZE=500
EMBEDDING_DIMENSIONS=1536

4. Database Setup

Ensure all databases are running and accessible:

MongoDB

# Local MongoDB
mongod --dbpath /path/to/data/db

# Or use MongoDB Atlas (cloud)

Qdrant

# Using Docker (recommended for development)
docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant

# Or use our provided Docker Compose setup
docker-compose -f docker-compose.qdrant.yml up -d

# Or use Qdrant Cloud

Neo4j

# Using Docker
docker run --publish=7474:7474 --publish=7687:7687 --env NEO4J_AUTH=neo4j/your_password neo4j

# Or use Neo4j Aura (cloud)

5. Run the Application

# Development mode
npm run dev

# Production build
npm run build
npm start

The application will be available at http://localhost:3000

πŸ“‚ Project Structure

documind/
β”œβ”€β”€ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”‚   β”œβ”€β”€ chat/                 # Q&A endpoint
β”‚   β”‚   β”œβ”€β”€ documents/            # Document management
β”‚   β”‚   β”œβ”€β”€ graph/                # Graph operations
β”‚   β”‚   β”œβ”€β”€ search/               # Search functionality
β”‚   β”‚   └── upload/               # File upload
β”‚   β”œβ”€β”€ chat/                     # Chat interface page
β”‚   β”œβ”€β”€ dashboard/                # Main dashboard
β”‚   β”œβ”€β”€ graph/                    # Knowledge graph view
β”‚   β”œβ”€β”€ sign-in/                  # Authentication pages
β”‚   β”œβ”€β”€ sign-up/
β”‚   β”œβ”€β”€ layout.tsx                # Root layout
β”‚   └── page.tsx                  # Landing page
β”œβ”€β”€ components/                   # React components
β”‚   β”œβ”€β”€ chat/                     # Chat interface components
β”‚   β”œβ”€β”€ documents/                # Document management
β”‚   β”œβ”€β”€ graph/                    # Graph visualization
β”‚   β”œβ”€β”€ layout/                   # Layout components
β”‚   └── ui/                       # Reusable UI components
β”œβ”€β”€ lib/                          # Utilities and configurations
β”‚   β”œβ”€β”€ ai/                       # AI processing modules
β”‚   β”‚   β”œβ”€β”€ chat.ts               # Chat functionality
β”‚   β”‚   β”œβ”€β”€ embeddings.ts         # Vector embeddings
β”‚   β”‚   β”œβ”€β”€ entities.ts           # Entity extraction
β”‚   β”‚   β”œβ”€β”€ pipeline.ts           # Processing pipeline
β”‚   β”‚   └── processing.ts         # Text processing
β”‚   β”œβ”€β”€ api/                      # API utilities
β”‚   β”œβ”€β”€ db/                       # Database connections
β”‚   β”‚   β”œβ”€β”€ mongodb.ts            # MongoDB client
β”‚   β”‚   β”œβ”€β”€ neo4j.ts              # Neo4j client
β”‚   β”‚   └── qdrant.ts             # Qdrant client
β”‚   └── storage/                  # File storage
β”œβ”€β”€ types/                        # TypeScript definitions
β”œβ”€β”€ docker-compose.qdrant.yml     # Local Qdrant Docker setup
β”œβ”€β”€ middleware.ts                 # Clerk middleware
└── next.config.ts               # Next.js configuration

πŸ”„ Document Processing Pipeline

1. Upload Phase

  • Authentication: Verify user via Clerk
  • Storage: Save file to AWS S3
  • Metadata: Create document record in MongoDB
  • Queue: Initiate background processing

2. Processing Phase

  • Text Extraction: Extract content from PDF/DOCX/TXT
  • Chunking: Split text into optimal segments (500 tokens)
  • Embeddings: Generate vector representations using OpenAI
  • Storage: Store vectors in Qdrant with user scoping

3. Knowledge Graph Construction

  • Entity Extraction: Identify people, organizations, locations, dates using AI
  • Relationship Mapping: Create co-occurrence and semantic similarity connections
  • Quality Filtering: Filter relationships by confidence thresholds (>0.3 for co-occurrence, >0.5 for similarity)
  • Cross-Document Resolution: Link same entities across different documents
  • Graph Storage: Build optimized knowledge graph in Neo4j with proper indexing
  • User Isolation: Ensure complete data privacy with user-scoped queries

4. Status Updates

  • Real-time: Live processing status updates
  • Error Handling: Comprehensive error reporting
  • Completion: Automatic notification system

πŸ” Search & Q&A System

Semantic Search Flow

  1. Query Processing: Convert user query to vector embedding
  2. Vector Search: Find similar content in Qdrant (user-scoped)
  3. Context Retrieval: Gather related entities from Neo4j
  4. LLM Integration: Combine context with user query
  5. Response Generation: Provide answers with source citations

Knowledge Graph Exploration

  • Interactive Visualization: Cytoscape.js powered graphs with optimized layouts
  • Smart Edge Rendering: Clean visualization with hover-to-reveal labels for reduced clutter
  • Advanced Filtering: Filter by entity types, confidence thresholds, and relationship strengths
  • Customizable Display: Toggle edge labels, adjust node limits, and control visual density
  • Entity Relationships: Explore connections between people, organizations, locations, and concepts
  • Document Mapping: Visualize how documents relate through shared entities and topics
  • Graph Statistics: Real-time metrics showing nodes, edges, and entity distributions

πŸ” Security & Privacy

Authentication

  • Clerk Integration: Secure sign-up/sign-in flows
  • Session Management: Automatic token handling
  • Route Protection: Middleware-based access control

Data Isolation

  • User Scoping: Complete isolation of user data
  • Query Filtering: Automatic user-based filtering
  • Access Control: Document ownership verification

Security Features

  • Encrypted Storage: Secure file storage in AWS S3
  • API Security: Protected routes with authentication
  • Error Handling: Safe error messages without data leakage

πŸ› οΈ Development

Available Scripts

# Development server
npm run dev

# Production build
npm run build

# Start production server
npm start

# Linting
npm run lint

# Code formatting
npm run format

Code Quality

  • TypeScript: Full type safety across the application
  • Biome: Modern linting and formatting
  • Error Boundaries: Graceful error handling
  • Loading States: Comprehensive loading indicators

πŸš€ Deployment

Environment Setup

  1. Database Services: Ensure all databases are accessible
  2. Environment Variables: Configure production credentials
  3. File Storage: Set up AWS S3 bucket
  4. Authentication: Configure Clerk for production

Recommended Platforms

  • Vercel: Optimal for Next.js applications
  • Netlify: Alternative deployment option
  • Railway: Full-stack deployment with databases
  • AWS/GCP/Azure: Enterprise-grade hosting

Production Checklist

  • Environment variables configured
  • Database connections tested
  • File upload limits set
  • Authentication flows verified
  • Error monitoring enabled
  • Performance optimization applied

πŸ”§ Troubleshooting

Common Issues

Qdrant Connection Errors

If you encounter ENOTFOUND errors with Qdrant:

  1. Check Instance Status: Verify your Qdrant Cloud instance is running
  2. Use Local Fallback: Switch to local Docker setup:
    # Start local Qdrant
    docker-compose -f docker-compose.qdrant.yml up -d
    
    # Update .env.local
    QDRANT_URL=http://localhost:6333
    # Remove QDRANT_API_KEY for local instance
  3. Network Issues: Check firewall/VPN settings
  4. Graceful Degradation: The app continues working with limited functionality if Qdrant is unavailable

Graph Visualization Issues

  • No Connections Visible: Check that documents have been processed and entities extracted
  • Cluttered Graph: Use the "Show Connection Labels" toggle to reduce visual noise
  • Performance Issues: Reduce max nodes limit in the filters panel
  • Layout Problems: Use graph controls (fit to view, center, reset zoom) to optimize display

Database Connection Issues

  • MongoDB: Ensure connection string is correct and database is accessible
  • Neo4j: Verify bolt:// URL and credentials are valid
  • AWS S3: Check access credentials and bucket permissions

Development Setup

Quick Local Development

# Start all services with Docker
docker-compose -f docker-compose.qdrant.yml up -d

# Install dependencies
npm install

# Run development server
npm run dev

Environment Validation

The application includes built-in connection testing and will provide clear error messages for misconfigured services.

πŸ“Š Performance Optimizations

Vector Search

  • Efficient Indexing: Optimized Qdrant collections
  • Batch Processing: Bulk operations for embeddings
  • Caching Strategy: Smart result caching

Database Performance

  • MongoDB Indexes: Optimized query performance
  • Neo4j Optimization: Efficient graph traversal
  • Connection Pooling: Managed database connections

Frontend Performance

  • Next.js Optimization: Built-in performance features
  • Component Optimization: Memoization and lazy loading
  • Bundle Optimization: Efficient code splitting

🀝 Contributing

We welcome contributions! Please follow these steps:

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

Development Guidelines

  • TypeScript: Maintain type safety
  • Testing: Add tests for new features
  • Documentation: Update docs for changes
  • Code Style: Follow established patterns

πŸ“„ License

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

πŸ†˜ Support

Documentation

  • API Reference: /docs/api
  • Component Library: /docs/components
  • Deployment Guide: /docs/deployment

Community

Enterprise Support

For enterprise deployments and custom integrations, contact us at [email protected]


Built with ❀️ by the Kanugu Rajesh

Website β€’ Documentation β€’ Blog

About

DocuMind is a document intelligence app where users can upload files, extract knowledge, and query them in natural language, combining semantic search (Qdrant), graph insights (Neo4j), and LLM reasoning.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published