On this page
It is 9pm, the fridge has half an onion, two eggs, leftover rice and a sad capsicum, and ordering in feels like defeat. This brief builds a helper for exactly that moment: take a photo of the fridge or type what is there, check the ingredient list the AI suggests, and get three meal ideas that fit the time you have. Android comes first because CameraX and the photo picker make capture quick and Room keeps saved ideas offline; the iPhone version uses PhotosPicker and SwiftData and needs a Mac with Xcode to build. The AI request goes through a backend function in your own Supabase that holds your provider key. The first proof: a typed list of five ingredients returns three ideas that use only those items plus basic staples.
Screens
- Fridge: Take a photo, choose one from the gallery or type ingredients as quick chips.
- Check list: The ingredients the AI found, each removable or editable, plus anything you add.
- Ideas: Three cards with a name, time, difficulty and which of your ingredients each uses.
- Recipe: Short numbered steps, a servings switch and a missing-items list if any.
- Saved and settings: Favourite ideas, diet and allergy filters, cooking time limit and AI on or off.
Data model
| Table | Key fields | Purpose |
|---|---|---|
| pantry_items | id (uuid), name (text), added_at (timestamptz), source (text) | What the user confirmed they have, whether typed or found in a photo. |
| preferences | id (int), diet (text), allergies (text[]), max_minutes (int), staples (text[]) | Rules sent with every request, such as vegetarian, no peanuts and under 20 minutes. |
| saved_ideas | id (uuid), title (text), minutes (int), ingredients (jsonb), steps (jsonb), saved_at (timestamptz) | Ideas the user kept, readable offline without another AI call. |
| ai_requests | id (uuid), kind (text), created_at (timestamptz), status (text) | A local log of calls for rate limits and error messages, with no photo or text stored. |
The app itself never holds an AI key. When the user taps Find ingredients or Get ideas, the app sends a downscaled photo or the confirmed ingredient list, plus preferences, to a backend function in your own Supabase, such as an Edge Function. That function holds your provider key, checks a signed-in user or per-install token, limits calls per day and returns structured JSON. It should not store photos or ingredient lists. Saved ideas live on the phone in Room or SwiftData.
Native features
Two separate AI steps keep this honest. First, the photo becomes a suggested ingredient list, which the user must confirm, because a model can mistake yoghurt for cream or miss what is behind the milk. Second, only the confirmed list and preferences produce meal ideas. Ask the function to return a fixed JSON shape and validate it in the app, so a strange reply shows a friendly error instead of a broken card.
| Feature | Android (Kotlin) | iPhone (SwiftUI) | Notes |
|---|---|---|---|
| Capturing the fridge | CameraX ImageCapture or the photo picker | PhotosPicker or a camera sheet | Downscale to about 1024 pixels and strip location data before sending. |
| Calling the AI | Ktor or OkHttp to your Supabase Edge Function | URLSession to the same Edge Function | Send only on tap, with a timeout and a cancel button. |
| Structured results | kotlinx.serialization with a strict schema | Codable with a strict schema | Reject replies missing a title, time or steps rather than guessing. |
| Cooking mode | Keep the screen on while a recipe is open | isIdleTimerDisabled while a recipe is open | Large step text and a next-step button for messy hands. |
Android notes (Kotlin and Jetpack Compose)
Run every network call from a ViewModel with a cancellable coroutine, and keep the ingredient chips editable while a request is in flight. A slow reply should never freeze the screen or overwrite edits the user made in the meantime.
- Compress the captured photo off the main thread, remove EXIF metadata, and send it as base64 or multipart to the function only after the user taps Find ingredients. Show the photo locally while waiting so the user can confirm it is the right shot.
- Parse the reply into data classes and filter ideas on the device as a second guard: drop any idea listing an allergen from preferences and tell the user one was removed.
- On a real phone, photograph a real fridge shelf, correct the suggested list, request ideas and save one. Then go offline and confirm the saved recipe opens fully while the Get ideas button explains it needs a connection.
iPhone notes (Swift and SwiftUI)
On iPhone, PhotosPicker and a camera sheet cover capture, and SwiftData keeps preferences and saved ideas. Use async URLSession calls tied to the view's task so leaving the screen cancels a pending request.
- Resize images with UIGraphicsImageRenderer before upload and send them without metadata, then decode the function's JSON with Codable into strongly typed idea structs.
- Keep the screen awake in Cooking mode with isIdleTimerDisabled and turn it off when the recipe closes or the app moves to the background.
- Test on a physical iPhone for the camera path; in the Simulator, test with gallery images and typed ingredients, and check VoiceOver reads each step in order.
Copy-paste prompt
Every night I open the fridge, see random leftovers and just order food. Build me an AI meal ideas app for Android. Screens: Fridge, Check list, Ideas, Recipe, and Saved and settings. I can snap a photo of my fridge, pick one from the gallery or type ingredients as chips. The AI suggests an ingredient list from the photo and I must confirm or edit it before anything else happens. Then show three meal ideas that fit my time limit, diet and allergies, using only my ingredients plus staples like salt, oil and spices. Each idea gets short steps, a servings switch and a cooking mode that keeps the screen on. Send data only when I tap, downscale photos and strip location. The AI call must go through a backend function in my own Supabase that holds my API key; never put a key in the app, and do not store my photos. Save ideas offline. Acceptance: five typed ingredients return three ideas that use only those plus staples.
Opens Apirex with this prompt in the box. Pick the Android · Kotlin tab before you send.
Acceptance test
- Type five ingredients, set a 20-minute limit and request ideas; confirm three cards appear and none needs an ingredient outside the list and staples.
- Take a fridge photo, check the suggested list, remove one wrong item and add a missing one; confirm the ideas reflect the corrected list.
- Set a peanut allergy and request ideas again; confirm no idea includes peanuts and the app mentions if one was filtered out.
- Turn on airplane mode, open a saved idea and confirm it works, then tap Get ideas and confirm a clear offline message.
- Inspect the release build for any provider key and confirm none exists; the only network target is your own Supabase function.
Check the backend function as carefully as the app. Call it without a valid user or token and confirm it refuses. Call it many times quickly and confirm the rate limit returns a clear message. Look at the function logs and storage and confirm no photo or ingredient list was kept. Finally, add a short line in the app reminding users to check allergens themselves, because AI suggestions can be wrong.
Frequently asked questions
Can the AI really see what is in my fridge?
It can suggest a list from a clear photo, but it will miss hidden items and sometimes mislabel things. That is why the brief makes you confirm the ingredient list before any meal ideas are generated.
Where does my photo go?
Only to the backend function in your own Supabase, and only when you tap. The function forwards it to your AI provider with your key and should not store it. Typing ingredients avoids sending a photo at all.
Are the recipes safe for allergies?
The app filters ideas against the allergies you set and the function is told to avoid them, but AI can still make mistakes. Always check ingredients yourself, especially for serious allergies.
Build this blueprint
The blueprint prompt, ready for your platform. Edit anything before you send it.
Opens Apirex with this prompt. Pick the Android · Kotlin tab before you send. The Free plan includes 5 Rex Credits a day.