How olehdatsyk/pdf-chat works
PDF Chat lets users upload PDFs, ask grounded questions with page citations, manage conversations and documents, and request structured summaries. Upload handlers validate and save files, extract and chunk text, then add chunks to persistent FAISS storage. Chat handlers manage SQLite-backed history and invoke retrieval-augmented generation, whose responses include cited sources and can stream. The graph separates API orchestration, ingestion, retrieval/generation, persistence, and browser interface. Relationships are limited to README statements and the shown source/index references; unsampled implementations are represented only where the tree and documentation support them.
Main entry points: main.py FastAPI app · upload.py Upload API · chat.py Chat API · rag_service.py RAG answers
Components 21
API and orchestration
- FastAPI app
main.py - Upload API
routers/upload.py - Documents API
routers/documents.py - Chat API
routers/chat.py - Health API
routers/health.py - API schemas
schemas.py - Application settings
config.py
PDF ingestion
- PDF extraction
services/pdf_loader.py - Text chunking
services/chunking_service.py
Retrieval and generation
- Embedding client
services/embedding_service.py - Chunk retrieval
services/retriever.py - RAG answers
services/rag_service.py - Prompt templates
services/prompt_templates.py
Persistent state
- Conversation memory
services/conversation_memory.py - SQLite database
database.py - Stored records
models.py - FAISS vector store
services/vector_store.py
Browser interface
- Web interface
templates - Browser interactions
static/js/chat.js
Other components
- PDF user
- OpenAI API
Connections 27
- PDF user → FastAPI app: uses
README.md - FastAPI app → Upload API: registers
main.py - FastAPI app → Documents API: registers
main.py - FastAPI app → Chat API: registers
main.py - FastAPI app → Health API: registers
main.py - FastAPI app → Web interface: renders
main.py - FastAPI app → Application settings: configures
main.py - Upload API → PDF extraction: extracts text
routers/upload.py - Upload API → Text chunking: chunks text
routers/upload.py - Upload API → FAISS vector store: adds chunks
routers/upload.py - Upload API → Stored records: records document
routers/upload.py - Documents API → FAISS vector store: deletes chunks
routers/documents.py - Documents API → RAG answers: requests summary
routers/documents.py - Chat API → Conversation memory: loads and saves
routers/chat.py - Chat API → RAG answers: requests answer
routers/chat.py - Chat API → Stored records: reads conversations
routers/chat.py - Chat API → API schemas: validates payloads
routers/chat.py - Conversation memory → Stored records: uses records
services/conversation_memory.py - Stored records → SQLite database: declares tables
models.py - RAG answers → Chunk retrieval: retrieves context
services/rag_service.py - RAG answers → Prompt templates: builds prompts
services/rag_service.py - Chunk retrieval → FAISS vector store: searches chunks
services/retriever.py - FAISS vector store → Embedding client: embeds chunks
services/vector_store.py - Embedding client → OpenAI API: creates vectors
README.md - RAG answers → OpenAI API: generates answers
README.md - PDF user → Browser interactions: asks questions
README.md - Browser interactions → FastAPI app: calls API