How tabesink/tg-context-engine works
Context Engine is an authenticated document workbench: users upload documents into managed LightRAG Domains, then chat against domain knowledge and browse source documents and graph structure. Document processing creates structured source chunks for indexing and citation; retrieval can combine semantic results with local document navigation, while chat synthesis grounds the response. The client also exposes domain management, library, and graph inspection. TrustGraph is an optional structural-retrieval attachment. The graph emphasizes documented product capabilities and sampled runtime relationships; several route-to-service connections are inferred from the repository’s module responsibilities rather than inspected route bodies.
Main entry points: layout.tsx Next.js workbench · retrieval_service.py Retrieval coordinator · document_ingestion_coordinator.py Upload and ingestion · lightrag_ingestion_service.py Domain indexing
Components 21
Web workbench
- Next.js workbench
client/src/app/layout.tsx - Chat experience
client/src/components/chat/LightRagChatShell.tsx - Document library
client/src/features/documents/DocumentRoute.tsx - Graph viewer
client/src/features/graph/GraphViewer.tsx
Backend workflows
- Authentication API
app/api/routes/auth.py - Document API
app/api/routes/documents.py - Chat API
app/api/routes/chat_query.py - Retrieval API
app/api/routes/retrieve.py - Domain management
app/services/lightrag_domain_view_service.py - Application database
app/storage/db.py
Document ingestion
- Upload and ingestion
app/services/document_ingestion_coordinator.py - Structure and chunks
app/document_processing/pipeline.py - Domain indexing
app/services/lightrag_ingestion_service.py
Retrieval and chat
- Retrieval coordinator
app/services/retrieval_service.py - Source navigation
app/retrieval/rich_navigation_engine.py - Answer synthesis
app/chat_synthesis/orchestrator.py - Chat turn service
app/services/chat_turn_service.py
Knowledge backends
- LightRAG Domain
app/integrations/lightrag_remote_adapter.py - TrustGraph engine
app/retrieval/trustgraph_engine.py - TrustGraph service
app/integrations/trustgraph_remote_adapter.py
Other components
- Workspace user
Connections 24
- Workspace user → Next.js workbench: uses
- Next.js workbench → Authentication API: signs in
- Next.js workbench → Document API: uploads files
- Next.js workbench → Chat API: asks questions
- Next.js workbench → Retrieval API: requests evidence
- Next.js workbench → Domain management: manages domains
- Next.js workbench → Graph viewer: inspects graph
- Next.js workbench → Document library: browses sources
- Document API → Upload and ingestion: coordinates ingest
- Upload and ingestion → Structure and chunks: parses documents
- Upload and ingestion → Domain indexing: submits chunks
- Domain indexing → LightRAG Domain: indexes chunks
- Domain indexing → TrustGraph service: pushes chunks
- Retrieval API → Retrieval coordinator: retrieves evidence
- Retrieval coordinator → Source navigation: searches sources
- Retrieval coordinator → LightRAG Domain: queries domain
- Retrieval coordinator → TrustGraph engine: routes structural search
- TrustGraph engine → TrustGraph service: queries graph
- Chat API → Chat turn service: runs turn
- Chat turn service → Retrieval coordinator: gathers evidence
- Chat turn service → Answer synthesis: composes answer
- Retrieval coordinator → Application database: reads source structure
- Upload and ingestion → Application database: records documents
- Graph viewer → LightRAG Domain: loads graph data