docMind
Linear GraphRAG & Intelligent Document Intelligence Platform
01. Context & Specifications
Most standard RAG pipelines fail due to information asymmetry: a short 5-word user query needs to pinpoint a highly specific clause without losing its global structural context. docMind solves this via an optimized MarkdownTextSplitter (chunkSize: 800, chunkOverlap: 200) coupled with a Multi-Router Query Gateway. Global synthesis queries route to a sequential RAG path (Top-15 consecutive chunks), while granular lookups trigger spatial vector matching augmented by graph neighborhood expansion traversal.
02. Architecture Pipeline
Unit modeling of the processing and isolation cycle of business data for this project:
[Document Source PDF/Specs] ──> (MarkdownTextSplitter: Size 800 / Overlap 200)
│
[Supabase / PostgreSQL] <── (Linear Graph Weaving: prev/next pointers)
│
(Vector Space: HNSW Index / 384-d via MiniLM-L6)
│
(Multi-Router Query Gateway) ──> [Path A: Intent Detection / Global Summary (Top-15 Sequential)]
──> [Path B: Semantic Top-K + Neighborhood Graph Expansion]
│
[Narrative Reordering by index] ──> (Gemini 2.5 Flash Lite SSE Stream) ──> [FinOps Log & Rate Limiter]03. Vector Ingestion & Relational Database Graph Schema
The core innovation lies in the persistence tier. Instead of relying on an isolated external vector store, all metadata and spatial embeddings are unified inside PostgreSQL using the pgvector extension. By explicitly saving pre-linked client-side UUID nodes (prev_chunk_id and next_chunk_id), the retriever can dynamically expand the structural context surrounding a match before injecting it into the Gemini 2.5 Flash Lite system prompt.
-- Schema layout for Linear GraphRAG structures
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE IF NOT EXISTS document_chunks (
id UUID PRIMARY KEY, -- Pre-generated client-side UUID for graphing
document_id UUID REFERENCES documents(id) ON DELETE CASCADE NOT NULL,
user_id UUID NOT NULL,
content TEXT NOT NULL,
chunk_index INT NOT NULL,
token_count INT NOT NULL,
embedding vector(384), -- 384-d embeddings via sentence-transformers
prev_chunk_id UUID REFERENCES document_chunks(id) ON DELETE SET NULL,
next_chunk_id UUID REFERENCES document_chunks(id) ON DELETE SET NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL
);
-- High-Performance Vector HNSW Index for rapid spatial queries
CREATE INDEX IF NOT EXISTS document_chunks_embedding_hnsw_idx
ON document_chunks USING hnsw (embedding vector_cosine_ops);04. Retrospective & Limitations
>_ Post-deployment engineering notes:The linear graph weaving layer successfully mitigates context fragmentation in dense technical documents. However, parsing multi-axis financial charts and asymmetric layout matrices embedded inside native PDFs remains a friction point. For v2, integrating a Vision-Transformer pre-processing pipeline is planned to extract complex visuals before text embedding.