How mehmetaliguda/rag_web works
This is a multi-PDF RAG chat application: users upload PDFs into isolated rooms, then ask room-scoped questions and receive cited answers. The frontend handles room selection and chat presentation; Flask manages uploads, room lookup, chat requests, and citation URLs. The RAG engine chunks and indexes PDFs, optimizes questions, retrieves and ranks context, and produces answers. Source excerpts are partial, so some internal method wiring and optional behavior are not shown; the graph omits those uncertain links.
Main entry points: app.py Flask API · rag_chat.py Room RAG engine · chat-client.tsx Chat client · page.tsx Document library
Components 15
Web interface
- Document library
app/page.tsx - Room page
app/chat/[roomId]/page.tsx - Chat client
app/components/chat-client.tsx - Message and citations
app/components/chat-message.tsx
API and rooms
- Flask API
backend/app.py - Room manager
backend/rag_chat.py - PDF and page images
backend/app.py
RAG processing
- Room RAG engine
backend/rag_chat.py - Query optimizer
backend/query_optimizer.py - Hybrid retrieval
backend/hybrid_retriever.py
Document state
- Chroma store
chroma_db - Room files and indexes
rag_rooms
Other components
- User
- Ollama models
- Uploaded PDF
Connections 25
- User → Document library: selects or uploads
- Document library → Flask API: lists rooms / uploads PDF
- Flask API → Room manager: creates or lists rooms
- Uploaded PDF → Flask API: upload
- Room manager → Room RAG engine: creates room engine
- Room RAG engine → Room files and indexes: stores room data
- Room RAG engine → Chroma store: persists embeddings
- Document library → Room page: opens room
- Room page → Chat client: renders
- User → Chat client: asks question
- Chat client → Flask API: posts question
- Flask API → Room manager: looks up room
- Room manager → Room RAG engine: returns room engine
- Room RAG engine → Query optimizer: optimizes query
- Query optimizer → Ollama models: expands query
- Room RAG engine → Hybrid retrieval: retrieves and ranks
- Hybrid retrieval → Chroma store: searches vectors
- Hybrid retrieval → Ollama models: embeds query
- Room RAG engine → Ollama models: generates answer
- Flask API → PDF and page images: builds citation URLs
- Flask API → Room manager: resolves citation room
- PDF and page images → Room files and indexes: serves PDF or images
- Flask API → Chat client: returns answer and citations
- Chat client → Message and citations: renders messages
- Message and citations → PDF and page images: opens cited sources