How rta-ai/documind works
1. Repository shape
- This is a very small, single-app repository: app.py contains the full application, with requirements.txt for dependencies and no separate backend/frontend split.
- The architecture is therefore a monolithic Streamlit app with an embedded RAG pipeline.
2. Primary user-facing boundary
- The main entry point is the Streamlit UI.
- Users upload a PDF and then interact with the document through chat-style questions and document-oriented actions like summarization and key extraction.
3. Document ingestion pipeline
- The first backend step is PDF parsing using PyMuPDF.
- The app accepts large PDFs (up to 200 MB per the README), so ingestion is a significant boundary: file upload from the UI, then extraction of text from the PDF into internal document text.
4. Text preparation and chunking
- Extracted text is split into smaller segments using LangChain’s RecursiveCharacterTextSplitter.
- This chunking boundary matters because it separates raw document text from retrieval-ready units that can be embedded and searched efficiently.
5. Embedding and indexing layer
- Chunks are converted into vector embeddings using all-MiniLM-L6-v2 from Hugging Face.
- Those embeddings are stored in ChromaDB, which serves as the vector database for retrieval-augmented generation.
- This is the core persistence/retrieval subsystem; it turns uploaded PDFs into searchable semantic memory.
6. Retrieval-augmented generation flow
- When the user asks a question, the app retrieves relevant chunks from ChromaDB and sends them as context to the LLM.
- This is the key data flow: PDF → chunks → embeddings/vector store → retrieval → LLM answer.
7. LLM and response generation
- The generation model is served through Groq API using LLaMA 3.3 (llama-3.3-70b-versatile).
- The app supports streaming responses, so the UI receives partial tokens incrementally rather than waiting for a full completion.
8. Document-centric capabilities
- The app is not only a chatbot; it also supports structured document tasks:
- full summary
- 5-point bullet summary
- key extraction for dates, names, figures, and terms
- These capabilities likely reuse the same parsed/chunked document data, but route it through different prompt templates or retrieval strategies.
9. State and interaction model
- Because this is Streamlit, application state is likely managed within Streamlit session state rather than an external service.
- That means the document context, chat history, and retrieved chunks are probably kept per user session inside the app process.
10. External dependencies and operational boundary
- The app depends on a Groq API key loaded from environment configuration.
- The runtime stack is Python 3.10 with Streamlit 1.32 and the libraries listed in requirements.txt.
- There is no evidence of separate databases, auth service, or job queue; the whole system is a local/in-memory Streamlit app plus external API calls to Groq and Hugging Face model assets.
11. What an architecture diagram should show
- A single Streamlit application box in the center.
- Inputs from the user: PDF upload and chat queries.
- Internal pipeline blocks: PDF parsing, chunking, embeddings, ChromaDB retrieval, prompt assembly, Groq LLM generation.
- Outputs back to the user: streamed answers, summaries, and extracted key facts.
Main entry points: app.py RAG Flow
Components 14
Streamlit App
Monolithic Python application that handles upload, RAG, and document actions.
- Chat UI · Main user-facing Streamlit screen for upload, questions, and document actions.
app.py - Session State · Holds document context, chat history, and interaction state inside the Streamlit process.
app.py - PDF Upload · Accepts large PDF files from the user and starts the document pipeline.
app.py - PDF Parse · Extracts text from uploaded PDFs using PyMuPDF.
app.py - Text Chunking · Splits extracted text into retrieval-friendly chunks with RecursiveCharacterTextSplitter.
app.py - Embeddings · Converts chunks into semantic vectors using all-MiniLM-L6-v2.
app.py - ChromaDB · Stores embeddings and chunk metadata for semantic retrieval.
app.py - Retriever · Finds relevant chunks from ChromaDB for questions and document tasks.
app.py - Prompt Assembler · Builds task-specific prompts for chat, summaries, and key extraction.
app.py - RAG Flow · Connects document context, retrieval results, and generation into one answer path.
app.py - Summaries · Produces full and 5-point summaries from the uploaded document context.
app.py - Key Extraction · Extracts dates, names, figures, and key terms from the document.
app.py
External Services
Third-party model and library-backed services used by the app.
- Groq LLM · Generates streamed responses through the Groq API using LLaMA 3.3.
- Hugging Face Model · Provides the all-MiniLM-L6-v2 embedding model asset used by the app.
Connections 18
- Chat UI → PDF Upload: upload PDF · User sends a document into the app.
- Chat UI → RAG Flow: ask / act · User submits chat questions or document-oriented actions.
- PDF Upload → PDF Parse: file text · Uploaded PDF is parsed into raw text.
- PDF Parse → Text Chunking: document text · Extracted text is prepared for splitting.
- Text Chunking → Embeddings: chunks · Chunks are encoded into vectors.
- Embeddings → Hugging Face Model: model load · Embedding generation depends on the Hugging Face model asset.
- Embeddings → ChromaDB: vectors · Embeddings and chunk metadata are indexed in ChromaDB.
- ChromaDB → Retriever: search index · Retriever queries the vector store for relevant context.
- Session State → RAG Flow: context · Session state supplies document and chat context to orchestration.
- RAG Flow → Retriever: find context · RAG flow fetches relevant chunks for the current task.
- RAG Flow → Prompt Assembler: assemble prompt · Task inputs are converted into generation-ready prompts.
- Prompt Assembler → Groq LLM: generate · Prompt is sent to the hosted LLM for completion.
- Groq LLM → Chat UI: stream answer · Partial tokens stream back to the user interface.
- RAG Flow → Summaries: summary task · Summary mode reuses the same document pipeline with a different prompt.
- RAG Flow → Key Extraction: extraction task · Key extraction mode reuses document context with structured prompts.
- Summaries → Groq LLM: summarize · Summaries are generated through the same Groq LLM path.
- Key Extraction → Groq LLM: extract facts · Structured facts are generated through the same Groq LLM path.
- Chat UI → Session State: save state · User interactions update per-session state.