How hrishikeshrt/chanda works
Project type and purpose
• This is a full-stack web application (Flask) that identifies Sanskrit meters from text or images (via OCR), displays scansions in a friendly UI, and supports batch processing & evaluation.
File structure
• webapp.py (Flask entry point / controller)
• chanda.py + data/*.csv + data/examples.json (core “model” – meter rules and examples)
• templates/*.html (views – Jinja2 templates)
• static/ (frontend assets: Bootstrap, FontAwesome, custom CSS/JS)
• experiments/ (evaluation scripts & output – optional analytics module)
• settings.sample.py / settings.py (configuration)
• requirements.txt (dependencies)
README for additional insights
• Confirms Flask-based web UI, OCR support (Google Cloud OCR or Tesseract), fuzzy matching, batch processing.
• No external database – uses CSV files and JSON for meter definitions.
• Two OCR subsystems: an external Google OCR service and a local Tesseract binary.
Main components & their relationships
A. Client / Browser (frontend)
– Loads HTML/CSS/JS from static/ and templates/
– Sends HTTP requests to Flask routes in webapp.py
B. Web Server / Application Layer (Flask)
– webapp.py defines routes for:
• Single-line or file uploads (text, image)
• Selecting output scheme
• Feedback, examples, help pages
– Acts as Controller in MVC
C. Core Meter Engine (chanda.py + data/)
– Implements scansion logic, fuzzy matching, CSV-driven meter definitions
– Provides an API to webapp.py to identify meter patterns
D. OCR Subsystem
– Google Cloud OCR (external REST API)
– Tesseract OCR (local process invocation)
– Called by webapp.py when image input is provided
E. Templates & Static Assets
– Jinja2 templates for rendering views
– CSS/JS assets (Bootstrap, FontAwesome, custom) to drive UI behaviors
F. Experiments & Evaluation (optional module)
– scripts under experiments/evaluation/ for batch evaluation against gold standards
– Not in request path; used offline for metrics
Architectural patterns & design principles
• MVC (Flask webapp.py = Controller, chanda.py = Model, templates = View)
• Layered design: presentation layer (templates/static), application logic (Flask), domain logic (meter engine), external services (OCR)
• Configuration-driven: settings.py toggles OCR backends, logging, etc.