Skip to content

ltphen/Neural-drive

Repository files navigation

NeuralDrive

AI-native workspace with vector-indexed storage, context-aware document generation, and agentic workflows.

Features

  • Document Drive — Upload and manage documents (PDF, DOCX, CSV, XLSX, TXT) with automatic parsing, chunking, and vector indexing. Organize files in a hierarchical folder system.

    Document Drive

  • Copilot — Conversational AI assistant with selectable document context, knowledge hub scoping, and MCP tool integration. Supports streaming responses with source citations.

    Copilot

  • Semantic Search — Search across all documents using natural language. Hybrid search combines vector similarity with keyword matching via pgvector.

    Semantic Search

  • Document Factory — AI-powered content generation with RAG context from your knowledge base. Includes templates, summarization, and Q&A.

    Document Editor

  • Automations — Visual workflow builder with event-driven triggers (file upload, schedule, webhook, manual) and configurable action nodes. Supports conditional logic, loops, and parallel execution.

    Automations

    Workflow Builder

  • MCP Tools — Connect external tools and services via the Model Context Protocol. Register STDIO or HTTP servers, discover their capabilities, and use them in Copilot and workflows.

    MCP Tools

  • Knowledge Hubs — Curated document collections with dedicated chat interfaces. Configure RAG settings per hub with auto-inclusion rules.

    Knowledge Hubs

  • AI Tables — Extract structured data from documents into configurable table schemas. Define columns with extraction prompts and export to CSV/JSON.

    AI Tables

Quick Start

Using Docker (Recommended)

  1. Clone the repository and copy the environment file:
cp .env.example .env
  1. Add your API keys to .env:
OPENAI_API_KEY=your-key-here
# or
ANTHROPIC_API_KEY=your-key-here
  1. Start all services:
docker-compose up --build
  1. Access the application:

Local Development

Backend

cd backend

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

# Install dependencies
pip install -r requirements.txt

# Start PostgreSQL and Redis (via Docker or locally)
docker-compose up postgres redis -d

# Run database migrations
alembic upgrade head

# Start the server
uvicorn app.main:app --reload

Frontend

cd frontend

# Install dependencies
npm install

# Start development server
npm run dev

Celery Workers

cd backend

# Worker (background tasks)
celery -A app.worker.celery_app worker --loglevel=info

# Beat (scheduled tasks)
celery -A app.worker.celery_app beat --loglevel=info

Architecture

NeuralDrive uses a hexagonal architecture (ports & adapters) on the backend and Next.js App Router on the frontend.

DMS/
├── backend/                      # FastAPI backend (Python 3.11)
│   ├── app/
│   │   ├── api/v1/              # Route handlers
│   │   │   ├── auth.py          # Authentication
│   │   │   ├── documents.py     # Document CRUD & upload
│   │   │   ├── folders.py       # Folder management
│   │   │   ├── search.py        # Semantic & hybrid search
│   │   │   ├── generation.py    # Content generation & RAG
│   │   │   ├── automations.py   # Workflow automation
│   │   │   ├── mcp.py           # MCP server management
│   │   │   ├── ai_tables.py     # AI table operations
│   │   │   ├── knowledge_hubs.py# Knowledge hub management
│   │   │   └── hub_chat.py      # Knowledge hub chat
│   │   │
│   │   ├── domain/              # Core business logic
│   │   │   ├── entities/        # Domain models (dataclasses)
│   │   │   ├── ports/           # Abstract interfaces (LLM, embedding, storage)
│   │   │   └── events/          # Domain events
│   │   │
│   │   ├── application/         # Use cases & services
│   │   │   └── services/        # Business logic orchestration
│   │   │       ├── agent_service.py       # Unified agent executor
│   │   │       ├── agentic_rag_service.py # Two-stage RAG retrieval
│   │   │       ├── ingestion_service.py   # Document processing
│   │   │       ├── search_service.py      # Search operations
│   │   │       ├── generation_service.py  # LLM generation
│   │   │       ├── automation_service.py  # Workflow management
│   │   │       ├── mcp_service.py         # MCP integration
│   │   │       ├── tool_registry.py       # Tool discovery & management
│   │   │       ├── ai_table_service.py    # AI table logic
│   │   │       ├── knowledge_hub_service.py
│   │   │       └── chat_service.py
│   │   │
│   │   ├── infrastructure/      # External implementations
│   │   │   ├── adapters/        # Port implementations
│   │   │   │   ├── llm/         # OpenAI, Anthropic, Ollama
│   │   │   │   ├── embedding/   # OpenAI, local sentence-transformers
│   │   │   │   ├── storage/     # Local filesystem, S3
│   │   │   │   └── web_search/  # Tavily
│   │   │   ├── database/        # SQLAlchemy models & repositories
│   │   │   └── parsers/         # PDF, DOCX, CSV, XLSX, TXT parsers
│   │   │
│   │   ├── worker/              # Celery background tasks
│   │   │   └── tasks/           # Ingestion, embedding, automation, AI table tasks
│   │   │
│   │   ├── config.py            # Pydantic settings
│   │   ├── dependencies.py      # FastAPI dependency injection
│   │   └── main.py              # App factory & lifespan
│   │
│   ├── alembic/                 # Database migrations
│   └── tests/                   # pytest test suite
│
├── frontend/                    # Next.js 14 frontend (TypeScript)
│   └── src/
│       ├── app/                 # App Router pages
│       │   ├── copilot/         # AI assistant
│       │   ├── drive/           # File manager
│       │   ├── editor/          # Document editor
│       │   ├── search/          # Search interface
│       │   ├── automations/     # Workflow management & builder
│       │   ├── mcp/             # MCP server configuration
│       │   ├── ai-tables/       # AI table interface
│       │   ├── knowledge-hubs/  # Knowledge hub management & chat
│       │   └── settings/        # Application settings
│       ├── components/          # React components
│       │   ├── ui/              # Base UI components
│       │   ├── copilot/         # Copilot interface
│       │   ├── workflow/        # Workflow builder (ReactFlow)
│       │   ├── ai-tables/       # AI table components
│       │   ├── knowledge-hubs/  # Knowledge hub components
│       │   ├── drive/           # File browser
│       │   ├── editor/          # Rich text editor (TipTap)
│       │   └── settings/        # Settings & MCP config
│       ├── lib/api/             # API client modules
│       ├── stores/              # Zustand state stores
│       ├── hooks/               # Custom React hooks
│       └── types/               # TypeScript type definitions
│
└── docker-compose.yml           # PostgreSQL, Redis, Backend, Celery, Frontend

