How abhishekn1947/vertex-ai-pdf-bot works
Project type and purpose
• This is a lightweight, full-stack web application built with Streamlit.
• Purpose: Let end users upload large PDF files (up to 200 MB), locally process them into embeddings and indexes, then ask free-form questions answered by a combination of local retrieval and Google Cloud Vertex AI LLM calls.
File structure
• Top-level files:
• main.py (Streamlit app, contains both “frontend” UI code and “backend” data-processing logic)
• requirements.txt (Python dependencies, including streamlit, langchain, chromadb, google-cloud-aiplatform)
• README.md / LICENSE
• No separate “frontend” or “backend” folders—everything runs in one monolithic Streamlit process.
• No dedicated config folder; environment variables (GOOGLE_APPLICATION_CREDENTIALS, project_id, location) are set externally.
Key architectural insights from the README
• Frontend: Streamlit UI for file upload and chat interaction.
• Document ingestion pipeline:
1) PDF loader
2) Text splitter / chunker
3) Embedding generator (via Vertex AI Embeddings)
4) Vector store (ChromaDB by default)
• Query pipeline:
1) Retrieve relevant chunks from vector store
2) Send prompt + context to Vertex AI LLM (e.g., PaLM 2)
3) Return answer to UI
• Optional: User can push data to their own BigQuery, ensuring data privacy/external storage.
Main components
a. Client (Web Browser)
b. Streamlit Server (main.py)
• UI Module: file-upload widget, question input, results display
• Ingestion Module: PDF Loader → Text Splitter → Embedding Client → Vector Store
• Query Module: Vector Store → Retrieval → LLM Client → Response Formatter
c. Local Persistence
• Chroma Vector Store (local on disk)
• Optional BigQuery Dataset (user-managed)
d. External Services
• Google Cloud Vertex AI Embeddings API
• Google Cloud Vertex AI LLM API
e. Environment Configuration
• GOOGLE_APPLICATION_CREDENTIALS (service account JSON)
• GCP project_id & location
Relationships & interactions
• User → Streamlit UI (upload PDF, ask question)
• UI triggers Ingestion Module → writes embeddings to Vector Store
• Query: Retrieval Module pulls nearest vectors → LLM Client calls Vertex AI → returns generated text
• All network calls to GCP services happen over secure HTTPS
Architectural patterns & design principles
• Monolithic single-process application (Streamlit)
• Pipeline pattern for ingestion & query (loader → splitter → embed → store / retrieve → LLM)
• Separation of concerns: UI vs. data pipeline vs. external API client
• Pluggable storage (local Chroma vs. BigQuery)
• Externalize credentials/config via environment variables
Essential details to capture
• Modules inside main.py (UI vs. ingestion vs. query)
• Environment/config layer
• Local vs. external storage distinction
• Upstream flow (PDF ingestion) vs. downstream flow (user Q&A)