How arun-232007/ai-multimodal-rag works
This is a FastAPI backend for document-grounded PDF chat. The principal workflow is PDF upload, text extraction and chunking, embedding and storage, followed by query embedding, vector retrieval, answer generation, and returning source chunks. Session creation and chat-history retrieval are additional API capabilities. The sampled routes show orchestration and persistence calls; the README documents the Supabase schema and vector-search RPC. The SQL file and frontend were not sampled, so their internal behavior is not expanded.
Main entry points: upload.py Upload Handler · chat.py Chat Handler · app.py FastAPI App · config.py Client Configuration
Components 16
API
- FastAPI App
app.py - API Models
schemas.py
PDF Ingestion
- Upload Handler
routes/upload.py - PDF Extraction
utils.py - Text Chunking
utils.py - Document Embedding
routes/upload.py
Retrieval and Chat
- Chat Handler
routes/chat.py - Query Embedding
routes/chat.py - Vector Retrieval
routes/chat.py - Answer Generation
routes/chat.py
Data and Configuration
- Client Configuration
config.py - Supabase Database
- Supabase Storage
- Database Schema
supabase_setup.sql
Other components
- API Client
- Cohere API
Connections 21
- API Client → FastAPI App: sends requests
README.md - FastAPI App → Upload Handler: registers router
app.py - FastAPI App → Chat Handler: registers router
app.py - Upload Handler → API Models: returns model
routes/upload.py - Chat Handler → API Models: uses models
routes/chat.py - Upload Handler → PDF Extraction: extracts text
routes/upload.py - Upload Handler → Text Chunking: chunks text
routes/upload.py - Upload Handler → Document Embedding: embeds chunks
routes/upload.py - Document Embedding → Cohere API: requests embeddings
routes/upload.py - Upload Handler → Supabase Database: writes session and records
routes/upload.py - Upload Handler → Supabase Storage: uploads PDF
routes/upload.py - Chat Handler → Supabase Database: checks session and saves messages
routes/chat.py - Chat Handler → Query Embedding: embeds question
routes/chat.py - Query Embedding → Cohere API: requests embeddings
routes/chat.py - Chat Handler → Vector Retrieval: retrieves matching chunks
routes/chat.py - Vector Retrieval → Supabase Database: calls vector search
routes/chat.py - Chat Handler → Answer Generation: generates answer
routes/chat.py - Answer Generation → Cohere API: requests chat completion
routes/chat.py - Client Configuration → Supabase Database: creates client
config.py - Client Configuration → Cohere API: creates client
config.py - Database Schema → Supabase Database: defines tables and RPC
README.md