How moinshariff26/ocr-and-multilingual-translator works
1. Overall shape
- This repository is a single-process Flask web application with three user-facing pages: a landing page, the main OCR/translation tool, and a records page.
- The core runtime boundary is: browser UI → Flask backend → OCR/translation libraries → SQLite storage.
2. Frontend presentation layer
- templates/landing.html, templates/index.html, and templates/records.html define the three routes’ HTML structure.
- static/landing.css, static/styles.css, static/landing.js, and static/script.js provide page-specific styling and client-side behavior such as upload interactions, drag-and-drop, previews, and UI actions like copying results.
3. Landing page as entry surface
- The landing page is a separate presentation surface, not just a reused section of the main tool.
- It likely acts as a marketing/overview page that routes users into the OCR workflow, with supporting imagery stored under static/images.
4. Main OCR workflow
- The main page is the application’s primary data-processing surface: users upload an image, optionally enable handwriting mode, and receive extracted text, detected language, and translated output.
- This page is where the app’s central pipeline is exposed end to end.
5. Backend orchestration in app.py
- app.py is the control plane of the system: it likely defines the Flask routes, accepts file uploads, invokes OCR, runs language detection, calls translation, and persists results.
- In architecture terms, it is both the HTTP gateway and the workflow coordinator.
6. OCR subsystem
- The OCR layer combines multiple engines: EasyOCR and PyTesseract, with PyOCR mentioned in the README as part of the stack.
- This suggests a layered recognition strategy rather than a single engine dependency, with handwriting mode and fallback behavior forming an important internal boundary.
7. Language detection and translation subsystem
- After OCR, extracted text flows into langdetect for language identification.
- Translation is handled through googletrans / Google Translate API, enabling output into multiple target languages, including Indian and common global languages.
- This is a distinct processing stage after text extraction, not part of the OCR engine itself.
8. Persistence and records
- The app stores OCR and translation results in SQLite, which is a key architectural boundary because it turns the tool from a stateless processor into a history-bearing system.
- templates/records.html is the readout surface for this storage layer, showing past OCR records and associated images.
- query.sql likely contains the SQL used for schema creation or record retrieval, reinforcing that the database logic is separated from the Flask route code.
9. Data flow
- Typical flow: user uploads image in browser → Flask receives the file → OCR engine extracts text → language detection identifies source language → translation service produces target text → record is written to SQLite → UI displays results and the records page can later read them back.
- The database read path is separate from the live OCR path, which matters for diagramming request/response vs. historical retrieval.
10. Operational dependencies
- The runtime depends on Python, Flask, EasyOCR, PyTesseract, PyTorch, OpenCV, langdetect, and googletrans.
- The README also notes system-level Tesseract installation, which is important because OCR is not self-contained in the Python package layer.
11. Repo artifacts vs runtime
- SNAPSHOTS/ contains PDFs that document the UI and stored records; these are reference artifacts, not application components.
- They are useful for understanding expected screens and outputs, but they do not participate in execution.
12. Architecture summary for diagramming
- Draw the browser as the presentation boundary with three routes.
- Place Flask/app.py as the central orchestrator.
- Attach OCR engines, language detection, and translation as downstream processing services.
- Show SQLite as the persistent store feeding the records page.
- Treat static assets and templates as the UI layer, and query.sql as the database-query/schema companion to the backend.
Main entry points: app.py Flask App · landing.html Landing Page · index.html Main Page · records.html Records Page
Components 20
Presentation
Browser-facing pages, templates, and static assets.
- Browser · User entry point for landing, OCR, and records pages.
- Landing Page · HTML for the marketing/entry page.
templates/landing.html - Main Page · HTML for image upload, OCR, and translation workflow.
templates/index.html - Records Page · HTML for browsing stored OCR history.
templates/records.html - Landing Assets · CSS, JS, and images for the landing surface.
static/landing.css - Landing JS · Client-side interactions for the landing page.
static/landing.js - Main JS · Upload, preview, copy, and other tool interactions.
static/script.js - App Styles · Shared styling for the main application pages.
static/styles.css
App Core
Flask control plane and request workflow.
- Flask App · HTTP routes, upload handling, workflow orchestration, and page rendering.
app.py
Text Pipeline
OCR, language detection, and translation stages.
- OCR Pipeline · Extracts text from uploaded images, including handwriting support and engine fallback.
- EasyOCR · Primary OCR engine used by the text extraction pipeline.
- PyTesseract · Secondary OCR engine backed by system Tesseract.
- Lang Detect · Identifies the source language of extracted text.
- Translator · Produces translated output for the selected target language.
Storage
Persistent record layer and SQL companion.
- SQL Companion · Schema or query definitions used with record storage.
query.sql - SQLite · Persistent store for OCR and translation history.
External
Runtime and library dependencies outside the repo.
- Flask · Web server and routing framework for the application.
- Python · Execution runtime for the application and libraries.
- OpenCV · Image handling and preprocessing support for OCR.
- Tesseract · System-level OCR binary required by PyTesseract.
Connections 21
- Browser → Landing Page: opens · Loads the landing page.
- Browser → Main Page: uses · Accesses the main OCR workflow.
- Browser → Records Page: views · Opens stored OCR records.
- Landing Page → Landing JS: uses · Landing page behavior.
- Landing Page → Landing Assets: styles · Landing page styling and assets.
- Main Page → Main JS: uses · Upload and result interactions.
- Main Page → App Styles: styles · Shared application styling.
- Records Page → App Styles: styles · Shared application styling.
- Browser → Flask App: requests · Browser requests are handled by Flask routes.
- Flask App → OCR Pipeline: orchestrates · Coordinates image processing and text extraction.
- OCR Pipeline → EasyOCR: uses · Primary OCR engine.
- OCR Pipeline → PyTesseract: uses · Fallback or alternate OCR engine.
- OCR Pipeline → OpenCV: preprocesses · Image preparation before recognition.
- PyTesseract → Tesseract: depends on · Requires system Tesseract installation.
- Flask App → Lang Detect: detects · Identifies source language after OCR.
- Flask App → Translator: translates · Produces translated text output.
- Flask App → SQLite: stores · Persists OCR and translation records.
- SQL Companion → SQLite: defines · SQL companion for schema or queries.
- Records Page → SQLite: reads · Displays stored historical records.
- Flask App → Flask: built on · Application control plane uses Flask.
- Flask App → Python: runs on · Python execution environment.