A cross-repository knowledge base engine with Agentic RAG capabilities for code, Markdown, and JSON.
Deep Engine is an advanced knowledge base system designed for development teams, supporting:
- Cross-Repository Querying: Search and reason across multiple codebases simultaneously
- Heterogeneous Data: Unified handling of code (Python, JavaScript, Go), Markdown documentation, and JSON configurations
- Agentic RAG: Intelligent query routing and planning with LangGraph
- Hybrid Retrieval: Combines vector search (Qdrant) and graph traversal (Neo4j) with RRF fusion
- Low Latency: Sub-800ms P95 query latency with intelligent query routing
- Fine-Grained Permissions: Repository-level access control with OpenFGA (optional)
ββββββββββββββββββββββββ
β Frontend Layer β VS Code Plugin / Web UI
β (TypeScript) β
ββββββββββββ¬ββββββββββββ
β gRPC/HTTP
ββββββββββββΌββββββββββββ
β API Gateway β FastAPI + OpenFGA
β (Python) β
ββββββββββββ¬ββββββββββββ
β gRPC
ββββββββββββΌββββββββββββ
β Agentic Orchestratorβ LangGraph Workflow
β (Python) β Router β Planner β Retriever β ReRanker β Generator
ββββββββββββ¬ββββββββββββ
β gRPC/Driver
ββββββββββββΌββββββββββββββββββββββββ
β Storage Layer β
β ββ Qdrant (Vector Database) β Dense + Sparse Vectors
β ββ Neo4j (Graph Database) β Code Relationships
ββββββββββββ¬ββββββββββββββββββββββββ
β File/Event
ββββββββββββΌββββββββββββββββββββββββ
β Ingestion Pipeline β
β ββ Tree-sitter (Code Parsing) β
β ββ unified (Markdown Parsing) β
β ββ JSON Parser β
ββββββββββββββββββββββββββββββββββββ
- Python 3.10+
- Docker & Docker Compose (for local development)
- OpenAI API Key (for embeddings)
git clone https://github.com/your-org/deep-engine.git
cd deep-engine# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -e ".[dev]"cp .env.example .env
# Edit .env and set your OPENAI_API_KEY# Start Qdrant and Neo4j
docker-compose up -d
# Wait for services to be healthy
docker-compose pspython -m deep_engine.scripts.init_storageuvicorn deep_engine.api.main:app --host 0.0.0.0 --port 8000 --reloadVisit http://localhost:8000/docs for the interactive API documentation.
All data (code, docs, JSON) is transformed into a unified StructuredNode:
{
"node_id": "org/repo/path/to/file.py#abc123",
"repo_id": "org/repo",
"file_path": "path/to/file.py",
"node_type": "function",
"content": "def authenticate(user, password):",
"metadata": {
"language": "python",
"line_start": 42,
"line_end": 56
},
"relations": [
{"type": "CALLS", "target": "org/repo/utils.py#validate"}
],
"embedding_dense": [...], # 384-dim vector
"embedding_sparse": {...} # Token IDs β weights
}Reciprocal Rank Fusion (RRF) combines three retrieval sources:
- Dense Vector Search: Semantic similarity (Cosine)
- Sparse Vector Search: Keyword matching (IDF-weighted)
- Graph Traversal: Relationship-based navigation
# RRF Formula
score(node) = Ξ£(1 / (k + rank_i)) # k=60, across all sourcesgraph TD
Start([User Query]) --> Router{Router<br/>Simple or Complex?}
Router -->|Simple| Retriever[Direct Retrieval]
Router -->|Complex| Planner[Query Planner]
Planner --> SubTasks[Parallel SubTask Execution]
SubTasks --> Retriever
Retriever --> ReRanker[Cross-Encoder ReRanker]
ReRanker --> Generator[Answer Generator]
Generator --> End([Response with Citations])
from deep_engine.ingestion.pipeline import IngestionPipeline
pipeline = IngestionPipeline()
await pipeline.ingest_repository(
repo_id="my-org/backend-api",
repo_path="/path/to/repo",
file_patterns=["**/*.py", "**/*.md", "**/*.json"]
)from deep_engine.api.client import DeepEngineClient
client = DeepEngineClient(api_url="http://localhost:8000")
response = await client.query(
query="Find all authentication functions that use UserSchema",
repo_ids=["my-org/backend-api"],
top_k=10
)
print(response.answer)
for citation in response.sources:
print(f" β {citation.file_path}:{citation.line_start}")# Query endpoint
curl -X POST http://localhost:8000/query \
-H "Content-Type: application/json" \
-d '{
"query": "How does authentication work?",
"repo_ids": ["my-org/backend-api"],
"top_k": 10
}'
# Health check
curl http://localhost:8000/healthdeep-engine/
βββ deep_engine/
β βββ api/ # FastAPI application
β βββ ingestion/ # Data ingestion pipeline
β β βββ parsers/ # Code, Markdown, JSON parsers
β β βββ chunking/ # Semantic chunking
β β βββ embedding/ # Vector generation
β βββ storage/ # Storage layer
β β βββ vector/ # Qdrant client
β β βββ graph/ # Neo4j client
β βββ retrieval/ # Hybrid retrieval
β βββ orchestrator/ # Agentic workflow
β β βββ agents/ # Router, Planner, Generator
β β βββ tools/ # Retrieval tools
β βββ models/ # Pydantic schemas
β βββ config/ # Configuration
β βββ utils/ # Logging, metrics
βββ tests/ # Unit and integration tests
βββ docker-compose.yml # Local development stack
βββ pyproject.toml # Python dependencies
βββ README.md
# Run all tests
pytest
# Run with coverage
pytest --cov=deep_engine --cov-report=html
# Run specific test file
pytest tests/unit/test_retrieval.py# Format code
black deep_engine/
# Lint code
ruff check deep_engine/
# Type checking
mypy deep_engine/- Query latency (P50, P95, P99)
- Retrieval performance by type
- Ingestion throughput
- Storage operation metrics
Start monitoring stack:
docker-compose --profile monitoring up -d- Prometheus: http://localhost:9091
- Grafana: http://localhost:3001 (admin/admin)
Logs are emitted in JSON format by default:
{
"timestamp": "2024-12-13T10:30:45.123Z",
"level": "info",
"event": "query_completed",
"query": "How does auth work?",
"latency_ms": 245,
"results_count": 10
}Enable fine-grained authorization:
# Start with OpenFGA
docker-compose --profile with-openfga up -d
# Configure in .env
OPENFGA_API_URL=http://localhost:8080
OPENFGA_STORE_ID=your-store-id
OPENFGA_AUTH_MODEL_ID=your-model-idAuthorization model:
type user
type repo
relations
define reader: [user]
define writer: [user]
| Metric | Target | Actual (Local) |
|---|---|---|
| Query Latency (P50) | < 300ms | ~250ms |
| Query Latency (P95) | < 800ms | ~650ms |
| Ingestion Throughput | > 10 files/sec | ~15 files/sec |
| Supported Repos | 1000+ | Tested up to 100 |
- Core data models
- Qdrant + Neo4j storage
- Hybrid retrieval with RRF
- Basic API gateway
- Docker Compose setup
- Code parser (Tree-sitter for Python, JS/TS)
- Markdown parser with enhanced metadata
- JSON parser with JSONPath and schema support
- Agentic orchestrator (LangGraph workflow)
- Router agent (simple/complex classification)
- Planner agent (LLM-powered decomposition)
- Retrieval manager (parallel execution)
- Generator agent (GPT-3.5 synthesis)
- VS Code plugin (deferred to future release)
- Cross-encoder reranking (20-30% precision improvement)
- Incremental indexing (content-hash based)
- Query caching (Redis with TTL)
- Multi-modal support (images, diagrams) (planned)
- OpenFGA integration for fine-grained authorization
- Horizontal scaling configuration
- Advanced monitoring (OpenTelemetry tracing)
- Enterprise SSO (SAML/OAuth)
Completion: 75% of roadmap features (7/14 major tasks)
Next Priority: Testing suite, VS Code plugin, multi-modal support
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Qdrant - High-performance vector database
- Neo4j - Graph database platform
- LangGraph - Agentic workflow framework
- LlamaIndex - Data framework for LLM applications
- Tree-sitter - Incremental parsing system
- Project Maintainer: Deep Engine Team
- Email: team@deep-engine.dev
- Issue Tracker: https://github.com/your-org/deep-engine/issues
Built with β€οΈ for developers who love knowledge