How robayedl/documind works
DocuMind is a multi-tenant document intelligence product: users upload PDFs or DOCX files, which are parsed and indexed asynchronously, then ask questions answered with hybrid retrieval and a revisable multi-agent RAG workflow. The graph also preserves documented MCP access, usage tracking, caching, and privacy/auth capabilities. Some relationships come from README architecture statements and the source index; unsampled implementations are represented at their known source paths, without inferring their internal call details.
Main entry points: main.py FastAPI service · researcher.py Research and tool use · retrieval.py Hybrid retrieval and HyDE · tasks.py Ingestion task
Components 26
Web client
- Chat interface
web/app/chat/ChatClient.tsx - API client
web/lib/api.ts
API and tenancy
- FastAPI service
app/main.py - Clerk authentication
app/auth.py - PII redaction
app/redact.py - Semantic cache
rag/cache.py - PostgreSQL and pgvector
app/db.py
Document ingestion
- Ingestion task
worker/tasks.py - Celery queue
worker/celery_app.py - Document parsing and indexing
rag/ingest.py - Chunk contextualization
rag/contextualize.py - Uploaded-file storage
app/storage.py
RAG answering
- Agent supervisor graph
rag/agents/graph.py - Research and tool use
rag/agents/researcher.py - Hybrid retrieval and HyDE
rag/chains/retrieval.py - Cross-encoder reranking
rag/chains/rerank.py - Chunk and vector store
rag/store.py - Answer synthesis
rag/agents/synthesizer.py - Answer critique
rag/agents/critic.py - Search and calculator tools
rag/tools - Gemini and embeddings
rag/llm.py
Integrations and usage
- MCP document tools
mcp_server/server.py - API-key validation
mcp_server/auth.py - Token and cost usage
rag/usage.py
Other components
- User
- LLM and search providers
Connections 28
- User → Chat interface: asks questions
- Chat interface → API client: sends requests
web/app/chat/ChatClient.tsx - API client → FastAPI service: calls API
- FastAPI service → Clerk authentication: validates users
app/main.py - FastAPI service → PII redaction: redacts queries
app/main.py - FastAPI service → Semantic cache: checks responses
app/main.py - FastAPI service → Agent supervisor graph: runs agent graph
app/main.py - Agent supervisor graph → Research and tool use: dispatches research
- Research and tool use → Hybrid retrieval and HyDE: retrieves passages
rag/agents/researcher.py - Hybrid retrieval and HyDE → Chunk and vector store: searches chunks
rag/chains/retrieval.py - Hybrid retrieval and HyDE → Cross-encoder reranking: reranks candidates
rag/chains/retrieval.py - Research and tool use → Search and calculator tools: calls selected tools
rag/agents/researcher.py - Research and tool use → Answer synthesis: provides research
- Answer synthesis → Answer critique: submits draft
- Answer critique → Answer synthesis: requests revision
- FastAPI service → Ingestion task: queues ingestion
app/main.py - Ingestion task → Celery queue: runs as task
worker/tasks.py - Ingestion task → Document parsing and indexing: indexes documents
worker/tasks.py - Document parsing and indexing → Chunk contextualization: contextualizes chunks
rag/ingest.py - Document parsing and indexing → Chunk and vector store: writes indexed chunks
rag/ingest.py - FastAPI service → Uploaded-file storage: saves uploads
app/main.py - FastAPI service → PostgreSQL and pgvector: persists metadata
app/main.py - Chunk and vector store → PostgreSQL and pgvector: reads and writes vectors
rag/store.py - MCP document tools → API-key validation: validates API keys
mcp_server/server.py - MCP document tools → Hybrid retrieval and HyDE: searches documents
mcp_server/server.py - Agent supervisor graph → Token and cost usage: tracks usage
rag/agents/graph.py - Gemini and embeddings → LLM and search providers: invokes Gemini
rag/llm.py - Search and calculator tools → LLM and search providers: uses web search