DepthAPI is a local-first retrieval-augmented generation (RAG) engine. PostgreSQL with pgvector is the datastore for documents, chunks, embeddings, and full-text search, with Redis for transient query caching and token quotas.
- Document Ingestion (
POST /api/ingest,POST /api/ingest/file): Raw text/Markdown ingestion plus multipart file uploads (PDF, DOCX, XLSX, PPTX, CSV, HTML, Markdown) converted to Markdown viamarkitdown, with a 75 MB payload limit and content-hash idempotency. - Hybrid Retrieval: Dense cosine similarity (
dense_search_v5) with hybrid dense + lexical Reciprocal Rank Fusion (hybrid_search_v5,hybrid_search_v6) and optional concept-graph expansion (hybrid_search_with_graph_v5). - Negative Query Algebra: Parses negation syntax (
NOT term,-term,without term) and downweights matching candidates. - Cognitive Depth (Levels 1–5):
- Depths 1–2: Direct concept summaries from
knowledge_concepts. - Depths 3–4: Dense-first semantic search with hybrid RRF fallback and intent-based 1-hop graph expansion.
- Depth 5: Forced reranking (
BAAI/bge-reranker-basewhensentence-transformersis installed) and U-shaped Lost-in-the-Middle context ordering.
- Depths 1–2: Direct concept summaries from
- Explainability & Streaming:
explain: truereturns retrieval scoring and chunk provenance;POST /api/query/streamstreams Server-Sent Events (SSE).
docker compose up -dDatabase migrations in db/migrations/ (001–006) and the dev API key seed (db/seed/001_dev_api_key.sql) are mounted automatically.
pip install -e ".[dev]"
python -m uvicorn api.main:app --reload --port 8000All endpoints except /api/health require Authorization: Bearer <api-key>. Default local dev key: sk-depth-dev-local-0000000000000000.
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET |
Service liveness probe |
/api/ingest |
POST |
Store raw markdown or text document and compute embeddings |
/api/ingest/file |
POST |
Multipart file upload converted via markitdown |
/api/query |
POST |
Hybrid retrieval with cognitive depth (1–5), negative algebra, and explainability |
/api/query/stream |
POST |
Server-Sent Events (SSE) streaming completion |
curl -X POST http://localhost:8000/api/ingest \
-H 'Authorization: Bearer sk-depth-dev-local-0000000000000000' \
-H 'Content-Type: application/json' \
-d '{
"collection_name": "docs",
"filename": "intro.md",
"raw_text": "DepthAPI stores searchable knowledge locally."
}'curl -X POST http://localhost:8000/api/ingest/file \
-H 'Authorization: Bearer sk-depth-dev-local-0000000000000000' \
-F 'file=@handbook.pdf' \
-F 'collection_name=docs'curl -X POST http://localhost:8000/api/query \
-H 'Authorization: Bearer sk-depth-dev-local-0000000000000000' \
-H 'Content-Type: application/json' \
-d '{
"query": "FastAPI authentication NOT oauth2",
"depth": 3,
"explain": true
}' Client / Agent ──(Bearer Auth)──▶ FastAPI (api.main:app)
├── Redis (query cache / token quotas)
└── PostgreSQL + pgvector
docker build -f api/Dockerfile -t depthapi:latest .pytest -q
ruff check api tests
python -m compileall -q api tests evaluation scripts