How codesomethingdaily/hiragana_recognition works
File structure
• Top level:
• android/ – Android Runner, Gradle build files, AndroidManifest, Kotlin MainActivity
• ios/ – Xcode project, Swift AppDelegate, Info.plist, storyboard assets
• windows/ – CMake runner, native entry (main.cpp), window management
• lib/ – Dart source: main.dart (app entry) and paint.dart (drawing canvas + logic)
• test/ – Flutter widget test harness
• pubspec.yaml – Flutter dependencies (likely includes pytorch_mobile plugin or similar)
• No explicit “backend” directory: inference happens on-device via platform-specific native libs.
• The structure follows Flutter’s standard runner + Dart code pattern, with platform channels implicitly used to bridge Dart to native ML code.
Key README insights
• “An flutter app that recognize handwriting of Japanese Hiragana using pytorch.”
• Tells us the core components are: Flutter UI → drawing input → on-device PyTorch inference → display result.
a. Main components:
1. Flutter Presentation Layer (Widgets, Drawing Canvas)
2. Application Logic (Dart service that captures strokes, rasterizes to bitmap/tensor)
3. Platform Channel Bridge (MethodChannel or similar)
4. Native Inference Module (PyTorch Mobile library on Android, iOS, Windows)
5. OS & Device Hardware (CPU/GPU)
b. Relationships & data flow:
• User touches screen → Flutter Canvas → stroke data aggregated
• Dart logic rasterizes strokes into an image tensor → sends tensor over Platform Channel
• Native side (Kotlin/Swift/C++) receives tensor → invokes PyTorch Mobile forward pass → returns a class/probability
• Dart layer receives recognition result → updates UI with predicted Hiragana character
c. Architectural patterns & principles:
• Layered architecture (Presentation → Service → Platform Bridge → Native Module)
• Single codebase for UI + business logic (Flutter), separation of concerns via Platform Channels
• On-device ML inference for low latency (no external server calls)
d. Key technologies/frameworks:
• Flutter framework (Dart)
• PyTorch Mobile (Android AAR, iOS Pod, Windows library)
• Platform Channels (MethodChannel)
• Kotlin (Android), Swift (iOS), C++/Win32 (Windows)
Capturing essential elements
• Assets or model file if present (e.g., .pt or .ptl file packaged).
• Clearly separates cross-platform UI from platform-specific ML inference
• Shows all five major components and their interactions
• Labels each platform runner, the Dart entrypoints, and the ML engine
• Reflects the exact structure implied by the project’s file tree and README.