API Reference

All endpoints are prefixed with /api/v1. Full interactive docs available at /docs when running.

Authentication (/auth)

Method Endpoint Description
POST /auth/register Register new user
POST /auth/login Login and get JWT tokens
POST /auth/refresh Refresh access token
GET /auth/me Get current user profile

Documents (/documents)

Method Endpoint Description
POST /documents/upload Upload a document file
POST /documents/create Create a text document
GET /documents/ List documents
GET /documents/{id} Get document details
PATCH /documents/{id}/content Update document content
GET /documents/{id}/download Download document file
DELETE /documents/{id} Delete a document
POST /documents/{id}/reprocess Reprocess a document

Folders (/folders)

Method Endpoint Description
POST /folders/ Create a folder
GET /folders/ List folders at level
GET /folders/{id} Get folder with contents
GET /folders/tree/all Get full folder tree
GET /folders/{id}/breadcrumb Get breadcrumb path
PATCH /folders/{id} Update a folder
DELETE /folders/{id} Delete a folder
POST /folders/{id}/move Move a folder

Search (/search)

Method Endpoint Description
GET /search/?q=query Semantic search
GET /search/hybrid?q=query Hybrid search (vector + keyword)
GET /search/context?q=query Get RAG context

Generation (/generation)

Method Endpoint Description
POST /generation/generate Generate content with RAG
POST /generation/generate/agentic Agentic RAG with tool use
POST /generation/generate/stream Stream generated content
POST /generation/template Generate from template
POST /generation/summarize Summarize a document
POST /generation/ask Answer a question with RAG

Automations (/automations)

Method Endpoint Description
POST /automations/ Create automation
GET /automations/ List automations
GET /automations/{id} Get automation
PATCH /automations/{id} Update automation
DELETE /automations/{id} Delete automation
POST /automations/{id}/pause Pause automation
POST /automations/{id}/resume Resume automation
POST /automations/{id}/trigger Manually trigger automation
GET /automations/{id}/runs Get run history
GET /automations/meta/trigger-types List trigger types
GET /automations/meta/action-types List action types

MCP Servers (/mcp)

Method Endpoint Description
POST /mcp/servers Register MCP server
GET /mcp/servers List MCP servers
GET /mcp/servers/{id} Get MCP server
PATCH /mcp/servers/{id} Update MCP server
DELETE /mcp/servers/{id} Delete MCP server
POST /mcp/servers/{id}/connect Connect and discover tools
POST /mcp/servers/{id}/disconnect Disconnect from server
GET /mcp/servers/{id}/tools Get server tools
POST /mcp/servers/{id}/tools/{name} Execute a tool

AI Tables (/ai-tables)

