How ananddangwal/docmind-ai works
Document Copilot is an analyst-facing research assistant for querying SEC filings and receiving answers with citations. The user workflow runs from sign-in and chat through retrieval, answer generation, citation validation, and streamed display. A separate corpus workflow loads filing sources, structures and chunks documents, embeds them, then verifies and activates searchable generations. The graph includes these documented capabilities; unsampled modules are represented by their exact tree paths, and edges are limited to relationships shown in excerpts, the source index, or README.
Main entry points: orchestrator.py Turn Orchestrator · retriever.py Document Retrieval · session.py Supabase Postgres · chunk_and_embed.py Chunk and Embed
Components 29
Analyst Experience
- Research Interface
frontend/src/pages/research-page.tsx - Thread Chat
frontend/src/components/chat/ThreadChat.tsx - Citation Inspector
frontend/src/components/chat/SourceInspector.tsx - Sign-in
frontend/src/auth/auth-context.tsx
Chat Service
- Auth Endpoint
backend/app/auth/router.py - Chat API
backend/app/api/chat.py - Turn Orchestrator
backend/app/chat/orchestrator.py - Stream Formatting
backend/app/chat/streaming.py - Message Handling
backend/app/chat/messages.py
Research and Grounding
- Answer Agent
backend/app/assistant/agent.py - Agent Retrieval Tools
backend/app/assistant/deps.py - Document Retrieval
backend/app/retrieval/retriever.py - Search Queries
backend/app/retrieval/queries.py - Rank Fusion
backend/app/retrieval/fusion.py - Query Embeddings
backend/app/retrieval/embeddings.py - Citation Validation
backend/app/grounding/validator.py - Answer Schemas
backend/app/assistant/outputs.py
Corpus Ingestion
- Source Documents
backend/ingest/source_documents.py - Chunk and Embed
backend/ingest/chunk_and_embed.py - Filing Chunking
backend/ingest/chunking.py - SEC Structure
backend/ingest/sec_structure.py - Document Embeddings
backend/ingest/embeddings.py - Generation Verification
backend/ingest/verify.py - Generation Activation
backend/ingest/activate_generation.py
Persistent State
- Supabase Postgres
backend/app/database/session.py - Chat Persistence
backend/app/database/chats.py - Domain Models
backend/app/database/models
Other components
- Analyst
- Google Gemini
Connections 36
- Analyst → Sign-in: signs in
README.md - Analyst → Research Interface: asks questions
README.md - Research Interface → Thread Chat: opens chat
- Sign-in → Auth Endpoint: authenticates
- Thread Chat → Chat API: sends turns
README.md - Chat API → Turn Orchestrator: delegates turns
backend/app/api/chat.py - Chat API → Message Handling: handles messages
backend/app/api/chat.py - Chat API → Chat Persistence: loads threads
backend/app/api/chat.py - Turn Orchestrator → Document Retrieval: retrieves evidence
backend/app/chat/orchestrator.py - Turn Orchestrator → Answer Agent: runs analysis
- Turn Orchestrator → Chat Persistence: saves turns
backend/app/chat/orchestrator.py - Turn Orchestrator → Citation Validation: validates answers
backend/app/chat/orchestrator.py - Turn Orchestrator → Stream Formatting: streams response
backend/app/chat/orchestrator.py - Answer Agent → Agent Retrieval Tools: uses tools
backend/app/assistant/agent.py - Answer Agent → Google Gemini: generates answers
README.md - Agent Retrieval Tools → Document Retrieval: queries passages
backend/app/assistant/deps.py - Document Retrieval → Query Embeddings: embeds query
backend/app/retrieval/retriever.py - Document Retrieval → Search Queries: runs searches
backend/app/retrieval/retriever.py - Document Retrieval → Rank Fusion: fuses rankings
backend/app/retrieval/retriever.py - Document Retrieval → Supabase Postgres: reads chunks
backend/app/retrieval/retriever.py - Query Embeddings → Google Gemini: requests vectors
README.md - Citation Validation → Answer Schemas: validates schema
backend/app/grounding/validator.py - Citation Validation → Citation Inspector: provides citations
- Stream Formatting → Thread Chat: streams events
- Chat Persistence → Supabase Postgres: reads and writes
backend/app/database/chats.py - Chat Persistence → Domain Models: uses records
backend/app/database/chats.py - Chunk and Embed → Source Documents: synchronizes filings
backend/ingest/chunk_and_embed.py - Chunk and Embed → Filing Chunking: creates chunks
backend/ingest/chunk_and_embed.py - Filing Chunking → SEC Structure: uses structure
backend/ingest/chunking.py - Chunk and Embed → Document Embeddings: embeds chunks
backend/ingest/chunk_and_embed.py - Document Embeddings → Google Gemini: requests vectors
backend/ingest/embeddings.py - Chunk and Embed → Supabase Postgres: stores corpus
backend/ingest/chunk_and_embed.py - Generation Verification → Supabase Postgres: checks generation
- Generation Activation → Supabase Postgres: activates generation
- Generation Verification → Generation Activation: precedes activation
README.md - Domain Models → Supabase Postgres: defines records