Knowledge Gateway
One API for five knowledge sources, with traceable context, scoped caching and resilient retrieval.
Explore the project in 3D
Knowledge is distributed.
Your integration can be simpler.
An agent may need a semantic match from a vector store, a canonical policy from OKF, a specification on disk, a commit explaining a decision, and a live relational record. Rebuilding those retrieval paths in every application creates repeated integration work.
Knowledge Gateway provides a common request, a bounded retrieval path and one result format. Sources keep their own storage and update workflows; clients receive document context with the evidence needed to inspect its origin and completeness.
Background reading: OKF vs RAGOne contract. Independent sources.
Select sources and a scenario to see how the architecture responds. This walkthrough uses browser examples; it sends no queries to a backend.
01 / Choose knowledge sources
Knowledge Gateway
POST /api/v1/query
- 1Validate & authenticate
- 2Check scoped cache
- 3Dispatch selected sources
- 4Rank & order candidates
- 5Return context + provenance
- 6Inspect timing & activity
03 / Inspect the outcome
Selected sources run concurrently. Candidates are ranked, ordered and returned as a bounded context page.
Five ways to retrieve. One way to inspect.
Each adapter returns the same item structure while preserving source-specific provenance.
Qdrant / RAG
Semantic recall
Search a configured vector collection through an OpenAI-compatible embedding endpoint. Validate vector indexes, dimensions and finite values before querying.
One Qdrant collection per instance; synthetic vectors are an explicit demo option.
OKF documents
Entities & relations
Read Markdown with YAML metadata, resolve named entities, and follow explicit dependencies and governance relationships without hard-coded service names.
Bounded file loading and periodic refresh; cached results still follow TTL/invalidation.
Filesystem
Docs & specifications
Search configured document roots with deterministic traversal and matching-line context. Skip hidden files, child symlinks and oversized documents.
Bounded lexical retrieval over explicitly configured roots.
Git repositories
Versioned decisions
Look up commits and tracked trees at configured revisions. Keep repository, author, branch and commit provenance attached to the result.
Git is invoked with argument arrays; retrieval follows the configured revision.
PostgreSQL
Structured records
Search configured relational tables through a bounded connection pool with read-only transactions, quoted identifiers and statement deadlines.
PostgreSQL is implemented; MySQL and pgvector adapters are not included.
Context with an explicit boundary
Source selection and tags help retrieval. They do not replace permissions. Enforce source access and tenant policy at your deployment boundary.
Reliability across the retrieval path.
Bounded parallel retrieval
Connector work runs outside the async event loop, with four worker slots per connector, configurable source deadlines and query admission limits.
Failures stay visible
A slow or failed source produces explicit per-source status and degraded results. Total source failure returns 503. Partial results are not cached.
Less repeated work
Identical in-flight queries share retrieval. Canonical SHA-256 keys include configuration scope and dataset namespace; cached responses are isolated copies.
Practical cache operations
Choose memory LRU/LFU/FIFO or Redis with TTL, bounded fallback and retry backoff. Clear only the scoped dataset; Redis invalidation failures remain visible.
Trace the response
Inspect request IDs, connector timing, provenance and eight ranking features through the dashboard, REST activity endpoints and bounded SSE notifications.
Deliberate access boundaries
Protect data APIs with a shared key, mask configuration secrets, restrict hosts/origins, validate requests and keep production startup free of sample insertion.
A small contract.
A traceable response.
Choose sources, tags, a page size and a minimum ranking score. Each result carries provenance; each response reports source status, cache state and a request ID. An application can distinguish an empty search from an upstream outage.
Response fields below are an abbreviated illustration. Read the versioned OpenAPI contract for the complete schema.
Read the API contractcurl http://127.0.0.1:8080/api/v1/query \
-H 'Content-Type: application/json' \
-H "X-API-Key: $KNOWLEDGE_GATEWAY_API_KEY" \
-d '{
"query": "Which services depend on vault-secrets-engine?",
"sources": ["okf", "filesystem"],
"tags": ["vault"],
"page": 1,
"page_size": 3,
"min_score": 0.15
}'Verification behind this revision.
The full local validation passed 53 automated checks, including real PostgreSQL, Redis and Qdrant, plus five embedding HTTP simulation cases.
| Cold query · median | 2.599 ms |
| Cached query · HTTP median | 1.233 ms |
| Cached query · HTTP p95 | 2.211 ms |
| Cached service work · median | 0.080 ms |
| Concurrent cached requests | 20 / 20 succeeded |
Local HTTP against small OKF and filesystem fixtures on Python 3.13: 30 cold queries, 100 cached queries, and 20 concurrent cached requests. These measurements describe this workload, not a production SLA.
Build once against your knowledge layer.
Agent context without integration sprawl
Connect an assistant once, then select the knowledge sources relevant to each task while retaining one query and response contract.
Operational knowledge with provenance
Combine a versioned runbook, service dependency, repository change and database record into traceable context before an application generates an answer.
Compare retrieval paths
Inspect where results came from, which sources failed and how ranking features affected the returned page during development and evaluation.
Start locally. Inspect every step.
The default launcher uses an explicit offline demo: synthetic in-memory Qdrant, deterministic test vectors, sample OKF/files/Git, and a memory cache. It makes no paid embedding requests. Configure real services separately when you move beyond the demo.
git clone https://github.com/karthikrameshdev/knowledge-gateway.git
cd knowledge-gateway
git checkout dad39edf69acb80ab643fa9d2273c08c697fdb67
./run.sh
# Offline regression checks
./test.sh
# Real PostgreSQL, Redis and Qdrant validation
./test.sh --integrationThe API beyond retrieval.
| Method | Endpoint | Purpose |
|---|---|---|
| POST | /api/v1/query | Ranked context, source status and pagination |
| GET | /api/v1/sources/status | Bounded connector diagnostics |
| GET | /api/v1/activity | Filtered recent query activity |
| GET | /api/v1/activity/{request_id} | Source and ranking inspection |
| GET | /api/v1/tail/stream | Authenticated SSE with heartbeats |
| GET | /api/v1/cache/stats | Process cache metrics |
| POST | /api/v1/cache/clear | Explicit scoped invalidation |
| GET | /api/v1/config | Configuration with masked secrets |
| GET | /health | Process liveness |
| GET | /ready | Retrieval readiness and degradation |
Know the current boundaries.
Choose the service with a clear view of its implemented contract and the controls your deployment still needs.
The gateway returns retrieved context. Answer generation belongs to the consuming application.
The bundled ONNX network has hand-authored weights. Its eight feature scores are ranking signals, not calibrated factual-confidence probabilities.
The shared API key is a service boundary. Per-user permissions, tenant isolation and source ACL enforcement belong in a deployment-specific authorization layer.
Activity and request coalescing are process-local. Durable audit storage and cross-worker observability are not included.
Freshness follows cache TTL or explicit invalidation. No automatic change watcher or webhook endpoint is shipped; strict distributed invalidation needs coordinated writers.
Pagination is deterministic for unchanged data and scores. It does not provide a durable snapshot cursor over a changing dataset.
Explore the code. Bring your knowledge sources.
Apache 2.0 · Reproducible local setup · Versioned API and validation docs
Project reference
One API. Five knowledge sources. Context you can trace.
An open-source retrieval gateway by Karthik Ramesh unifying Qdrant, OKF documents, filesystem knowledge, Git history, and PostgreSQL through bounded parallel retrieval, local ONNX feature ranking, scoped caching, and provenance-rich results.
An open-source retrieval service connecting agents to five knowledge source types through bounded parallel searches, scoped TTL caching, local feature-based ranking, and provenance-rich paginated context. Includes a live query dashboard and source inspection, with explicit partial-result and outage behavior.
Bounded source fan-out → 8-feature ONNX ranking → stable score/source/ID ordering → paginated context; canonical SHA-256 cache keys scoped by configuration and dataset namespace.
- Five adapters: Qdrant vector retrieval, OKF entities and explicit relations, bounded filesystem search, revision-aware Git, and read-only pooled PostgreSQL.
- Source deadlines, query admission limits and in-process request coalescing; degraded responses stay out of cache and total source failure returns 503.
- Memory LRU/LFU/FIFO or Redis TTL caching, failure backoff and scoped invalidation; shared-key API access, secret masking and bounded SSE inspection.
- Documented v1.1.0 revision with 53 passing local full-stack checks, an OpenAPI contract, explicit offline demo and deployment boundaries.
Python 3.11+ · FastAPI · Local ONNX Runtime · Apache-2.0 · 53 checks passed · 5 connector types · Reproducible local HTTP benchmark
git clone https://github.com/karthikrameshdev/knowledge-gateway.git && cd knowledge-gateway && ./run.shPractical guide & interpretation
Knowledge Gateway is Karthik Ramesh’s open-source retrieval API for five knowledge sources: Qdrant, OKF documents, filesystem documents, Git history and PostgreSQL. It returns ranked context with provenance and source status; answer generation belongs to the consuming application.
Integrate the gateway without losing the evidence boundary
Choose the sources needed for one application task rather than enabling every connector by default. Submit a bounded query and inspect both the results and the per-source status. A partial response can still be useful, but the application should explain which source was unavailable and avoid representing incomplete evidence as a complete answer. Total source failure and degraded retrieval require different handling.
Build authorization around the deployment. The documented shared API key protects a service boundary; it is not a complete per-user or multi-tenant access-control system. Apply caller-specific scope before retrieving protected material and include that scope in the caching design. Test whether the same query from two differently authorized callers can expose an unintended cached result before using shared infrastructure.
Reproduce performance under an equivalent workload. The recorded local measurements use small OKF and filesystem fixtures, and cached requests exercise a different path from cold connector work. They do not predict latency for a remote embedding service, a large repository or a congested database. Evaluate cold queries, warm queries, connector timeouts, concurrent requests and invalidation together, and report the slow cases as well as the median.
Questions & answers
Does Knowledge Gateway generate the final answer?
No. The documented gateway returns retrieved context, ranking information, provenance and connector status. A consuming assistant or application decides how to synthesize an answer and must preserve the evidence and authorization boundaries appropriate to its users.
Which databases and retrieval sources are implemented?
The documented version supports Qdrant, OKF documents, configured filesystem roots, Git repositories and PostgreSQL. MySQL and pgvector adapters are not included. Configure the actual supported connectors rather than assuming that a general multi-source description implies every database is available.
Do ranking scores measure factual confidence?
No. The bundled ONNX network uses hand-authored weights over eight ranking features. Its scores help order candidates and are not calibrated probabilities that a passage is true or sufficient. Check source provenance, version and relevance independently before relying on the returned context.
About this work
Written by Karthik Ramesh, an AI platform engineer and independent AI and quantum researcher. This project walkthrough includes a compact interactive explanation; the text describes its assumptions and practical limits.
Explanation updated . The portfolio date is an owner-assigned display date, separate from publication and project-start history.
