How sanjayss140-cloud/secure-rag-pipeline works
Mayandi AI is a web-based multimodal knowledge assistant. A user authenticates, uploads documents or images for extraction and indexing, then asks questions through the chat UI; the backend applies security checks, routes the question through retrieval and model reasoning, and returns responses with citations. Conversation history, document metadata, and usage metrics are persisted, while the admin UI exposes observability. The README documents hybrid intent routing, OCR, and heartbeat capabilities; some subsystem connections are therefore documented rather than directly shown in sampled code.
Main entry points: api.js API client · App.jsx Assistant interface · document_service.py Ingest and indexing · chat_service.py Conversation service
Components 27
Client experience
- Assistant interface
frontend/src/App.jsx - Chat and citations
frontend/src/components/ChatArea.jsx - Document drawer
frontend/src/components/DocumentDrawer.jsx - Admin dashboard
frontend/src/components/AdminDashboard.jsx - Session state
frontend/src/context/AuthContext.jsx - API client
frontend/src/services/api.js
API and security
- Chat endpoints
backend/api/chat_routes.py - Document endpoints
backend/api/document_routes.py - Authentication endpoints
backend/api/auth_routes.py - Admin endpoints
backend/api/admin_routes.py - JWT and roles
backend/security/auth.py - Prompt guardrail
backend/security/sanitizer.py - Rate limiting
backend/middleware/rate_limiter.py
Knowledge processing
- Ingest and indexing
backend/services/document_service.py - Vision and OCR
backend/rag/vision.py - Embedding and retrieval
retriever.py
Chat intelligence
- Conversation service
backend/services/chat_service.py - Intent and RAG agent
backend/rag/agent.py - Retrieval tools
backend/rag/tools.py - Language model client
llm.py
Persistence and operations
- Application database
backend/database/session.py - User and chat records
backend/database/models.py - Usage metrics
backend/services/usage_service.py - Document files and vectors
config.py - Keep-alive worker
backend/main.py
Other components
- User
- Groq model service
Connections 37
- User → Assistant interface: uses
- Assistant interface → Chat and citations: renders
frontend/src/App.jsx - Assistant interface → Document drawer: renders
frontend/src/App.jsx - Assistant interface → Admin dashboard: renders
frontend/src/App.jsx - Assistant interface → API client: requests
frontend/src/App.jsx - Session state → API client: requests auth
frontend/src/context/AuthContext.jsx - Chat and citations → API client: sends questions
- Document drawer → API client: uploads files
- Admin dashboard → API client: loads metrics
frontend/src/components/AdminDashboard.jsx - API client → Chat endpoints: calls chat API
- API client → Document endpoints: calls document API
- API client → Authentication endpoints: calls auth API
- Chat endpoints → Conversation service: delegates chat
backend/api/chat_routes.py - Chat endpoints → Rate limiting: applies limits
backend/api/chat_routes.py - Document endpoints → Ingest and indexing: delegates indexing
backend/api/document_routes.py - Document endpoints → Rate limiting: applies limits
backend/api/document_routes.py - Authentication endpoints → JWT and roles: uses credentials
backend/api/auth_routes.py - Admin endpoints → JWT and roles: checks roles
backend/api/admin_routes.py - Admin endpoints → Usage metrics: requests metrics
backend/api/admin_routes.py - Conversation service → Intent and RAG agent: processes questions
backend/services/chat_service.py - Conversation service → Prompt guardrail: checks prompts
backend/services/chat_service.py - Intent and RAG agent → Prompt guardrail: screens input
backend/rag/agent.py - Intent and RAG agent → Retrieval tools: invokes tools
backend/rag/agent.py - Intent and RAG agent → Language model client: requests generation
backend/rag/agent.py - Language model client → Groq model service: generates with
- Retrieval tools → Embedding and retrieval: retrieves chunks
backend/rag/tools.py - Ingest and indexing → Vision and OCR: analyzes images
backend/services/document_service.py - Ingest and indexing → Embedding and retrieval: updates index
backend/services/document_service.py - Ingest and indexing → Application database: stores metadata
backend/services/document_service.py - Embedding and retrieval → Application database: fallback reads
retriever.py - Embedding and retrieval → Document files and vectors: loads vector index
retriever.py - Ingest and indexing → Document files and vectors: stores uploads
backend/services/document_service.py - Application database → User and chat records: creates tables
backend/database/models.py - JWT and roles → Application database: queries users
backend/security/auth.py - Conversation service → User and chat records: persists conversations
backend/services/chat_service.py - Usage metrics → User and chat records: records usage
backend/services/usage_service.py - Keep-alive worker → Keep-alive worker: pings periodically
backend/main.py