Back

HydraDBTechnical Deep Dive

HydraDB

The RAG engine powering this app

HydraDB is a multi-tenant vector database with hybrid recall, memory management, and an edge-native API. This page shows exactly how H1BAgent uses it to turn 30+ USCIS documents into instant, cited answers.

Multi-TenantHybrid SearchMemory SystemEdge-Native APIPDF Ingestion

<80ms

Recall Latency (p50)

Full recall endpoint

~50 docs/min

Ingest Throughput

PDF extraction + embedding

High

Chunk Precision

Tunable via alpha parameter

Parallel

Concurrency

Both recall endpoints simultaneously

Bearer Token

Auth

Single API key per tenant

Edge-native

Runtime

No Node.js dependency for recall

System Architecture

How H1BAgent uses HydraDB for RAG

upload.knowledge()upload.addMemory()recall/full_recallrecall/recall_preferencesHydraDBPDF UploadMemory StoreMarkdown IngestMetadata TagsFull RecallPreference RecallHybrid SearchMulti-TenantSub-TenantsRanked ChunksIngestionCoreRetrievalIsolationOutput

RAG Pipeline

End-to-end flow from data to answer

1
IngestUpload PDFs + structured markdown with metadata
2
ProcessAuto-chunk, embed, and index into tenant namespace
3
RecallHybrid semantic + keyword search with alpha tuning
4
AugmentInject ranked chunks into LLM system prompt
5
RespondStream grounded, cited answers to the user

How H1BAgent Uses HydraDB

Real production architecture — not a demo

Ingested
30+
USCIS documents (15 PDFs + 15 structured markdown covering FY2001-FY2027)
Recall Strategy
2x
Parallel recall paths (full_recall + recall_preferences) merged into a single context window
Runtime
Edge
Pure fetch() API on Cloudflare Workers edge runtime — no Node SDK needed at query time

What's Inside the Knowledge Base

30+ documents ingested via upload.knowledge() and upload.addMemory()— here's what the workbench queries against

PDF Documents (15 files via upload.knowledge)
PDFCharacteristics of H-1B Workers FY2024
PDFCharacteristics of H-1B Workers FY2023
PDFCharacteristics of H-1B Workers FY2020
PDFCharacteristics of H-1B Workers FY2019
PDFCharacteristics of H-1B Workers FY2018
PDFCharacteristics of H-1B Workers FY2005
PDFCharacteristics of H-1B Workers FY2004
PDFReport on H-1B Petitions FY2024
PDFReport on H-1B Petitions FY2023
PDFReport on H-1B Petitions FY2019
PDFH-1B Trend Tables FY2007-FY2017
PDFTop 30 H-1B Employers FY2018
PDFFY2025 E-Registration Process
PDFH-1B Weighted Selection Compliance Guide
PDFH-1B Characteristics FY2023 (supplemental)
Structured Memories (15 docs via upload.addMemory)
H-1B Program Overview
Visa category basics, dual intent, specialty occupation definition
Cap History & Legislative Changes
65k/85k cap evolution, ACWIA, AC21, H-1B Reform Act
Petitions Filed/Approved FY2001-FY2024
Year-by-year petition volumes with approval counts
Petition Types FY2024
Initial vs continuing employment breakdown
Country of Birth Data
India, China, Canada share trends across 20 years
Age & Sex Demographics
Median age 34, gender split 70/30
Education Levels
Bachelor's vs master's shift from 57/31 to 33/46
Top Occupations
Computer occupations rising from 44% to 64%
Compensation Data
Median salary $52k (FY03) to $120k (FY24) by occupation
Industry Sectors
Professional services, tech, finance distribution
Registration & Lottery System
FY21-FY27 registration counts, selection rates, methods
Fees Structure
Filing fees, ACWIA, fraud prevention, asylum program fees
Premium Processing & RFE
I-907 stats, RFE rates, denial trends
Top Employers FY2007-2017
Infosys, Tata, Cognizant, Wipro petition volumes
FY2027 Weighted Lottery
Wage-level based selection probabilities
How it works: PDFs are auto-chunked and embedded by HydraDB. Structured memories are stored as markdown with is_markdown: true and upsert: true for idempotent updates. At query time, both sources are searched in parallel via full_recall + recall_preferences, with the alpha parameter controlling the semantic vs keyword balance. The top chunks are injected into the LLM system prompt.

Live Workbench

Query HydraDB in real time — tune parameters, compare endpoints

KeywordSemantic
NoneRecent first
110

Core Capabilities

Click to expand code examples and implementation details

Every tenant gets its own isolated namespace. Sub-tenants enable hierarchical data organization — perfect for per-user, per-org, or per-project knowledge separation.

TypeScript
// Create isolated tenant
await hydra.tenant.create({
  tenant_id: "H1B"
});

// Data always scoped to tenant
await hydra.upload.knowledge({
  files: [pdfBuffer],
  tenant_id: "H1B",
  // Optional sub-tenant for finer isolation
  sub_tenant_id: "user_123"
});
  • +Complete data isolation between tenants
  • +Hierarchical sub-tenant support for nested workspaces
  • +409 conflict handling for idempotent tenant creation
  • +Tenant-scoped queries — no data leakage across boundaries

With HydraDB vs. Without

Without RAG
const result = streamText({
  model: google("gemini-2.0-flash"),
  system: "You are an H-1B expert.",
  // No context — LLM hallucinates
  // outdated data, wrong numbers
  messages,
});

LLM invents numbers, cites non-existent reports, mixes up fiscal years

With HydraDB RAG
// Retrieve grounding context
const chunks = await hydraRecall(query);

const result = streamText({
  model: google("gemini-2.0-flash"),
  system: `You are an H-1B expert.
    ## Retrieved USCIS Data:
    ${chunks.join("\n---\n")}`,
  messages,
});

Every answer grounded in official USCIS data with correct fiscal year citations