How ysnhdn/assistdoc works
Project type and purpose
• AssistDoc is a full-stack, RAG-powered document assistant built with Streamlit. Its purpose is to let users upload PDF/DOCX/TXT files, automatically index and embed their contents, then interact via question-answering, summarization, or structured-data extraction using LLMs (GitHub Inference, Hugging Face, etc.) and a local vector store (FAISS/ChromaDB).
File structure
• Top-level:
• app.py – Streamlit entry point and router
• .streamlit/ – config & setup scripts
• scripts/index_documents.py – batch indexing utility
• Dockerfile, setup.py, requirements.txt
• data/ – JSON registry + persistent vector_store & uploaded_files (in README)
• src/:
• document_processor/ (parser → chunker → embedder)
• vector_db/ (store.py ↔ Faiss/ChromaDB, retriever.py)
• llm/ (models.py, prompts.py, chain.py)
• agents/ (high-level orchestrators: qa_agent, summary_agent, extraction_agent)
• utils/ (helpers, API/session utilities)
• ui/:
• pages/ (home, qa, summary, extraction)
• components/ (sidebar upload, visualization, document selector)
• models/: pre-downloaded sentence-transformers model files
• test/: unit tests for core modules
Key architecture insights from README
• Streamlit front end drives interaction
• Persistent storage of source docs + vector store between sessions
• Seamless switch between multiple LLM providers
• RAG pipeline: upload → parse → chunk → embed → store → retrieve → LLM chain
Main components
a. User Interface (Streamlit)
• app.py orchestrates pages & sidebar
• ui/pages and ui/components render controls and results
b. Document Processing Pipeline
• parser: extract text from PDF/DOCX/TXT
• chunker: split text into manageable chunks
• embedder: call sentence-transformers to generate embeddings
c. Vector Database
• store.py: create/manage FAISS or ChromaDB index on disk
• retriever.py: semantic search for top-K chunks
• data/documents_registry.json: metadata registry
d. LLM Layer
• chain.py: orchestrates prompt templates + retrieved context
• prompts.py: templates for QA, summarization, extraction
• models.py: config for providers (GitHub, OpenAI, etc.)
• External API: GitHub Inference / Hugging Face / OpenAI endpoints
e. Agents
• qa_agent, summary_agent, extraction_agent: high-level wrappers that call retriever + chain
f. Persistent Data Store
• data/uploaded_files – raw docs
• vector_store – serialized FAISS/ChromaDB index
Relationships & interactions
1. User uploads document via Streamlit UI →
2. document_processor.parser → chunker → embedder → vector_db.store → update registry
3. User selects action (QA/Summary/Extraction) → UI calls corresponding agent
4. Agent calls vector_db.retriever to fetch top-K embeddings + chunks
5. Agent calls llm.chain with chunks + prompt → External LLM API or local model
6. llm.chain returns result → UI displays with visualization components
Architectural patterns and design principles
• Modular pipeline: clear separation of parsing, chunking, embedding
• Adapter pattern: vector_db abstracts FAISS vs. ChromaDB, llm/models.py abstracts different providers
• Agent orchestration: high-level agents hide complexity from UI
• Persistence layer: registry JSON + on-disk vector store ensure stateful sessions
Elements
• Clear labels: e.g., “Parser”, “Chunker”, “Embedder”, “Agent: QA”
• Upload → Parser → Chunker → Embedder → Store
• UI → Agent → Retriever → LLM Chain → UI
• UI components (light blue rectangles)
• Processing modules (yellow rectangles)
Detailed capture of essential elements
• Location of config.py (API key injection)
• Pre-downloaded model directory under models/all-MiniLM-L6-v2
• Test suite separately (optional, for dev flow)