How anujkulal/handwritten-equation-solver works
Project Type and Purpose
• This is a full-stack web application called “handwritten-equation-solver.”
• Frontend: React + TypeScript app (Vite) providing a drawing canvas for users to handwrite equations.
• Backend: Python web service (likely Flask or similar) hosting a pre-trained Keras/TensorFlow model to classify symbols and then solve the equation.
File Structure Analysis
• Top level:
• backend/ – Python app, model file (math_symbol_classifier.h5), class_indices.json
• frontend/ – React + TypeScript source, Vite config, HTML entry point
• No databases or external microservices, just a two-tier architecture.
• Configuration files (package.json, tsconfig, eslint) suggest standard React/Vite setup.
README Insights
• Two processes: one to start backend (python app.py), one to start frontend (npm run dev).
• No mention of additional components (e.g. caching, message queues), confirming a simple front-to-back HTTP architecture.
Components
a. Main Components
• User’s Browser (UI layer)
• Frontend App
– Drawing Canvas component
– HTTP Client (fetch/axios)
• Backend Service
– Web Framework (Flask/FastAPI)
– Model Loader (loads .h5 file, class_indices.json)
– Symbol Classifier (Keras inference)
– Equation Solver (parses symbols into expression, computes result)
• Static Assets & Model Store (on server filesystem)
b. Relationships & Interactions
1. User draws equation → Canvas component captures strokes → converts to image or pixel data.
2. Frontend sends image payload (e.g., base64) via HTTP POST to backend /predict or /solve endpoint.
3. Backend receives image, Model Loader initializes the Keras model once at startup.
4. Classifier module runs inference → outputs predicted symbol classes.
5. Solver module assembles symbols into a math expression → computes result.
6. Backend returns JSON response (symbol sequence + solution) to frontend.
7. Frontend displays recognized equation and solution to the user.
c. Architectural Patterns & Design Principles
• Two-tier, client–server separation.
• Single responsibility: frontend does only UI/data collection; backend handles ML and business logic.
• Model is loaded once (singleton pattern) to minimize inference latency.
• Stateless HTTP endpoints for easy scaling (if Dockerized or containerized later).
d. Key Technologies & Libraries
• Frontend: React, TypeScript, Vite dev server, HTML5 Canvas
• Backend: Python 3, Flask (or FastAPI), TensorFlow/Keras
• Model files: math_symbol_classifier.h5, class_indices.json
• Build tools/config: npm, package.json, tsconfig.json