How macasteglione/cashscan works
Project Type and Purpose
• This is a mobile‐centric AI application (“reconocimiento-de-billetes”) with two main parts:
• A Python‐based classifier (under Clasificador/) that trains/tests/validates a TensorFlow Lite model for banknote recognition.
• An Android app (under movil/) written in Kotlin that embeds or invokes that TFLite model (and a helper Python script), displays UI screens, and stores scan history in a local SQLite database.
File Structure Analysis
• Top level:
• Clasificador/: Python virtual env + scripts (MCBIA7.py, test* scripts), model file (modelo_billetes.tflite), class mapping.
• movil/: full Android project with:
– app/: source code (domain, data, presentation, UI, adapters, factory for currency models), Python helper (main.py), raw assets (audio prompts), SQLite helper, resource files (layouts, strings).
– Gradle scripts, wrappers, config.
• Patterns & tech:
• Mobile uses MVVM/MVC–style separation: domain, data, factory, adapters, presentation, UITheme.
• Uses embedded Python via Chaquopy or similar (python/ folder).
• Local storage: SQLiteHelper.
• ML inference: TensorFlow Lite (.tflite).
C4 Approach
A. Level 1 – System Context
• The “ReconocimientoDeBilletes” system sits within users’ mobile devices.
• External actors: End User (scans bills), optionally a Developer (maintains classifier).
• External systems: none (fully on‐device).
1. Android App Container
– Language: Kotlin
– Framework: Android SDK
– Responsibilities: UI, camera preview, user flows, data persistence.
2. Python Classifier Container
– Language: Python 3.11 in virtualenv
– Frameworks: TensorFlow, TFLite Interpreter
– Responsibilities: preprocess image, run inference with modelo_billetes.tflite, return class.
3. Local SQLite Database
– Technology: SQLite
– Stores: scan history, user settings.
4. Model File
– TensorFlow Lite (.tflite) loaded by the Python container or directly by mobile.
• Android App → Python Classifier: send camera frame → inference result
• App ↔ SQLite: read/write scan history and config
• App loads .tflite from assets to classifier
Inside the Android App container, break out major components:
1. UI Layer
– Activities: MainActivity, ScanBillActivity, CountBillActivity, ConfigActivity, TutorialActivity, IntroActivity
– Adapters: BillsAdapter, ModelListAdapter, IntroViewPagerAdapter
2. Presentation Layer
– CameraPreview, Utils
3. Domain Layer
– Data classes: BillData, Model, ScreenItem
4. Data Layer
– SQLiteHelper for persistence
5. Factory Layer
– ModelFactory & ConcreteModelFactory choose correct currency model (ArsModel, UsdModel, BrlModel)
6. Python Integration
– main.py invoked via Chaquopy (or equivalent) bridging Android → Python
– classifier call and mapping via mapeo_clases.json
Interactions:
• UI → Presentation → Domain → Data / Python Integration → returns to UI
• Factory supplies domain models to UI
Architectural Patterns & Design Principles
• Separation of concerns: UI, presentation, domain, data, factory
• MVC/MVVM‐like layering in Android
• On‐device ML inference using TFLite
• Extensibility via Factory Method for currency models
• Local persistence (offline operation)