MCPcopy Index your code
hub / github.com/brainfish-ai/ReasonDB

github.com/brainfish-ai/ReasonDB @v0.5.10

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.10 ↗ · + Follow
2,813 symbols 7,724 edges 382 files 844 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<img src="https://github.com/brainfish-ai/ReasonDB/raw/v0.5.10/assets/logo.svg" alt="ReasonDB" width="140" />

AI-Native Document Intelligence

The database that understands your documents.


Built for AI agents that need to reason, not just retrieve.











<a href="https://github.com/reasondb/reasondb/releases"><img src="https://img.shields.io/github/v/release/reasondb/reasondb?color=6C5CE7&include_prereleases&label=version&sort=semver&style=flat-square" alt="Version"></a>
&nbsp;
<a href="https://github.com/reasondb/reasondb"><img src="https://img.shields.io/badge/built_with-Rust-dca282.svg?style=flat-square" alt="Built with Rust"></a>
&nbsp;
<a href="https://github.com/reasondb/reasondb/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/reasondb/reasondb/ci.yml?style=flat-square&branch=main&label=CI" alt="CI"></a>
&nbsp;
<a href="https://github.com/reasondb/reasondb/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-ReasonDB_v1.0-00bfff.svg?style=flat-square" alt="License"></a>







<a href="https://hub.docker.com/r/brainfishai/reasondb"><img src="https://img.shields.io/docker/pulls/brainfishai/reasondb?label=docker%20pulls&style=flat-square" alt="Docker Pulls"></a>
&nbsp;
<a href="https://github.com/reasondb/reasondb"><img src="https://img.shields.io/github/stars/reasondb/reasondb?color=FFD700&style=flat-square&label=stars" alt="GitHub Stars"></a>
&nbsp;
<a href="https://github.com/reasondb/reasondb"><img src="https://img.shields.io/github/downloads/reasondb/reasondb/total?color=8259dd&label=downloads&style=flat-square" alt="Downloads"></a>







<a href="https://reason-db.devdoc.sh">Docs</a>
&nbsp;&bull;&nbsp;
<a href="https://reason-db.devdoc.sh/documentation/page/quickstart">Quick Start</a>
&nbsp;&bull;&nbsp;
<a href="https://reason-db.devdoc.sh/api-reference/introduction">API Reference</a>







<sub>&#9888;&#65039; <strong>Alpha Release</strong> &mdash; ReasonDB is under active development. APIs and features may change. We'd love your <a href="https://github.com/reasondb/reasondb/issues">feedback</a>!</sub>

Similarity is not relevance. ReasonDB replaces broken RAG & vector search.

ReasonDB Client Demo

What is ReasonDB?

ReasonDB is an AI-native document database built in Rust, designed to go beyond simple retrieval. While traditional databases and vector stores treat documents as data to be indexed, ReasonDB treats them as knowledge to be understood - preserving document structure, enabling LLM-guided traversal, and extracting precise answers with full context.

ReasonDB introduces Hierarchical Reasoning Retrieval (HRR), a fundamentally new architecture where the LLM doesn't just consume retrieved content - it actively navigates your document structure to find exactly what it needs, like a human expert scanning summaries, drilling into relevant sections, and synthesizing answers.

ReasonDB is not another vector database. It's a reasoning engine that preserves document hierarchy, enabling AI to traverse your knowledge the way a domain expert would.

Key features of ReasonDB include:

  • Hierarchical Reasoning Retrieval: LLM-guided tree traversal with parallel beam search - AI navigates document structure instead of relying on similarity matching
  • RQL Query Language: SQL-like syntax with built-in SEARCH (BM25) and REASON (LLM) clauses in a single query
  • Plugin Architecture: Extensible extraction pipeline - PDF, Office, images, audio, and URLs out of the box via MarkItDown
  • Multi-Provider LLM Support: Anthropic, OpenAI, Gemini, Cohere, Vertex AI, AWS Bedrock, and more — switch providers without code changes
  • Production Ready: ACID-compliant storage, API key auth, rate limiting, async parallel traversal - all in a single Rust binary

Contents

The Problem

AI agents today are limited by their databases:

Approach What It Does Why It Fails
Vector DBs Finds "similar" chunks Loses structure. A contract's termination clause isn't "similar" to your question about exit terms - but it's the answer.
RAG Pipelines Retrieves then generates Garbage in, garbage out. Wrong chunks retrieved means wrong answers, no matter how capable the LLM.
Knowledge Graphs Maps explicit relationships Requires manual entity extraction. Can't handle the messy reality of real documents.

The result? AI agents that hallucinate, miss critical context, or drown in irrelevant chunks.

ReasonDB solves this by letting the LLM reason through your documents - not just search them.

Benchmark

Results on a real-world insurance document corpus (4 policy documents, ~1,900 nodes, 12 queries across 6 complexity tiers). Full benchmark script: tutorials/data/insurance/benchmark.py.

Retrieval quality vs. typical RAG

