How sharma39vishal/talk-to-pdf-ai works
Project Type and Purpose
• This is a full-stack web application (“Talk To PDF”) that allows users to upload PDF documents, ask questions about their contents, and receive LLM-generated answers.
• Key indicators: Flask backend (app.py), static frontend assets in build/index.html, PDF processing and vector search logic in Python modules.
File Structure Analysis
• Top-level files:
• app.py – Flask server application entry point
• searching_logic.py – PDF ingestion, text splitting, FAISS vector store, QA pipeline
• requirements.txt – Python dependencies (Flask, LangChain, PyPDF2, FAISS, OpenAI)
• build/index.html – Compiled frontend UI (HTML/CSS/JS) served by Flask or static middleware
• No separate “frontend” folder suggests a single‐page app delivered from build/
README Insights
• Technologies: Flask backend, HTML/CSS/JS frontend, PyPDF2 for PDF handling, LangChain for text splitting and QA, FAISS for vector storage, OpenAI GPT for LLM
• Workflow described: upload PDF → split text → build vector index → query index → call LLM → respond
Main Components
a. Frontend (User Interface)
• Browser running build/index.html + JS logic
• Responsible for file upload form and question input
b. Backend (Flask API)
• app.py exposes endpoints:
– POST /upload (receive PDF)
– POST /ask (receive question, trigger searching_logic)
c. PDF Processing & Vector Store
• searching_logic.py modules:
– PDF ingestion via PyPDF2
– CharacterTextSplitter (LangChain)
– FAISS in-memory vector database
d. LLM Service (External)
• OpenAI GPT-3 (or compatible) called via API key
e. Data Flow & Storage
• Temporary storage of uploaded PDFs (filesystem or memory)
• In-memory or persisted FAISS index
f. User (Actor)
• Initiates upload and queries; receives answers
Relationships & Data Flows
• User → Browser UI: selects PDF, inputs question
• Browser UI → Flask API:
• Upload request triggers PDF ingestion
• Ask request triggers similarity search + LLM call
• Flask API → PDF Processing: extract text and split into chunks
• Flask API → FAISS Vector Store: store and query vectors
• Flask API → OpenAI API: send context + question, receive answer
• Flask API → Browser UI: return answer for display
Architectural Patterns & Principles
• Separation of concerns:
• UI layer (static assets)
• API layer (Flask controllers)
• Business logic layer (searching_logic.py)
• Data layer (FAISS index)
• External service integration (OpenAI)
• Stateless HTTP endpoints with in-memory or transient storage
• Modularity via Python modules for PDF and vector logic