How log4j-innovations/scrapbuddy works
Project type and purpose
• ScrapBuddy is a cross-platform (Android, iOS, Web, Windows, macOS, Linux) Flutter application that uses AI (Google Vertex AI + on-device TensorFlow Lite) to classify waste materials, provide recycling guidance, track user stats, and deliver voice assistance via Sarvam AI.
File structure
• Top-level directories:
• android / ios / linux / macos / web / windows → platform embedding and native launchers
• lib → the Dart application code, subdivided into config, localization, models, screens (UI), services (business logic), widgets (UI components)
• assets → audio clips (multi‐lang), ML models (TFLite), labels, other static resources
• scripts → build or codegen helpers (e.g., generate_audio.dart)
• Key patterns:
• Clean Architecture / separation of concerns: UI (screens/widgets) ⇄ service layer (vertex_ai_service, firebase_service, offline_classifier_service) ⇄ data sources (Firestore, Storage, local assets, Shared Preferences)
• Provider or similar state management (implied by “Provider pattern” in README)
• Deployment/config files:
• pubspec.yaml → Flutter dependencies
• android/app/build.gradle, ios/Runner.xcodeproj → native Firebase integration
• analysis_options.yaml → linting rules
README for additional insights
• Architecture description: Clean/Repository/Service layer, Provider state management
• Tech stack: Flutter/Dart, Firebase Auth, Firestore, Firebase Storage, Vertex AI, TensorFlow Lite, Sarvam AI TTS, Shared Preferences
• Features: real-time & offline inference, multi-language support, gamification, audio guidance, responsive UI
a. Main components
• Client Application (Flutter UI)
• Service Layer
• Vertex AI Service (remote inference)
• Offline Classifier Service (TFLite on-device)
• Firebase Service (Auth, Firestore, Storage)
• Sarvam AI Service (TTS)
• Data Stores
• Cloud Firestore (user profiles, scan history, stats)
• Firebase Storage (uploaded images)
• Local Storage (Shared Preferences, cached TFLite model, offline audio)
• External Services
• Google Vertex AI
• Sarvam AI TTS
b. Relationships and interactions
• UI screens/widgets invoke Service Layer APIs
• Service Layer delegates to either Vertex AI (REST/gRPC) or Offline TFLite for classification
• Classification results → UI + Service Layer triggers Firestore updates (user points, history)
• Service Layer calls Sarvam AI (or local audio assets) to generate/play audio guidance
• On login/registration, UI → Firebase Auth → Firestore → local cache
• Assets (models/audio) loaded from packaged assets folder on startup
c. Architectural patterns
• Clean Architecture (UI ⇄ Use Cases/Services ⇄ Repositories ⇄ Data Sources)
• Repository pattern for abstracting Firebase vs. local data sources
• Provider (or other DI) for injecting services into widgets
• Offline-first design: fallback to on-device ML and cached audio when network unavailable
d. Key technologies/frameworks
• Flutter & Dart
• TensorFlow Lite (model_unquant.tflite in assets)
• Google Vertex AI (Gemini 2.0 Flash)
• Firebase (Auth, Firestore, Storage)
• Sarvam AI (Text-to-Speech)
• Shared Preferences (local key-value store)
• Audio Players package for playback