How ishandikshit/sniprag works
SnipRAG turns PDFs into searchable text chunks linked to page coordinates and rendered images, then returns semantic matches with visual snippets. The main workflow is engine selection, local or S3 document ingestion, strategy-specific text extraction, embedding and indexing, followed by filtered search and snippet delivery. The semantic and OCR strategies are distinct extraction paths; both share the base engine’s indexing and search behavior. README capabilities guide the map where excerpts are incomplete, so uncertain internal wiring is omitted.
Main entry points: base_engine.py Base Engine · ocr_engine.py OCR Strategy · semantic_engine.py Semantic Strategy · __init__.py Strategy Factory
Components 16
Engine API
- Strategy Factory
sniprag/core/__init__.py - Base Engine
sniprag/core/base_engine.py
PDF Ingestion
- Semantic Strategy
sniprag/core/semantic_engine.py - OCR Strategy
sniprag/core/ocr_engine.py
Search And Snippets
- Text Embeddings
sniprag/core/base_engine.py - Semantic Search
sniprag/core/base_engine.py - Snippet Extraction
sniprag/core/base_engine.py - Text And Image Results
sniprag/core/base_engine.py
Index And Assets
- FAISS Index
sniprag/core/base_engine.py - Chunk Metadata
sniprag/core/base_engine.py - Page And Slice Images
sniprag/core/base_engine.py
Other components
- Application User
- PDF Documents
- Amazon S3
- PyMuPDF
- Tesseract OCR
Connections 29
- Application User → Strategy Factory: selects strategy
- Strategy Factory → Semantic Strategy: creates semantic
- Strategy Factory → OCR Strategy: creates OCR
- Application User → Base Engine: submits PDF and query
- Base Engine → Amazon S3: downloads PDF
- Base Engine → Semantic Strategy: dispatches extraction
- Base Engine → OCR Strategy: dispatches extraction
- Semantic Strategy → PDF Documents: reads PDF
- OCR Strategy → PDF Documents: reads PDF
- Semantic Strategy → PyMuPDF: extracts text and renders
- OCR Strategy → PyMuPDF: renders pages
- OCR Strategy → Tesseract OCR: recognizes slice text
- Semantic Strategy → Page And Slice Images: stores page images
- OCR Strategy → Page And Slice Images: stores page and slice images
- Semantic Strategy → Base Engine: returns text chunks
- OCR Strategy → Base Engine: returns text chunks
- Base Engine → Text Embeddings: embeds chunks and queries
- Base Engine → FAISS Index: adds and searches vectors
- Base Engine → Chunk Metadata: stores chunks and coordinates
- Application User → Semantic Search: requests filtered search
- Semantic Search → Text Embeddings: embeds query
- Semantic Search → FAISS Index: retrieves matches
- Semantic Search → Chunk Metadata: filters and reads matches
- Semantic Search → Snippet Extraction: requests snippets
- Snippet Extraction → Chunk Metadata: reads coordinates
- Snippet Extraction → Page And Slice Images: crops visual context
- Snippet Extraction → Text And Image Results: adds image snippet
- Semantic Search → Text And Image Results: returns text and scores
- Text And Image Results → Application User: delivers matches