Method Endpoint Description
POST /ai-tables/ Create AI table
GET /ai-tables/ List AI tables
GET /ai-tables/{id} Get AI table
PUT /ai-tables/{id} Update AI table
DELETE /ai-tables/{id} Delete AI table
POST /ai-tables/{id}/columns Add column
PUT /ai-tables/{id}/columns/{col_id} Update column
DELETE /ai-tables/{id}/columns/{col_id} Delete column
GET /ai-tables/{id}/rows List rows
POST /ai-tables/{id}/rows Add row manually
POST /ai-tables/{id}/rows/process Extract data from documents
PUT /ai-tables/{id}/rows/{row_id} Update row value
POST /ai-tables/{id}/rows/{row_id}/review Mark row reviewed
GET /ai-tables/{id}/export Export table (CSV/JSON)

Knowledge Hubs (/knowledge-hubs)

Method Endpoint Description
POST /knowledge-hubs/ Create hub
GET /knowledge-hubs/ List hubs
GET /knowledge-hubs/{id} Get hub
PUT /knowledge-hubs/{id} Update hub
DELETE /knowledge-hubs/{id} Delete hub
POST /knowledge-hubs/{id}/documents Add documents
DELETE /knowledge-hubs/{id}/documents Remove documents
POST /knowledge-hubs/{id}/folders Add folders
DELETE /knowledge-hubs/{id}/folders Remove folders
POST /knowledge-hubs/{id}/rules Add inclusion rule
DELETE /knowledge-hubs/{id}/rules/{idx} Remove rule
GET /knowledge-hubs/{id}/documents List hub documents
POST /knowledge-hubs/{id}/refresh Refresh hub index

Knowledge Hub Chat (/knowledge-hubs/{hub_id}/chat)

Method Endpoint Description
POST /chat/sessions Create chat session
GET /chat/sessions List sessions
GET /chat/sessions/{id} Get session with messages
PATCH /chat/sessions/{id} Update session
DELETE /chat/sessions/{id} Delete session
POST /chat/sessions/{id}/archive Archive session
POST /chat/sessions/{id}/messages Send message
POST /chat/sessions/{id}/messages/stream Stream message (SSE)
GET /chat/sessions/{id}/messages Get messages

Configuration

LLM Providers

NeuralDrive supports multiple LLM providers via a pluggable adapter pattern. Set DEFAULT_LLM_PROVIDER in .env:

Provider Models Config
OpenAI GPT-4, GPT-4 Turbo, GPT-3.5 Turbo OPENAI_API_KEY, OPENAI_MODEL
Anthropic Claude 3 Opus, Sonnet, Haiku ANTHROPIC_API_KEY, ANTHROPIC_MODEL
Ollama Llama 2, Mistral, and other local models OLLAMA_BASE_URL, OLLAMA_MODEL

Embedding Providers

Set DEFAULT_EMBEDDING_PROVIDER in .env:

Provider Models Dimensions
OpenAI text-embedding-3-small, text-embedding-3-large 1536
Local all-MiniLM-L6-v2 (sentence-transformers) 384

Storage Backends

Set STORAGE_BACKEND in .env:

Backend Config
Local STORAGE_PATH (default: ./storage)
S3 S3_BUCKET, S3_REGION, S3_ACCESS_KEY, S3_SECRET_KEY

Web Search (Optional)

Set ENABLE_WEB_SEARCH=true and configure TAVILY_API_KEY to enable web search in Copilot and agent workflows.

Authentication

JWT-based authentication. Configure SECRET_KEY, ALGORITHM (default: HS256), and ACCESS_TOKEN_EXPIRE_MINUTES (default: 30).

Tech Stack

Backend

  • FastAPI — async web framework
  • SQLAlchemy 2.0 — async ORM
  • PostgreSQL + pgvector — database with vector similarity search
  • Celery + Redis — background task processing and scheduling
  • Alembic — database migrations
  • Pydantic v2 — settings and request/response validation
  • passlib + python-jose — authentication (JWT + bcrypt)

Frontend

  • Next.js 14 — React framework (App Router)
  • TypeScript — type safety
  • TanStack Query — data fetching and caching
  • Zustand — state management (with Immer)
  • TipTap — rich text editor
  • ReactFlow — workflow visualization
  • Tailwind CSS — styling
  • React Dropzone — file uploads

Infrastructure

  • Docker Compose — orchestration (PostgreSQL, Redis, Backend, Celery Worker, Celery Beat, Frontend)

License

MIT

About

AI-native document workspace with vector-indexed storage, semantic search, and agentic workflows. Features RAG-powered copilot, visual automation builder, MCP tool integration, and AI data extraction tables.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors