2.8 KiB
2.8 KiB
Payfrit Food Android
Native Android app for the Payfrit Food product intelligence platform.
What It Does
Users scan food product barcodes, get health scores (0-100), NOVA processing classification (1-4), nutrition facts, ingredient analysis, and discover healthier alternatives from sponsors.
Stack
- Language: Kotlin
- UI: Jetpack Compose + Material 3
- Architecture: MVVM (ViewModel + StateFlow)
- Networking: Retrofit 2 + kotlinx.serialization
- Image Loading: Coil
- Barcode Scanning: CameraX + ML Kit
- Auth Storage: EncryptedSharedPreferences (Jetpack Security)
- Min SDK: 26 (Android 8.0)
- Target SDK: 34
API Base URLs
- Production:
https://food.payfrit.com/api - Dev:
https://dev.payfrit.com/api(set via BuildConfig)
Key Endpoints
GET /scan.php?barcode=X— product lookupGET /search.php?q=X— product searchGET /alternatives.php?productID=X— healthier alternativesPOST /user/login.php— email/password loginPOST /user/register.php— registrationGET /user/account.php— profileGET /user/scans.php— scan historyGET /user/favorites.php— favorites listPOST /user/favorites.php— add favoriteDELETE /user/favorites.php?productID=X— remove favoriteDELETE /user/account.php— delete account (GDPR)
Auth
- Bearer token via
Authorization: Bearer <token>header - Token stored in EncryptedSharedPreferences
- Public endpoints (scan, search, alternatives) work without auth
- User endpoints (history, favorites, account) require auth
Project Structure
com.payfrit.food/
├── PayfritFoodApp.kt # Application class
├── MainActivity.kt # Single activity
├── data/
│ ├── model/Models.kt # All data classes
│ ├── local/AuthStorage.kt # Encrypted token storage
│ ├── remote/FoodApiClient.kt # Retrofit API client
│ └── repository/ # ProductRepository, UserRepository
├── navigation/FoodNavHost.kt # Bottom tab + detail navigation
└── ui/
├── theme/ # Material 3 theme
├── components/ # ScoreRing, NOVABadge, DietaryPills, ProductCard
└── screens/
├── scan/ # Camera barcode scanner + manual entry
├── product/ # Product detail with scores, nutrition, ingredients
├── alternatives/ # Filtered alternatives list with sponsor cards
├── favorites/ # Saved products
├── history/ # Scan history
└── account/ # Login/register/profile/GDPR
Building
- Keystore passwords in
keystore.properties(gitignored) - Debug builds point to dev API
- Release builds point to production API