AskScribe is an intelligent document analysis tool built with Flask, combining Google Gemini AI and FAISS vector search to help users ask questions about uploaded documents in natural language. Whether you're scanning PDFs, DOCX, or TXT files โ AskScribe extracts, indexes, and intelligently answers with structured, professional responses.
- ๐ Upload PDFs, DOCX, and TXT files
- ๐ง Ask questions and get structured, context-aware answers
- ๐งพ Supports multi-session chat history
- ๐ Custom TF-IDF + FAISS vector search engine
- ๐ผ๏ธ OCR support for scanned documents
- ๐ฌ Gemini-powered LLM responses with Markdown formatting
- ๐ Secure user authentication and session handling
- ๐ Embedded file management, chunking, and vector indexing
DocumentIntelligence/
โ
โโโ templates/ # HTML (Jinja2)
โโโ static/ # CSS/JS/Assets
โโโ uploads/ # Uploaded documents
โโโ vectors/ # Stored vector index (JSON)
โ
โโโ main.py # Entry point
โโโ routes.py # App routes
โโโ gemini_client.py # Gemini integration
โโโ rag_engine.py # Vector search & RAG engine
โโโ models.py # SQLAlchemy models
โโโ utils/ # OCR, chunking, preprocessing
โโโ requirements.txt # Dependencies
โโโ README.md
git clone https://github.com/yourusername/askscribe.git
cd askscribe
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txtCreate a .env file and add:
GEMINI_API_KEY=your_google_gemini_key
SESSION_SECRET=your_flask_secretpython main.pyVisit http://localhost:5000 in your browser.
Users upload files โ Extract content โ Chunk โ Generate TF-IDF embeddings โ Store with FAISS
User asks question โ Retrieve top relevant chunks โ Construct prompt โ Gemini generates answer
Real-time Q&A โ History stored per session โ View or continue previous chats
- Framework: Bootstrap 5.3.2 with dark theme
- Styling: Custom CSS with ChatGPT-inspired dark interface
- JavaScript: Vanilla JS with Bootstrap components
- Templates: Jinja2 templating engine
- Features: Responsive design, file upload validation, real-time chat interface
- Framework: Flask with SQLAlchemy ORM
- Authentication: Flask-Login for session management
- Database: SQLite (configurable via DATABASE_URL)
- File Processing: Multi-format document processing with OCR
- AI Integration: Google Gemini 2.5 Flash model
- Vector Search: FAISS for efficient similarity search
- Text Extraction: Full support for PDF (PyMuPDF), DOCX, and TXT
- OCR: Automatic Tesseract fallback for scanned documents
- Chunking: 1000-char chunks with 200-char overlap
- Embeddings: Custom TF-IDF embeddings (lightweight)
- Vector Store: JSON-based TF-IDF + FAISS similarity
- Retrieval: Cosine similarity for top-matching chunks
- LLM Generation: Prompt engineering with Gemini AI
- User System: Registration, login, logout
- Session Handling: Secure cookie-based sessions with Flask-Login
- Protected Routes: Auth-required pages
- Session Support: Multi-chat session per user
- Chat History: Stored persistently in database
- Contextual Q&A: Gemini answers are always based on document context
flowchart TD
A[User Uploads Document] --> B[Text Extraction + OCR]
B --> C[Chunking & Embedding]
C --> D[FAISS Vector Storage]
D --> E[Ask Question]
E --> F[Relevant Chunks Retrieved]
F --> G[Prompt Sent to Gemini AI]
G --> H[Response Returned to User]
| Layer | Tools / Libraries |
|---|---|
| ๐ง AI Model | Google Gemini 2.5 Flash |
| ๐ Search | FAISS + TF-IDF (custom implementation) |
| ๐งพ OCR | Tesseract + Pillow |
| ๐งฐ Backend | Flask, SQLAlchemy, SQLite |
| ๐จ Frontend | HTML, Bootstrap 5.3, JS |
| ๐ Auth | Flask-Login |
**Question**: What is the policy on leave?
**Context**: [Relevant chunks retrieved]
**Instructions**: Answer with headings, bullet points, and highlight **key terms**.- โ Secure file storage with size/type checks
- โ CSRF protection & secure sessions
- โ Environment-based secrets (no hardcoding)
- โ Auto OCR fallback for scanned documents
Export session as PDF, Markdown, or TXT for offline sharing.
Switch to Amazon S3 or Google Cloud Storage for large files.
Track document types, most asked queries, usage trends.
Get alerts for OCR status, Gemini API limits, and timeouts.
This project is licensed under the MIT License. See the LICENSE file for more info.
Made with โค๏ธ by Md Meraj Alam
Your feedback is always welcome!