How srimathib01/querynest--multidoc-chatbot- works
Project type and purpose
• This is a lightweight, single-page, full-stack “chatbot” application built with Streamlit for the UI and Python (LangChain) for the backend logic.
• Purpose: Let users upload multiple PDF documents, build a FAISS semantic-search index over their embeddings, then ask natural-language questions. Answers are generated by an LLaMA 3.1 model via the OpenRouter API, with source passages surfaced for transparency.
File structure
• Top-level files only (no separate “frontend” or “backend” folders).
• app.py – the single entry point implementing both UI and logic.
• requirements.txt – lists dependencies (Streamlit, LangChain, FAISS, OpenRouter client, etc.).
• faiss_index*, faiss_docstore.pkl – local persisted vector index & document store.
• No containerization or deployment scripts, so it runs locally or on Streamlit Cloud.
Key insights from README
• Technology stack: Streamlit UI, LangChain for orchestration, FAISS vector store, external LLM via OpenRouter.
• Workflow: upload → embedding & index build → semantic retrieval → LLM call → display responses + sources.
Main components
a. Streamlit User Interface
• Accepts PDF uploads, displays chat interface, shows source snippets.
b. Document Processing & Embedding
• PDF loader → text chunker → embedding model (e.g., OpenAI embeddings or local embedding model).
c. FAISS Vector Store + Docstore
• FAISS index holds embeddings; docstore (.pkl) maps index IDs back to original text.
d. Query Pipeline
• Semantic search against FAISS → top-k relevant chunks.
e. LLM Client & External Service
• Wrapper in app.py calling OpenRouter’s API endpoint for LLaMA 3.1.
f. Results Aggregator
• Formats the LLM’s answer and attaches source references for display.
Relationships & data flows
• User → Streamlit UI: file upload or question input.
• UI → Document Processor: on upload, text extraction & embedding.
• Processor → FAISS: write vectors, update index & docstore.
• UI (question) → Query Pipeline: embed question → search FAISS → retrieve chunks.
• Pipeline → OpenRouter API: send prompt + context → receive model answer.
• Pipeline → Results Aggregator → UI: show answer + source passages.
Architectural patterns & design principles
• Single-page application with model-view-controller semantics within app.py.
• Persistent vector store for session-independent retrieval.
• Clear separation between:
• State & storage (FAISS, .pkl files)
• Business logic (LangChain chains in Python)
• Presentation (Streamlit components)