Projects

OpenKB

An agentic knowledge base for the enterprise

Overview

OpenKB is an enterprise knowledge platform, a place where a whole company can ask plain-English questions and get accurate, cited answers drawn from its own documents, repositories, and conversations.

It started as a classic RAG stack (FastAPI, PostgreSQL + pgvector, Neo4j knowledge graphs, multi-LLM routing) and has since been rebuilt on Cloudflare’s edge around an agentic core: instead of pre-chunking and embedding everything, an agent reads the actual files on demand inside an isolated sandbox. Alongside it is a native macOS voice client that turns meetings into searchable, speaker-labeled transcripts, entirely on-device.

The agentic rebuild on Cloudflare

The newer architecture replaces the heavy RAG pipeline with something simpler and cheaper to run: give a Claude Agent the files and let it explore them with grep and read, the same way an engineer would.

  • Cloudflare Workers: the entire backend runs at the edge. A Worker receives a question, spins up the agent, and streams the answer back. No servers to keep warm; you only pay while a request is in flight.
  • Cloudflare Sandbox: each agent run executes inside an isolated container (the Claude Agent SDK over a /workspace folder), so it can safely run shell tools against a project’s files without touching anything else. Container instances scale up to real multi-user concurrency and bill only while awake.
  • D1 (SQLite at the edge): the metadata and access-control layer: users, projects, per-project file registries, connectors, and an error log. It holds pointers and permissions, not content, a deliberate slimming of the old Postgres model (no more chunks, embeddings, or analytics tables).
  • R2 (persistent storage): the files themselves live here: originals plus a greppable text/markdown extraction for fast searching, organized one prefix per project. D1 rows point at R2 keys.
  • Durable Objects & Workflows: a Durable Object backs the realtime voice agent and per-job state; a repo-sync Workflow does durable, retrying clone/refresh of GitHub repos, one instance per repo, on a 30-minute cron.
  • Auth0 / Clerk identity, AES-256-GCM encryption for stored credentials, and persistent Workers Logs round out the production surface.

GitHub connectors

A standout feature is bringing source code into the knowledge base so the agent can answer questions about how something actually works.

  • Each user links a single GitHub Personal Access Token, encrypted at rest (AES-256-GCM), the raw token is never stored, only a safe display hint.
  • Repos are deduplicated globally: one row per real repo, cloned once into R2. Adding an already-present repo to a second project never re-clones it, a many-to-many bridge maps repos to the projects that use them.
  • Access falls out of the existing ACL: you can see a repo only if you belong to a project that contains it. No repo is ever hydrated for someone outside its projects.
  • A scheduled Workflow keeps every clone fresh on a per-repo interval, with per-step retries and backoff, tracking the last-synced SHA.

The macOS voice client

A separate native macOS app (menu-bar + floating-mic recorder) is the capture client for OpenKB. It records mic and system audio, transcribes it, and files the transcript back into the knowledge base.

  • On-device first, so it’s safe: transcription runs on Apple’s modern on-device SpeechTranscriber engine by default: free, offline, and private, with results streaming in live. A cloud engine (Gemini Flash) is available on demand to compare or for harder audio.
  • Speaker diarization: transcripts are split by speaker, so a meeting reads as a real conversation rather than a wall of text.
  • Org-wide voice recognition (voiceprints): beyond “Speaker 1 / Speaker 2,” the system learns identity across recordings: this voice is “Vedant,” everywhere. Crucially, the audio never leaves the device, only small embedding vectors and names are synced. An org-scoped roster (org = email domain, auto-provisioned) lets matching happen server-side so names stay consistent across the whole team, while admin actions (rename / merge / delete) are isolated per org. Voiceprints are biometric, so enrollment is consent-gated and deletable.
  • A correction loop that improves over time: renaming or merging a speaker enrolls/updates that person’s reference voiceprint, so accuracy grows with use (a growing personal reference library, not model retraining).

Durable, cached transcription service

Backing the voice client is another Cloudflare service, a Worker with one Durable Object per transcription job and a D1 cache.

  • Never pay twice: results are cached by a content + settings hash, so re-transcribing the same audio is free and instant.
  • Survives interruptions: each job runs in a Durable Object driven by an alarm, so it keeps going even if the Mac app quits; the app persists the job id and re-attaches on next launch.
  • Glossary: a custom-vocabulary loop that learns recurring terms and names to improve accuracy over time.

Earlier RAG platform

The original OpenKB was a full hybrid-retrieval RAG system, much of which still informs the design:

  • Vector search (pgvector HNSW) + BM25 + Graph RAG (LightRAG / Neo4j) + web grounding, fused with Reciprocal Rank Fusion and cross-encoder reranking.
  • A query router that classifies each question and picks per-component LLM tiers across Gemini, OpenAI, OpenRouter, and local Ollama.
  • A document ingestion pipeline (PDF, DOCX, XLSX, PPTX, images, notebooks) with parent-child chunking, secret scanning, and dedup.
  • A document-generator studio, enterprise connectors (Drive, OneDrive, Jira, Slack, GitHub, IMAP, NAS, SVN), an MCP server, and an OpenAI-compatible API.

Tech stack

Edge backend: Cloudflare Workers, D1, R2, Vectorize, Durable Objects, Workflows, Workers AI, the Cloudflare Agents SDK, and Cloudflare Sandbox, running the Anthropic Claude Agent SDK inside the sandbox. Voice client: native Swift / SwiftUI for macOS, Apple SpeechTranscriber for on-device transcription, sherpa-onnx speaker embeddings for voiceprints. Original platform: FastAPI + Python, PostgreSQL + pgvector, Neo4j + LightRAG, Redis, and Next.js.