How ermihageez/rag works
eTech RAG is a local-first B2B sales and marketing application. A user query enters through the API or copilot, is routed through a LangGraph agent workflow for lead discovery, tender scoring and knowledge retrieval, then produces sales intelligence and a draft for approval and optional n8n delivery. The repository also documents document RAG, conversational sales, marketing, MCP tools and an ML training pipeline. Arrows cite the README or indexed source references; unsampled subsystem internals and some runtime wiring are represented only where documented.
Main entry points: graph.py LangGraph workflow · api.py FastAPI service · retriever.py RAG retrieval · llm.py LLM integration
Components 28
User interfaces
- React dashboard
ui/src/App.tsx - FastAPI service
src/api.py - Copilot routes
src/copilot/routes.py
Sales agent workflow
- LangGraph workflow
src/agents/graph.py - Supervisor
src/agents/supervisor/supervisor.py - Lead discovery
src/agents/lead/lead_agent.py - Tender scoring
src/agents/tender/tender_agent.py - Knowledge agent
src/agents/knowledge/knowledge_agent.py - Sales intelligence
src/agents/sales_intelligence/sales_agent.py - Content drafting
src/agents/content/content_agent.py - Approval gate
src/agents/approval/approval_agent.py
Knowledge retrieval
- Document loading
src/rag/data_loader.py - OCR fallback
src/ocr_loader.py - Chunk and embed
src/rag/embedding.py - FAISS index
src/rag/vectorstore.py - RAG retrieval
src/rag/retriever.py
Sales and marketing
- Sales assistant
src/sales_assistant/engine.py - Marketing pipeline
src/marketing
Data and integrations
- MCP tools
mcp_server/tools - Conversation memory
src/memory/postgres_memory.py - Evaluation framework
src/evaluation - ML training pipeline
app/ml/pipeline.py - Training event sink
app/ml/training_sink.py - Pipeline metrics
app/ml/metrics.py - LLM integration
src/agents/llm.py
Other components
- Sales user
- Ollama
- n8n delivery
Connections 32
- Sales user → React dashboard: uses
- React dashboard → FastAPI service: requests
- Sales user → FastAPI service: submits query
README.md - FastAPI service → LangGraph workflow: runs agents
src/api.py - Copilot routes → LangGraph workflow: builds and runs
src/copilot/routes.py - LangGraph workflow → Supervisor: routes
src/agents/graph.py - LangGraph workflow → Lead discovery: dispatches
src/agents/graph.py - LangGraph workflow → Tender scoring: dispatches
src/agents/graph.py - LangGraph workflow → Knowledge agent: dispatches
src/agents/graph.py - LangGraph workflow → Sales intelligence: dispatches
src/agents/graph.py - LangGraph workflow → Content drafting: dispatches
src/agents/graph.py - LangGraph workflow → Approval gate: dispatches
src/agents/graph.py - Lead discovery → MCP tools: searches leads
README.md - Tender scoring → MCP tools: fetches tenders
README.md - Knowledge agent → RAG retrieval: retrieves context
- RAG retrieval → FAISS index: queries
src/rag/retriever.py - RAG retrieval → Chunk and embed: via index query
- Document loading → OCR fallback: uses fallback
src/rag/data_loader.py - FAISS index → Chunk and embed: embeds documents
src/rag/vectorstore.py - FastAPI service → Sales assistant: serves sales flow
src/api.py - FastAPI service → Marketing pipeline: serves marketing
src/api.py - FastAPI service → RAG retrieval: serves RAG
src/api.py - LangGraph workflow → Conversation memory: uses memory
src/agents/graph.py - Content drafting → LLM integration: generates drafts
- LLM integration → Ollama: infers locally
README.md - FastAPI service → n8n delivery: delivers payload
README.md - ML training pipeline → Evaluation framework: evaluates models
app/ml/pipeline.py - ML training pipeline → Training event sink: builds from events
- ML training pipeline → Pipeline metrics: reports metrics
- FastAPI service → Training event sink: records events
src/api.py - LLM integration → Pipeline metrics: increments counters
src/agents/llm.py - Chunk and embed → LLM integration: loads embedding model
src/rag/embedding.py