How anuragthippani1/docflow-rag works
DocFlow is a document-grounded supply-chain intelligence product. Users upload PDFs, then ask questions and receive cited answers, evidence checks, domain risk assessments, and a combined recommendation. The graph shows the documented API/UI and sampled ingestion and evidence flows; several backend routes and frontend behaviors are documented in the README but their implementation excerpts were not provided, so those links are cited to the README.
Main entry points: main.py FastAPI routes · agent_router.py Agent dispatch · ingest.py PDF processing · pipeline.py Evidence preparation
Components 24
Document ingestion
- PDF processing
app/ingest.py - Entity extraction
app/entity_extractor.py
Evidence-grounded answers
- Conversational retrieval
app/rag_chat.py - Hybrid retrieval
app/retrievers/hybrid.py - Result reranking
app/retrievers/rerank.py - Evidence preparation
app/evidence/pipeline.py - Evidence verification
app/evidence/verify_openrouter.py - Answer generation
app/rag_chat.py
Supply-chain analysis
- Agent dispatch
app/agent_router.py - Supplier risk
app/agents/supplier_agent.py - Inventory risk
app/agents/inventory_agent.py - Logistics risk
app/agents/logistics_agent.py - External risk
app/agents/external_risk_agent.py - Final decision
app/agents/decision_agent.py
API and user experience
- Web interface
frontend/js/chat.js - Session dashboard
frontend/js/dashboard.js - FastAPI routes
app/main.py - Health and stats
app/status.py
Persistence and operations
- FAISS index
app/ingest.py - Knowledge graph
app/graph.py - Conversation history
app/conversations.py
Other components
- User
- External risk data
- OpenRouter models
Connections 25
- User → Web interface: asks or uploads
- Web interface → FastAPI routes: calls API
- FastAPI routes → PDF processing: processes uploads
app/main.py - PDF processing → FAISS index: indexes chunks
app/ingest.py - PDF processing → Entity extraction: extracts entities
app/ingest.py - PDF processing → Knowledge graph: upserts extraction
app/ingest.py - FastAPI routes → Evidence preparation: prepares query turn
app/main.py - Evidence preparation → Conversational retrieval: retrieves evidence
app/evidence/pipeline.py - Conversational retrieval → Hybrid retrieval: builds retriever
app/rag_chat.py - Hybrid retrieval → Result reranking: may rerank
app/retrievers/hybrid.py - Evidence preparation → Evidence verification: verifies pack
app/evidence/pipeline.py - Evidence verification → OpenRouter models: checks evidence
app/evidence/verify_openrouter.py - FastAPI routes → Answer generation: generates answer
app/main.py - Answer generation → OpenRouter models: generates response
- FastAPI routes → Conversation history: stores messages
app/main.py - FastAPI routes → Agent dispatch: dispatches analysis
app/main.py - Agent dispatch → Supplier risk: runs assessment
app/agent_router.py - Agent dispatch → Inventory risk: runs assessment
app/agent_router.py - Agent dispatch → Logistics risk: runs assessment
app/agent_router.py - Agent dispatch → External risk: runs assessment
app/agent_router.py - FastAPI routes → External risk data: fetches risk context
- External risk → External risk data: uses context
- Agent dispatch → Final decision: combines assessments
- FastAPI routes → Health and stats: serves status
app/main.py - FastAPI routes → Session dashboard: returns query stats