Context Engine is an open-source structured context infrastructure for AI systems. It extracts structured facts from documents, organizes them into semantic models, and surfaces relationships as a living knowledge graph.
Company knowledge is scattered across Slack, Notion, Zoom transcripts, GitHub issues, meeting notes, and local documents. Traditional RAG gives you retrieval, but it doesn't answer:
- Where did this answer come from?
- Is this still true?
- What changed?
- How does pricing relate to features?
Context Engine's philosophy: facts should be structured, answers should cite sources, and relationships should be visible—not silently averaged away.
| Layer | Technology |
|---|---|
| Framework | FastAPI (async Python 3.12+) |
| ORM | SQLAlchemy 2.0 |
| Database | SQLite (default), optional PostgreSQL + pgvector |
| LLM Gateway | LiteLLM (OpenAI, Anthropic, etc.) |
| Embeddings | LiteLLM or local HashingEmbedder (tests/offline) |
| Build | Hatchling |
| CLI | ctxe |
| Layer | Technology |
|---|---|
| Framework | React 18 |
| Build Tool | Vite |
| Styling | Tailwind CSS |
| Graph Viz | Cytoscape.js |
| Routing | React Router DOM v6 |
- Single Docker container (Python 3.12 slim + pre-built frontend)
- SQLite default, PostgreSQL optional
- No Redis, no Celery, no worker processes
- Memory footprint: ~150MB RAM idle
6 tables:
- SourceDocument — Raw ingested content with metadata
- Model — Product domain (Pricing, Features, Roadmap, Decisions)
- Component — Atomic structured fact with confidence, status, embedding
- Relationship — Typed edge between components
- Connector — Catalogued or configured ingestion surface
- SyncJob — Connector sync attempt and status record
- Ingest document via API or CLI
- Extract structured facts (LLM or regex fallback)
- Create/update Model and Component records
- Batch embed new components
- Create Relationship edges from extracted links
- Query via semantic search + graph traversal
3 frontend views:
- Graph Explorer — Visual knowledge graph with models, components, and relationships
- Ask (Query) — Natural language query with cited components and sources
- Source Manager — Upload, browse, and inspect source documents
# One-command start
ctxe serve
# Ingest
ctxe ingest ./docs/
# Query
ctxe query "What is our pricing?"
# MCP server
ctxe mcp- Graph-first — Relationships are first-class, not afterthoughts
- Self-host first — Single container, zero external dependencies by default
- Minimal but impactful — 6 tables, focused views, 1 process
- Source-backed — Every fact links to its origin document
- MCP-native — Built-in Model Context Protocol server for AI assistants
Stable:
- Docker-based self-hosting
- Local document import
- Source-backed query API
- Knowledge graph visualization
- MCP server mode
app/
api/ FastAPI routes (sources, graph, query)
cli/ CLI commands (ingest, query, graph, mcp)
models.py SQLAlchemy data model
processing/ Extraction, embeddings
services/ Ingest, query
mcp/ MCP server implementation
frontend/ React 3-view app
tests/ Backend tests