How daiwanmaru/susu-car-seeker works
Purpose and Entry Points
速速找車 is a Flutter Android/iOS parking-memory app: it records a parking session locally, helps locate the vehicle, tracks bills, and calculates time-based charges. The Flutter bootstrap is lib/main.dart, which composes the application shell in lib/app/susu_app.dart; Android and iOS host it through android/app/src/main/kotlin/tw/susuparking/susu_parking/MainActivity.kt and ios/Runner/AppDelegate.swift.
Application Composition and State
lib/app/app_scope.dart is the dependency/state boundary for app-wide services and repositories. lib/app/app_controller.dart coordinates startup, authentication/session restoration, and app-level state; lib/app/app_theme.dart provides shared presentation configuration. lib/screens/main_shell.dart is the authenticated navigation container, while lib/screens/login_screen.dart gates access through Google sign-in or debug preview mode.
Local-First Parking Domain
The authoritative user data remains on-device. Domain entities and pure pricing/time logic are separated in lib/domain/models.dart and lib/domain/parking_calculator.dart. Parking sessions are created/edited, restored after relaunch, and ended through UI stages including lib/screens/home_screen.dart, lib/screens/edit_parking_screen.dart, and lib/screens/find_vehicle_screen.dart. Derived values—elapsed duration, fee estimate, and next billing point—are recalculated from persisted facts rather than stored as authoritative aggregates.
Persistence, Bills, and History
SQLite access is centralized in lib/data/app_database.dart; lib/data/parking_repository.dart owns parking sessions, bills, photos, and deletion workflows. App preferences such as feature/settings state belong in lib/data/settings_repository.dart. The main downstream flow is: screens/controller invoke repository operations; SQLite retains parking facts and local media references; history and detail screens read those records to render active/history states. Relevant UI boundaries are lib/screens/bill_form_screen.dart, lib/screens/history_screen.dart, and lib/screens/history_detail_screen.dart.
Device Integrations
Platform-facing capabilities are isolated behind services: GPS permission/high-accuracy location in lib/services/location_service.dart, map handoff in lib/services/map_service.dart, and local photo capture/storage in lib/services/media_service.dart. lib/services/notification_service.dart schedules local reminders before the next charge point. These integrations feed local session data; parking records, images, and bills are not uploaded to the account backend.
Authentication and Remote Account Boundary
lib/services/auth_service.dart manages Google identity, offline restoration, and the development preview path. lib/services/backend_service.dart calls the narrowly scoped account API. The Cloudflare Worker implementation is backend/src/index.ts, deployed/configured through backend/wrangler.jsonc, with user/account state held in Cloudflare D1 according to backend/schema.sql. Its boundary is intentionally limited to validating Google ID tokens and maintaining user ID, account status, and last-login metadata.
Monetization and Platform Delivery
Ads and entitlement purchases are client-side integrations: lib/services/purchase_service.dart handles the non-consumable remove_ads purchase/restore flow, while ad configuration is supplied via Flutter build defines. Flutter packages and runtime dependencies are declared in pubspec.yaml; native Android/iOS packaging remains under android/app/ and ios/Runner/. External production dependencies are Google OAuth, Cloudflare Workers/D1, optional AdMob banner inventory, and Play/App Store in-app purchase catalogs.
Main entry points: home_screen.dart Parking workflow · parking_repository.dart Parking repository · app_scope.dart App scope · app_controller.dart App controller
Components 21
Flutter app
- Flutter bootstrap
lib/main.dart - App shell
lib/app/susu_app.dart - App scope · Provides app-wide services and repositories.
lib/app/app_scope.dart - App controller · Coordinates startup and session restoration.
lib/app/app_controller.dart - Login gate
lib/screens/login_screen.dart - Main navigation
lib/screens/main_shell.dart - Parking workflow · Create, edit, and locate active parking sessions.
lib/screens/home_screen.dart - Bills and history · Renders bills, historical sessions, and details.
lib/screens/history_screen.dart
Local-first data
- Parking domain · Calculates duration, fees, and next billing point from facts.
lib/domain/parking_calculator.dart - Parking repository · Owns sessions, bills, photos, and deletion workflows.
lib/data/parking_repository.dart - SQLite database · Retains parking facts and local media references.
lib/data/app_database.dart - Settings repository
lib/data/settings_repository.dart
Device integrations
- Auth service · Handles Google identity, offline restoration, and debug preview.
lib/services/auth_service.dart - Location service
lib/services/location_service.dart - Map service
lib/services/map_service.dart - Media service
lib/services/media_service.dart - Notification service · Schedules reminders before the next charge point.
lib/services/notification_service.dart - Purchase service · Handles remove-ads purchase and restore.
lib/services/purchase_service.dart
Account backend
- Account API client · Calls the narrow account API only.
lib/services/backend_service.dart - Cloudflare Worker · Validates Google tokens and maintains account metadata.
backend/src/index.ts - Cloudflare D1 · Stores user ID, status, and last-login metadata.
backend/schema.sql
Connections 22
- Flutter bootstrap → App shell: starts
- App shell → App scope: composes
- App scope → App controller: provides
- App controller → Login gate: gates access
- Login gate → Auth service: signs in
- App controller → Main navigation: opens after session
- Main navigation → Parking workflow: navigates
- Main navigation → Bills and history: navigates
- Parking workflow → Parking repository: creates and updates
- Bills and history → Parking repository: reads records
- Parking repository → SQLite database: persists
- Parking workflow → Parking domain: calculates
- Parking repository → Parking domain: derives values
- Parking workflow → Location service: captures location
- Parking workflow → Map service: opens navigation
- Parking workflow → Media service: stores photos
- Parking repository → Notification service: schedules charge reminders
- App scope → Settings repository: provides
- App scope → Purchase service: provides
- Auth service → Account API client: syncs account identity
- Account API client → Cloudflare Worker: calls
- Cloudflare Worker → Cloudflare D1: maintains account state