Metric ReasonDB Typical RAG
Pass rate 100% (12 / 12) 55 – 70%
Context recall (term match) 90% avg 60 – 75%
Median latency (RQL REASON) 6.1 s 15 – 45 s

"Typical RAG" = chunked-retrieval pipelines (LlamaIndex / LangChain defaults) on the same corpus. ReasonDB uses BM25 candidate selection + LLM-guided hierarchical tree traversal instead of flat similarity matching.

Per-category breakdown

Category Avg latency Term recall Pass
Simple 7.1 s 100% 2 / 2
Specific 5.9 s 75% 2 / 2
Multi-condition 5.6 s 83% 2 / 2
Comparative 6.2 s 100% 2 / 2
Multi-hop 6.5 s 83% 2 / 2
Synthesis 6.5 s 100% 2 / 2

Cross-section reference retrieval

ReasonDB detects and follows intra-document cross-references during ingestion (LLM-extracted during summarization) and surfaces the referenced sections alongside primary results. This closes the "answer is split across two clauses" gap that defeats flat-chunk retrieval.

Metric Value
Queries with ≥ 1 cross-ref surfaced 4 / 5
Avg recall, primary content only 62%
Avg recall, primary + cross-refs 80% (+18 pp)
Example gain Recurrent disability query: 67% → 100% once cross-referenced policy schedule clause is included

Insurance Policy Analyser — Live Demo

The benchmark above is powered by this tutorial app. It queries four insurance policy documents using REASON and shows the full traversal trace — which nodes the LLM visited, why it selected them, and how it synthesized the final answer.

Insurance Policy Analyser Demo

Full tutorial source: tutorials/06-insurance/

How It Works

%%{init: {'theme': 'dark'}}%%
flowchart TD
    subgraph Ingestion["Ingestion Pipeline (Plugin-Driven)"]
        A["Documents / URLs"] -->|Extractor Plugin| B["Markdown"]
        B -->|Post-Processor Plugin| C["Cleaned Markdown"]
        C -->|Chunker| D["Semantic Chunks"]
        P["Pre-chunked JSON"] -->|"bypasses extract + chunk"| D
        D --> E["Build Hierarchical Tree"]
        E -->|Bottom-up| F["LLM Summarizes Each Node"]
    end

    subgraph Search["Search & Reasoning"]
        G["Natural Language Query"] --> G1["BM25 Candidates + Title Boost"]
        G1 --> G2["Recursive Tree-Grep Pre-Filter"]
        G2 --> H["LLM Ranks by Summaries + Match Signals"]
        H -->|Selects relevant branches| I["Traverse Tree"]
        I -->|Parallel beam search| J["Drill Into Leaf Nodes"]
    end

    subgraph Result["Response"]
        J --> K["Extract Answer"]
        K --> L["Confidence Score + Reasoning Path"]
    end

    Ingestion --> Search
  1. Extract - Extractor plugins convert documents and URLs to Markdown (built-in: MarkItDown)
  2. Chunk - Content is split into semantic chunks with heading detection — or bypass entirely with pre-chunked JSON via /ingest/chunks
  3. Build Tree - Chunks are organized into a hierarchical tree structure, preserving per-chunk metadata (page numbers, line ranges, custom attributes)
  4. Summarize - LLM generates summaries for each node (bottom-up); pre-supplied summaries are used as-is
  5. Search - 4-phase pipeline: BM25 candidate selection → recursive tree-grep filtering → LLM summary ranking → parallel beam-search traversal
  6. Return - Relevant content with extracted answers, confidence scores, and the full reasoning path

Quick Start

Get from zero to intelligent document search in under 5 minutes.

Download pre-built binaries

Grab the latest release for your platform:

Platform Architecture Download
macOS Apple Silicon (M1/M2/M3/M4) aarch64-apple-darwin
Linux x86_64 x86_64-unknown-linux-gnu
Linux ARM64 aarch64-unknown-linux-gnu
Windows x86_64 x86_64-pc-windows-msvc

ReasonDB Client: A desktop app is also available for macOS (.dmg) and Windows (.msi).

macOS: "ReasonDB.app" Not Opened

Since ReasonDB is in alpha, the desktop app is not yet signed with an Apple Developer certificate. macOS Gatekeeper will block it on first launch. To open it:

  1. Right-click (or Control-click) on ReasonDB.app and select Open
  2. Click Open in the confirmation dialog

Or remove the quarantine attribute from the terminal:

xattr -cr /Applications/ReasonDB.app

You can also go to System Settings → Privacy & Security, scroll down, and click Open Anyway next to the ReasonDB message.

Install with Homebrew (macOS / Linux)

brew tap brainfish-ai/reasondb-tap
brew install reasondb

Install with one line (macOS / Linux)

No Homebrew? Download and install directly:

# macOS Apple Silicon
curl -L https://github.com/brainfish-ai/reasondb/releases/latest/download/reasondb-$(curl -s https://api.github.com/repos/brainfish-ai/reasondb/releases/latest | grep tag_name | cut -d'"' -f4)-aarch64-apple-darwin.tar.gz | tar -xz && sudo mv reasondb /usr/local/bin/

