How mahirqt/kiddycanvas works
Project Type & Purpose
• KiddyCanvas is a full-stack web application:
• Backend: Flask server exposing an API endpoint
• AI/ML: a pre-trained TensorFlow/Keras CNN (EMNIST) for character recognition
• TTS: pyttsx3 engine to speak out the predicted character
Top-Level Components
• Frontend
• index.html (Flask template)
• style.css (UI styling)
• script.js (Canvas drawing, AJAX to backend)
• Backend
• app.py (Flask app: serves UI, handles POST image data, returns JSON/text)
• render.yaml (deployment config)
• requirements.txt (dependencies: Flask, TensorFlow, Pillow, pyttsx3, etc.)
• Machine Learning
• cnn_emnist_model.h5 (trained CNN)
• label_mapping.npy (map from model index to character)
• EMNIST raw files under emnist_balanced/ (training/testing data, only used for retraining)
• Text-to-Speech
• pyttsx3 invoked in app.py after prediction
• Miscellaneous
• .gitignore, “how to use.md”, static/animated_gifs (optional assets)
Relationships & Data Flows
• User draws on HTML5 Canvas
→ script.js captures drawing, sends image payload (base64 PNG) via AJAX POST to Flask endpoint
→ app.py receives image, uses Pillow to preprocess (resize, grayscale, normalize)
→ Preprocessed image passed to CNN model (.h5) for prediction
→ Numeric class index mapped to character via label_mapping.npy
→ Flask returns JSON {“prediction”: “A”} and simultaneously invokes pyttsx3 to speak “A for Apple”
→ script.js plays audio (or audio triggered server-side), updates UI with predicted letter
Architectural Patterns & Principles
• MVC-style separation:
• View: templates/index.html + static assets
• Controller: Flask routes in app.py
• Model: Keras CNN + label mapping
• Single-page interaction with REST-style API call for recognition
• Modularity: ML, TTS, and web layers clearly decoupled