How hieuwu/android-groceries-store works
Project Type & Purpose
• This is a full-stack mobile application (“Groceries Store”) built on Android.
• Purpose: enable users to browse products, manage a shopping cart, create orders, plan meals, and receive notifications. It demonstrates modern Android development (Clean Architecture, MVVM, Use Cases) and leverages Supabase as a backend.
File Structure Analysis
• Top level: build scripts, CI configs, docs, database dumps.
• “app/src/main/java/com/hieuwu/groceriesstore” subdivides into:
• presentation/ – UI layer (Activities, Fragments, Composables, ViewModels)
• domain/ – business logic (use cases, models, use case interfaces + implementations)
• data/ – repository implementations, local database (Room) DAOs/entities, network layer (Retrofit, DTOs)
• di/ – Hilt modules for providing dependencies (Database, Repositories, Use Cases, Dispatchers, Supabase, SharedPrefs)
• utilities/ & works/ – helpers (e.g., for FCM, WorkManager jobs)
• Assets and resources under res/ (layouts, navigation graphs, drawables, animations).
• Configs: google-services.json, Supabase config in DI module.
• Tests under app/src/test for unit testing domain use cases.
README Insights
• Architecture claims: Clean Architecture with Use Case pattern and MVVM.
• Technologies: Kotlin, Hilt, Room, Retrofit2, Moshi, Supabase, Firebase Cloud Messaging, WorkManager, Jetpack Compose UI elements.
a. Main Components
• Mobile Client UI (Presentation Layer)
• ViewModel Layer
• Domain Layer (Use Cases)
• Data Layer
• Local Data Source: Room Database + DAOs
• Remote Data Source: Supabase REST API via Retrofit/Moshi
• Dependency Injection (Hilt Modules)
• Background Workers: WorkManager jobs (e.g., RefreshDatabaseWork)
• Notification Service: Firebase Cloud Messaging
• External Services: Supabase backend, Firebase Cloud Messaging
b. Relationships & Interactions
• UI → ViewModel (state & events)
• ViewModel → Use Cases (invoke business logic)
• Use Cases → Repository Interface → Repository Implementation
• Repository Implementation chooses between Local (Room) or Remote (Supabase via ApiService)
• DI Graph wires up all interfaces to implementations
• WorkManager triggers background sync → Data Layer → updates local DB
• FCM receives push → Notification Service → UI or Data Layer
c. Architectural Patterns & Principles
• Clean Architecture with 3 layers (Presentation / Domain / Data)
• MVVM in Presentation
• Single Responsibility (Use Cases each handle one action)
• Dependency Inversion (repositories, use cases as interfaces injected by Hilt)
• Repository Pattern abstracting data sources
• Jetpack best practices (ViewModel, Lifecycle, Room, WorkManager)
d. Key Technologies & Frameworks
• Kotlin + Coroutines
• Hilt for DI
• Retrofit2 + Moshi for network
• Room for local persistence
• Supabase REST API (Auth, CRUD)
• Firebase Cloud Messaging for notifications
• WorkManager for scheduled database refresh
• Jetpack Compose widgets and XML layouts