# Linux x86_64
curl -L https://github.com/brainfish-ai/reasondb/releases/latest/download/reasondb-$(curl -s https://api.github.com/repos/brainfish-ai/reasondb/releases/latest | grep tag_name | cut -d'"' -f4)-x86_64-unknown-linux-gnu.tar.gz | tar -xz && sudo mv reasondb /usr/local/bin/

Install from source

git clone https://github.com/reasondb/reasondb.git && cd reasondb
cargo build --release

To also set up the desktop app and tutorials, install JS dependencies from the repo root:

yarn install          # installs apps/, packages/, and tutorials/ in one step
yarn build:packages   # builds the shared @reasondb/rql-editor package

Configure your LLM provider

reasondb config init
Variable Description Required
REASONDB_LLM_PROVIDER openai, anthropic, gemini, cohere, glm, kimi, ollama, vertex, bedrock Yes
REASONDB_LLM_API_KEY API key for the chosen provider Yes
REASONDB_MODEL Override the default model for the provider No

Start the server

reasondb serve

Server starts at http://localhost:4444 with Swagger UI at http://localhost:4444/swagger-ui/

Run using Docker

docker run --rm --pull always --name reasondb -p 4444:4444 \
  -e REASONDB_LLM_PROVIDER=openai \
  -e REASONDB_LLM_API_KEY=sk-... \
  brainfishai/reasondb:latest serve

Or use the Makefile for local development:

make docker-up        # Build and start
make docker-up-d      # Start in background
make docker-logs      # View logs
make docker-down      # Stop containers
make docker-down-v    # Stop and remove data volume
make docker-ps        # Check health status

ReasonDB Client (Desktop App)

The repo uses a Yarn workspace — a single yarn install at the root installs all JS dependencies across apps/, packages/, and tutorials/.

# One-time setup from repo root
yarn install
yarn build:packages   # build the shared @reasondb/rql-editor package

# Run the desktop app
make client-app          # dev mode (Tauri + Vite)
make client-app-build    # production build

# Or use yarn workspace commands directly
yarn workspace reasondb-client dev         # Vite web dev server only
yarn workspace reasondb-client tauri dev   # full Tauri desktop app (dev)
yarn workspace reasondb-client build       # production build

Interactive Tutorials

Six hands-on tutoria

Extension points exported contracts — how you extend this code

ReasoningEngine (Interface)
(no doc) [4 implementers]
crates/reasondb-core/src/llm/mod.rs
EmptyStateProps (Interface)
* Empty table state
apps/reasondb-client/src/components/table/document-viewer/components/States.tsx
Props (Interface)
(no doc)
tutorials/03-research-papers/src/components/ResultsDisplay.tsx
Props (Interface)
(no doc)
tutorials/02-legal-search/src/components/ResultsDisplay.tsx
Props (Interface)
(no doc)
tutorials/05-pdf-financials/src/components/ResultsDisplay.tsx
Props (Interface)
(no doc)
tutorials/04-knowledge-base/src/components/ResultsDisplay.tsx
TreeNode (Interface)
(no doc)
tutorials/06-insurance/src/components/MatchedNodesTree.tsx
WikiQueryResponse (Interface)
(no doc)
tutorials/scripts/fetchers/wikipedia.ts

Core symbols most depended-on inside this repo

clone
called by 427
crates/reasondb-core/src/engine.rs
clone
called by 241
crates/reasondb-core/src/backup/snapshot.rs
len
called by 185
crates/reasondb-plugin/src/registry.rs
json
called by 182
crates/reasondb-core/src/backup/export.rs
is_empty
called by 161
crates/reasondb-plugin/src/registry.rs
cn
called by 158
apps/reasondb-client/src/lib/utils.ts
as_str
called by 143
crates/reasondb-core/src/auth/key.rs
parse
called by 102
crates/reasondb-core/src/rql/parser.rs

Shape

Function 1,193
Method 890
Class 375
Interface 298
Enum 57

Languages

Rust67%
TypeScript33%
Python1%
Ruby1%

Modules by API surface

apps/reasondb-client/src/lib/api.ts118 symbols
crates/reasondb-core/src/rql/tests.rs61 symbols
crates/reasondb-core/src/rql/parser.rs55 symbols
crates/reasondb-core/src/llm/provider.rs53 symbols
crates/reasondb-ingest/src/pipeline.rs45 symbols
crates/reasondb-server/src/jobs.rs43 symbols
crates/reasondb-core/src/llm/mod.rs38 symbols
crates/reasondb-core/src/llm/dynamic.rs36 symbols
crates/reasondb-plugin/src/protocol.rs35 symbols
tutorials/06-insurance/src/lib/api.ts34 symbols
crates/reasondb-core/src/ratelimit/limiter.rs32 symbols
crates/reasondb-core/src/cluster/raft.rs31 symbols

For agents

$ claude mcp add ReasonDB \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact