An intelligent document ingestion and retrieval system that forms the AI backbone of the DreamWeave project.
The system accepts multiple content formats, extracts information from them, structures the data, generates embeddings, and eventually enables context-aware conversational retrieval (RAG).
User Upload
│
▼
File Processor
│
├── Image → OCR
├── PDF → Text Extraction / OCR Fallback
├── Notes → Raw Text
│
▼
Raw Text
│
▼
AI Cleanup / Structuring
│
▼
Clean Text
│
▼
Embedding Generator
│
▼
Vector Store
│
▼
Retriever
│
▼
LLM
│
▼
Answer
- PNG
- JPG / JPEG
- WEBP
- Other PIL-supported image formats
- PDF (text PDFs)
- Scanned PDFs (OCR fallback)
- Plain text files
- User-entered notes
Supported inputs:
- Images
- PDFs
- Notes
Files are stored locally in:
uploads/
Image
↓
Tesseract OCR
↓
Raw Text
PDF
↓
Direct Text Extraction
↓
Raw Text
PDF
↓
No Text Found
↓
Convert Pages To Images
↓
OCR
↓
Raw Text
Temporary page images are created in the background using Python's tempfile module and automatically deleted after OCR.
Notes
↓
Raw Text
No extraction required.
All extracted content is stored using a unified document structure.
Example:
{
"id": 1782210867,
"source": "image",
"filename": "test.png",
"raw_content": "...",
"clean_content": "",
"metadata": {
"ocr_used": true,
"page_count": 1,
"language": "en",
"ocr_engine": "tesseract"
},
"timestamp": "2026-06-23 16:04:27"
}Pipeline:
Raw Text
↓
LLM Cleanup
↓
Clean Text
Examples:
- Reconstruct menus
- Fix OCR errors
- Preserve structure
- Improve formatting
- Enhance semantic quality before embedding generation
Both raw_content and clean_content are preserved.
Text
↓
SentenceTransformer
↓
Vector Embeddings
Embeddings will be generated primarily from:
clean_content
with fallback to:
raw_content
Embeddings and metadata will initially be stored locally.
Future migration:
- PostgreSQL
- pgvector
Query
↓
Embedding
↓
Cosine Similarity
↓
Relevant Documents
Purpose:
- Intelligent search
- Context retrieval
- Recommendation engine support
User Query
↓
Semantic Search
↓
Relevant Documents
↓
Prompt Construction
↓
LLM
↓
Answer
The LLM answers using only the retrieved context from uploaded data.
Tesseract OCR
Advantages:
- Lightweight
- Fast
- Good for clean screenshots and documents
EasyOCR
Potential use cases:
- Stylized fonts
- Menus
- Posters
- Multilingual text
- Symbols and currencies
- Complex backgrounds
Future architecture:
Image
↓
Simple Document?
↓ yes → Tesseract
↓ no
EasyOCR
- Automatic language detection
- Multi-language OCR
- Emoji support
- Document chunking
- Metadata extraction
- Summarization
- Recommendation engine
- Vision boards
- Collaborative AI search
- Full RAG-powered assistant
UPLOAD
↓
TEXT EXTRACTION (RAW TEXT)
↓
AI CLEANUP / STRUCTURING
↓
CLEAN TEXT
↓
EMBEDDINGS
↓
VECTOR STORAGE
↓
SEMANTIC SEARCH
↓
RAG
↓
CHAT RESPONSE