Open-source softwareApache 2.0 · Open source

Knowledge Gateway

One API for five knowledge sources, with traceable context, scoped caching and resilient retrieval.

Explore the project in 3D

Loading interactive 3D…
5
Knowledge connector types
53
Automated checks passed
8
Local ranking features
Apache 2.0
Open-source license
Why it exists

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 RAG
Explore the request path

One 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.

Interactive architecture

01 / Choose knowledge sources

02 / Unified retrieval layer

Knowledge Gateway

POST /api/v1/query

  1. 1Validate & authenticate
  2. 2Check scoped cache
  3. 3Dispatch selected sources
  4. 4Rank & order candidates
  5. 5Return context + provenance
  6. 6Inspect timing & activity
Bounded I/O · local feature model · stable ordering

03 / Inspect the outcome

200 · Complete retrieval
ragresults + provenance
okfresults + provenance
filesystemresults + provenance
gitresults + provenance
sqlresults + provenance

Selected sources run concurrently. Candidates are ranked, ordered and returned as a bounded context page.

The source layer

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.

ProvenanceCollection · point ID · embedding model · dimensions

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.

ProvenanceFile · version · verification · traversal path

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.

ProvenanceFile path · matching line · file size

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.

ProvenanceRepository · revision · commit · author

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.

ProvenanceDatabase · table · row ID

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.

Implementation

Reliability across the retrieval path.

01

Bounded parallel retrieval

Connector work runs outside the async event loop, with four worker slots per connector, configurable source deadlines and query admission limits.

02

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.

03

Less repeated work

Identical in-flight queries share retrieval. Canonical SHA-256 keys include configuration scope and dataset namespace; cached responses are isolated copies.

04

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.

05

Trace the response

Inspect request IDs, connector timing, provenance and eight ranking features through the dashboard, REST activity endpoints and bounded SSE notifications.

06

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.

For application developers

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 contract
Query request
curl 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
  }'
Measured, with scope

Verification behind this revision.

The full local validation passed 53 automated checks, including real PostgreSQL, Redis and Qdrant, plus five embedding HTTP simulation cases.

Input validation, access protection and secret masking
Partial results, total outages and source deadlines
Concurrent request coalescing and cache invalidation
Real database lookup and Redis TTL / namespace isolation
Embedding success, malformed vectors, JSON/HTML errors and timeout
Browser query execution and distinct pagination results
Read the validation record
Local HTTP benchmark
Cold query · median2.599 ms
Cached query · HTTP median1.233 ms
Cached query · HTTP p952.211 ms
Cached service work · median0.080 ms
Concurrent cached requests20 / 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.

Where it fits

Build once against your knowledge layer.

USE CASE / 01

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.

USE CASE / 02

Operational knowledge with provenance

Combine a versioned runbook, service dependency, repository change and database record into traceable context before an application generates an answer.

USE CASE / 03

Compare retrieval paths

Inspect where results came from, which sources failed and how ranking features affected the returned page during development and evaluation.

Try the documented revision

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.

Local setup
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 --integration

The API beyond retrieval.

MethodEndpointPurpose
POST/api/v1/queryRanked context, source status and pagination
GET/api/v1/sources/statusBounded connector diagnostics
GET/api/v1/activityFiltered recent query activity
GET/api/v1/activity/{request_id}Source and ranking inspection
GET/api/v1/tail/streamAuthenticated SSE with heartbeats
GET/api/v1/cache/statsProcess cache metrics
POST/api/v1/cache/clearExplicit scoped invalidation
GET/api/v1/configConfiguration with masked secrets
GET/healthProcess liveness
GET/readyRetrieval readiness and degradation
Deployment decisions

Know the current boundaries.

Choose the service with a clear view of its implemented contract and the controls your deployment still needs.

01

The gateway returns retrieved context. Answer generation belongs to the consuming application.

02

The bundled ONNX network has hand-authored weights. Its eight feature scores are ranking signals, not calibrated factual-confidence probabilities.

03

The shared API key is a service boundary. Per-user permissions, tenant isolation and source ACL enforcement belong in a deployment-specific authorization layer.

04

Activity and request coalescing are process-local. Durable audit storage and cross-worker observability are not included.

05

Freshness follows cache TTL or explicit invalidation. No automatic change watcher or webhook endpoint is shipped; strict distributed invalidation needs coordinated writers.

06

Pagination is deterministic for unchanged data and scores. It does not provide a durable snapshot cursor over a changing dataset.

Build with Knowledge Gateway

Explore the code. Bring your knowledge sources.

Apache 2.0 · Reproducible local setup · Versioned API and validation docs

Open the project

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

Quickstart · shell
git clone https://github.com/karthikrameshdev/knowledge-gateway.git && cd knowledge-gateway && ./run.sh

Practical 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 , 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.

All projectsPython · FastAPI · ONNX Runtime · Qdrant · PostgreSQL · Redis · SSE