textrawl
byJeff Green

Architecture

Deep dive into textrawl's technical architecture

This section covers the technical details of how textrawl works under the hood.

Architecture Overview

textrawl is built on a modern stack optimized for semantic search:

  • Runtime: Node.js 22+ with ES modules
  • Database: Supabase PostgreSQL with pgvector extension
  • Transport: MCP over HTTP (StreamableHTTPServerTransport)
  • Embeddings: OpenAI or Ollama (configurable)

Request Flow

Claude Desktop / MCP Client

         ▼ POST /mcp (JSON-RPC)
    ┌─────────────┐
    │   Express   │
    │   Server    │
    └──────┬──────┘


    ┌─────────────┐
    │    MCP      │
    │  Transport  │
    └──────┬──────┘


    ┌─────────────┐
    │    Tool     │
    │  Handlers   │
    └──────┬──────┘

     ┌─────┴─────┐
     ▼           ▼
┌─────────┐ ┌─────────┐
│ Supabase│ │ OpenAI/ │
│   DB    │ │ Ollama  │
└─────────┘ └─────────┘

Core Components

The search system combines full-text keyword matching with semantic vector similarity using Reciprocal Rank Fusion (RRF).

Learn about hybrid search →

Text Chunking

Documents are split into overlapping chunks to fit within embedding model context limits while preserving semantic coherence.

  • 512 tokens (~2048 characters) per chunk
  • 50 token overlap for context preservation
  • Paragraph-aware splitting on \n\n

Learn about chunking →

Embeddings

Vector representations that capture semantic meaning, enabling similarity search.

ProviderModelDimensions
OpenAItext-embedding-3-small1536
Ollamanomic-embed-text1024

Learn about embeddings →

Database Schema

Core Tables

TablePurpose
documentsDocument metadata, content, tags
chunksText chunks with embeddings and FTS vectors

Memory Tables (Optional)

TablePurpose
memory_entitiesNamed entities (people, projects, concepts)
memory_observationsFacts about entities with embeddings
memory_relationsDirected relationships between entities

Key Indexes

IndexTypePurpose
chunks.search_vectorGINFull-text search
chunks.embeddingHNSWVector similarity
memory_observations.embeddingHNSWMemory search

MCP Transport

textrawl uses StreamableHTTPServerTransport for stateless HTTP operation:

  • Stateless: Each request creates a fresh MCP server instance
  • Serverless-compatible: Works with Cloud Run, Lambda, etc.
  • Single endpoint: POST /mcp handles all MCP operations

Rate Limiting

EndpointLimit
/mcp (API)100 requests/minute
/api/upload10 requests/minute

Security

  • Bearer token authentication (API_BEARER_TOKEN)
  • Row Level Security (RLS) on all tables
  • Service role key bypasses RLS (single-tenant design)

See Security Hardening for production setup.

Next Steps

On this page