Logo Lanfrica

HamzaAfif/amina-refactored

Domain:

educationnatural language processing

Record type:

software
Creator:
Ham
Host:
# AMINA — refactored A tutor that looks at a child's handwritten arithmetic and tells them *which step* they got wrong — not just that the answer is wrong. Write `47`, `38` and your answer `75` on the three canvases. It reads the digits, works out that you forgot the carry when moving to the tens column, explains it in plain French, and reads the explanation out loud. --- ## What this repo is, and what it isn't The original AMINA project — the math error-detection engine, the error taxonomy, the explanation datasets — is the work of **Naoufal Bezzat**: **github.com I did not build that engine. What I did here was: - **restructure the detection code around five GoF design patterns**, without changing what it detects - **add the AI layer**: handwriting recognition, an LLM explanation agent, and text-to-speech - **add a web front end** so the whole thing can be used by drawing instead of typing > The upstream repo is currently private, so that link may 404 for you. --- ## The problem with the original code The detection logic worked. It was just impossible to extend. Each operation was one long free function with deeply nested `if ... return`: | Original file | Lines | |---|---| | `addition_error_detector.py` | 240 | | `multiplication_error_detector.py` | 225 | | `subtraction_error_detector.py` | 222 | All three had the same shape: set up ~20 local variables at the top, then a wall of conditionals that each `return` a different error. There was no shared type between them either — three free functions, so every caller had to know which one to call by name. The important thing I noticed: **that wall of `if ... return` was already a Chain of Responsibility.** Each block asked "is it *this* error? then stop, otherwise keep going." The pattern was there implicitly. The refactor mostly consisted of making it explicit and building the other four patterns around it. --- ## The five patterns, and where they live ### 1. …