Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  AskScribe โ€” AI-Powered Document Intelligence System

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.

FlaskGeminiFAISSTesseractSQLiteBootstrap MIT LicensePython


๐Ÿš€ Features

  • ๐Ÿ“‚ 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

๐Ÿ“ Project Structure

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

โš™๏ธ Getting Started

1๏ธโƒฃ Clone & Setup

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.txt

2๏ธโƒฃ Environment Variables

Create a .env file and add:

GEMINI_API_KEY=your_google_gemini_key
SESSION_SECRET=your_flask_secret

3๏ธโƒฃ Run the App

python main.py

Visit http://localhost:5000 in your browser.


๐Ÿง  How It Works

๐Ÿ“‚ Document Upload

Users upload files โ†’ Extract content โ†’ Chunk โ†’ Generate TF-IDF embeddings โ†’ Store with FAISS

โ“ Question Answering

User asks question โ†’ Retrieve top relevant chunks โ†’ Construct prompt โ†’ Gemini generates answer

๐Ÿ’ฌ Chat Interface

Real-time Q&A โ†’ History stored per session โ†’ View or continue previous chats


๐Ÿงฐ System Architecture

๐ŸŽจ Frontend Architecture

  • 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

๐Ÿงฐ Backend Architecture

  • 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

๐Ÿ” Key Components

๐Ÿ“„ Document Processing Pipeline

  • 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)

โš™๏ธ RAG Engine

  • Vector Store: JSON-based TF-IDF + FAISS similarity
  • Retrieval: Cosine similarity for top-matching chunks
  • LLM Generation: Prompt engineering with Gemini AI

๐Ÿ” Authentication

  • User System: Registration, login, logout
  • Session Handling: Secure cookie-based sessions with Flask-Login
  • Protected Routes: Auth-required pages

๐Ÿ’ฌ Chat System

  • Session Support: Multi-chat session per user
  • Chat History: Stored persistently in database
  • Contextual Q&A: Gemini answers are always based on document context

๐Ÿ” Data Flow

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]
Loading


๐Ÿ› ๏ธ Tech Stack

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

๐Ÿงช Sample Gemini Prompt

**Question**: What is the policy on leave?
**Context**: [Relevant chunks retrieved]
**Instructions**: Answer with headings, bullet points, and highlight **key terms**.

๐Ÿ” Security Features

  • โœ… Secure file storage with size/type checks
  • โœ… CSRF protection & secure sessions
  • โœ… Environment-based secrets (no hardcoding)
  • โœ… Auto OCR fallback for scanned documents

๐Ÿ”ฎ Future Upgrades

๐Ÿ“ค Chat Export

Export session as PDF, Markdown, or TXT for offline sharing.

โ˜๏ธ Cloud Uploads

Switch to Amazon S3 or Google Cloud Storage for large files.

๐Ÿ“ˆ Analytics Dashboard

Track document types, most asked queries, usage trends.

๐Ÿ”” Real-Time Notifications

Get alerts for OCR status, Gemini API limits, and timeouts.


๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for more info.


๐Ÿ‘จโ€๐Ÿ’ป Author

Made with โค๏ธ by Md Meraj Alam
Your feedback is always welcome!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages