How shangxunhang/enterprise-rag-agent works
Enterprise RAG-Agent is a modular application for turning standardized project inputs into evidence-grounded, sectioned business documents. Its main path is input normalization, task/workflow setup, Supervisor execution, section generation with scoped retrieval, and validated deliverable output. Separate subsystems provide model access, context budgeting, workflow state, and operational trace/data capture; evaluation is another documented capability. Relationships are shown where the excerpts, SOURCE INDEX, or README support them; some README-described capabilities have no sampled implementation details.
Main entry points: mainline_service.py Mainline service · stage_service.py Scheme writer · rag_service.py RAG service · call_boundary.py Model gateway
Components 25
Application flow
- Mainline service
backend/application/mainline_service.py - Input normalization
backend/apps/enterprise_document/services/project_input_normalization/use_case.py - Project input schema
backend/apps/enterprise_document/schemas/project_input_schema.py - Task lifecycle
backend/task/task_manager.py - Supervisor agent
backend/agent/supervisor_agent.py - Workflow router
backend/agent/services/workflow_router.py
Document generation
- Scheme workflow
backend/apps/enterprise_document/workflows/scheme_generation.py - Scheme writer
backend/apps/enterprise_document/services/scheme_writer/stage_service.py - Document validation
backend/apps/enterprise_document/services/document_gate.py
RAG retrieval
- RAG service
backend/rag/services/rag_service.py - Retrieval runtime
backend/rag/runtime/retrieval_runtime.py - Parent-child engine
backend/rag/rag_engine/parent_child_rag_engine.py - Retrieval components
backend/rag/retriever - Evidence contract
backend/rag/evidence/contract.py
Runtime services
- Workflow engine
backend/agent/runtime/langgraph_workflow_engine.py - Workflow schema
backend/agent/runtime/workflow_schema.py - Context manager
backend/context_manager/manager.py - Model gateway
backend/model_gateway/call_boundary.py - Model clients
backend/model_gateway/local_qwen_client.py - Model contract
backend/contracts/model_gateway.py - Shared schemas
backend/schemas - Core runtime controls
backend/core/runtime
Operations and evaluation
- Trace and capture
backend/data_capture/run_trace_recorder.py - Evaluation
backend/eval/rag/engine/eval_runner.py
Other components
- Project submitter
Connections 26
- Project submitter → Mainline service: submits input
README.md - Mainline service → Input normalization: normalizes input
- Mainline service → Task lifecycle: creates task
backend/application/mainline_service.py - Mainline service → Scheme workflow: builds workflow
backend/application/mainline_service.py - Mainline service → Supervisor agent: runs task
backend/application/mainline_service.py - Input normalization → Project input schema: produces input
- Supervisor agent → Workflow router: routes workflow
backend/agent/services/workflow_router.py - Workflow router → Workflow schema: uses workflow definition
backend/agent/services/workflow_router.py - Workflow engine → Workflow schema: executes steps
backend/agent/runtime/langgraph_workflow_engine.py - Workflow engine → Shared schemas: updates graph state
backend/agent/runtime/langgraph_workflow_engine.py - Workflow engine → Core runtime controls: controls execution
backend/agent/runtime/langgraph_workflow_engine.py - Scheme workflow → Scheme writer: runs generation
- Scheme writer → RAG service: retrieves evidence
- Scheme writer → Document validation: validates output
- RAG service → Retrieval runtime: retrieves
backend/rag/services/rag_service.py - Retrieval runtime → Parent-child engine: runs pipeline
- Parent-child engine → Retrieval components: uses retrieval ports
backend/rag/rag_engine/parent_child_rag_engine.py - RAG service → Evidence contract: returns evidence
- Scheme writer → Context manager: budgets context
- RAG service → Model gateway: uses model boundary
backend/rag/services/rag_service.py - Model gateway → Model contract: implements port
backend/model_gateway/call_boundary.py - Model gateway → Model clients: invokes client
- Model gateway → Shared schemas: exchanges model schemas
backend/model_gateway/call_boundary.py - Mainline service → Trace and capture: captures run data
- Parent-child engine → Trace and capture: records retrieval
backend/rag/rag_engine/parent_child_rag_engine.py - Evaluation → Trace and capture: evaluates captures