Skip to main content
MetaCogna RAG is a production-ready RAG system built on Cloudflare Workers that combines document storage, vector search, and knowledge graph extraction to provide intelligent question-answering capabilities.

Architecture

Key Features

Document Management

Upload and index .md, .pdf, .txt files with metadata tracking

Vector Search

Semantic search with 768-dimensional embeddings using Vectorize

Knowledge Graph

Entity and relationship extraction for graph visualization

RAG Chat

Context-aware chat with multiple LLM providers

Prompt Engineering

Template library with variable interpolation

Admin User Management

Controlled user creation with goal-driven personalization

Technology Stack

Backend

  • Cloudflare Workers - Edge compute runtime
  • D1 - SQLite database for metadata and graph nodes
  • R2 - Object storage for document content
  • Vectorize - Vector database (768 dimensions, cosine similarity)
  • Workers AI - LLM and embedding generation

Frontend

  • React 18 - UI framework
  • Vite - Build tool and dev server
  • Tailwind CSS - Styling with Paper UI theme
  • Zustand - State management
  • Framer Motion - Animations

Quick Start

Prerequisites

  • Bun (recommended) or Node.js 18+
  • Cloudflare Account with Workers access
  • Wrangler CLI (installed via Bun)

Installation

Environment Setup

Create .env.local:

Development

Deployment

Project Structure

Core Concepts

RAG Pipeline

The ingestion pipeline processes documents through 4 stages:
  1. Chunking (0-29%) - Text splitting into semantic chunks (~500 chars)
  2. Embedding (30-59%) - Vector embedding generation (768 dimensions)
  3. Graph Extraction (60-89%) - Entity and relationship extraction
  4. Finalizing (90-100%) - Final indexing and metadata updates

Knowledge Graph

The system extracts entities and relationships from documents:
  • Nodes: Entities (people, concepts, topics)
  • Edges: Relationships between entities
  • Metadata: Node types, connection strengths, document sources

Authentication

  • Admin-only signup: Only administrators can create users
  • SHA-256 hashing: Secure password storage
  • Session cookies: 7-day expiry, HttpOnly, secure
  • Worker-based auth: No localStorage credentials