How brilliantlabsar/noa-flutter works
Project Type and Purpose
• This is a cross-platform mobile application built in Flutter, targeting both iOS and Android.
• Purpose: to serve as a companion app (“Noa”) for the Frame hardware device, demonstrating Bluetooth connectivity, GPS/location services, Google OAuth, and real-time device control.
File Structure
• Top-Level Folders
– android/ and ios/: Native project scaffolding and platform-specific code (Bluetooth permissions, manifests, Gradle and Xcode projects).
– lib/: Main Flutter code. Subfolders:
• pages/: UI screens and navigation (login.dart, pairing.dart, noa.dart, hack.dart, tune.dart, etc.).
• widgets/: Reusable UI components (bottom_nav_bar, top_title_bar).
• models/: Data and business-logic models (app_logic_model.dart).
• util/: Services and helpers (bluetooth.dart, location.dart, foreground_service.dart, state_machine.dart, noa_api.dart, sign_in.dart, etc.).
– assets/: Static assets (images, firmware ZIP, Lua scripts).
– docs/: Documentation and screenshots.
• Configurations and Build Scripts
– pubspec.yaml/pubspec.lock: Flutter dependencies.
– .env.template: Environment variables (e.g., Google OAuth client IDs).
– Android Gradle files and iOS plist/config for permissions.
Extract Additional Insights from README
• Confirms use of Flutter, Google OAuth, Bluetooth Central & Peripheral, background modes, and location permissions.
• Describes regeneration of platform folders, hinting at platform channels for native-Flutter integration.
Of Main Components
a. Presentation Layer (Flutter UI)
• Pages (login, splash, pairing, noa, hack, tune, regulatory, account)
• Widgets (navigation bars, dialogs)
b. State & Business Logic Layer
• app_logic_model.dart
• state_machine.dart
• noa_api.dart (abstracts device or cloud API)
c. Services Layer
• BluetoothService (lib/util/bluetooth.dart)
• LocationService (lib/util/location.dart)
• ForegroundService (background execution code)
• AuthService (lib/util/sign_in.dart using Google OAuth)
d. Data & Device Layer
• Frame Hardware Device via BLE (connect, pair, send Lua scripts)
• Assets (Lua scripts for firmware control)
e. External Services
• Google OAuth endpoints
• Potential Cloud API (if noa_api.dart calls a remote server)
Relationships and Data Flows
• User interacts with Flutter UI → triggers AuthService → Google OAuth → returns tokens → stored in app_logic_model.
• UI navigates to Pairing → BluetoothService scans and pairs with Frame → underlying platform-specific code in android/ and ios/ invokes native BLE APIs → returns device handle.
• UI invokes commands (tune/hack pages) → StateMachine applies transitions → BluetoothService writes data (e.g., Lua scripts) → Frame executes firmware commands.
• LocationService fetches GPS data → used for regulatory compliance pages.
• ForegroundService keeps BLE connection alive in background.
Architectural Patterns and Principles
• Separation of Concerns: UI vs business logic vs services.
• Platform Abstraction: util/bluetooth.dart and util/location.dart wrap platform channels.
• State Machine: Handles complex device interaction flows.
• Modular Widgets: Reusable UI components for consistent design.
Detail Level
• Config files (.env, Info.plist entries) in a side note or callout.