Skip to content

zsculac/pantry

Repository files navigation

Pantry — AI Cooking Assistant

A personal cooking assistant for Android. Chat in Croatian (or English), manage your pantry and shopping list, and save recipes — all backed by your own Google Sheets and Google Docs.

Architecture: Expo app → Claude API (direct) + Google Apps Script Web App (your own Google account). No shared infrastructure, no Make.com, no service accounts.

Cost: ~€2/month at normal usage (Claude API only — everything else is free).


Prerequisites

  • Node.js 18+ and npm
  • Expo CLI: npm install -g expo-cli
  • EAS CLI: npm install -g eas-cli
  • A Google account (for Sheets, Docs, Apps Script)
  • An Anthropic account with a Claude API key

Step 1: Google Sheet Setup

  1. Go to sheets.google.com and create a new spreadsheet named "Pantry".
  2. Create 3 tabs with these exact names and headers (row 1):

Tab: Pantry | item | amount | unit |

Tab: Shopping List | item | amount | unit | checked |

Tab: Saved Recipes | recipe_name | doc_url | saved_date | doc_id |

Quick setup via CSV templates: The templates/ folder contains ready-made CSV files. In each tab: File → Import → Upload → select the matching CSV → choose "Replace current sheet" and "No" for automatic conversion.

  1. Note the Sheet ID from the URL: https://docs.google.com/spreadsheets/d/THIS_IS_YOUR_SHEET_ID/edit

Step 2: Deploy the Google Apps Script

  1. Go to script.google.comNew project
  2. Delete the default code and paste the contents of gas/Code.gs
  3. On line 10, replace 'YOUR_SHEET_ID_HERE' with your actual Sheet ID
  4. Click Deploy → New deployment
    • Type: Web app
    • Execute as: Me
    • Who has access: Anyone
  5. Click Deploy → authorize when prompted → copy the Web App URL

The URL looks like: https://script.google.com/macros/s/AKfycb.../exec

Important: Each time you modify the script, you must create a new deployment (not edit existing) for changes to take effect.


Step 3: Get a Claude API Key

  1. Go to console.anthropic.com
  2. Create an API key
  3. Set a spending limit (~€5/month is safe for personal use)

Step 4: Clone and Install

git clone <repo-url>
cd pantry
npm install

Step 5: First Launch (Setup Screen)

When you first open the app, you'll see a setup screen asking for:

  • Claude API Key — from Step 3
  • Google Apps Script URL — from Step 2

These are stored encrypted on your device using Android Keystore. They are never committed to source code.


Step 6: Build the APK

Option A: EAS Cloud Build (easiest, no local setup required)

# Log in to EAS (one-time)
npx eas-cli login

# Build APK for Android
npx eas-cli build --profile preview --platform android
  1. EAS will build in the cloud (~5–10 minutes)
  2. Download the .apk from the EAS dashboard
  3. Send it to your phones via WhatsApp, Drive, or email
  4. On each phone: enable "Install from unknown sources" → install the APK
  5. Each person enters their own keys on first launch

Note: The free EAS plan allows a limited number of Android builds per month. If you hit the limit, use Option B.

Option B: Local Build (requires Android Studio)

Prerequisites:

  1. Install Android Studio — this installs the Android SDK
  2. In Android Studio → Settings → Languages & Frameworks → Android SDK → SDK Tools: install NDK (Side by side) and CMake
  3. Install JDK 17: brew install --cask temurin@17
  4. Add to ~/.zshrc:
    export ANDROID_HOME=$HOME/Library/Android/sdk
    export PATH=$PATH:$ANDROID_HOME/platform-tools
    export JAVA_HOME=$(/usr/libexec/java_home -v 17)
  5. Reload: source ~/.zshrc

Build:

npx eas-cli build --profile preview --platform android --local

The .apk will appear in the project root when the build completes (~10–20 minutes).


Updating the App

Rebuild and resend:

npx eas-cli build --profile preview --platform android

Download the new APK → send to phones → install (replaces existing, keeps data).


Verification Checklist

  • curl -X POST <GAS_URL> -H "Content-Type: application/json" -d '{"action":"read_pantry"}' returns []
  • Chat responds in Croatian with metric measurements
  • "Što imam u smočnici?" → Claude calls read_pantry, reports pantry contents
  • "Potrošili smo jednu limenku graha" → GAS updates existing pantry row (not duplicate)
  • "Dodaj rajčice na listu kupovine" → new row appears in Shopping List tab
  • "Spremi ovaj recept" → Google Doc created, URL in Saved Recipes tab, readable without login
  • Adding item on phone 1 → appears on phone 2 after opening Pantry tab

Project Structure

pantry/
  gas/
    Code.gs              # Google Apps Script — paste into script.google.com
  src/
    api/
      claude.ts          # Claude API client, tool definitions, agentic loop
      gas.ts             # All GAS Web App calls
    screens/
      SetupScreen.tsx    # First-launch: enter keys
      ChatListScreen.tsx # Session list (grouped by date)
      ChatScreen.tsx     # Chat UI with tool execution loop
      PantryScreen.tsx   # Pantry management
      ShoppingScreen.tsx # Shopping list with check-off
      RecipesScreen.tsx  # Saved recipes (opens Google Docs)
      SettingsScreen.tsx # Update keys, language, clear data
    storage/
      sessions.ts        # AsyncStorage: chat session CRUD
      secureConfig.ts    # expo-secure-store wrapper
    types/
      index.ts           # Shared TypeScript types
    constants/
      systemPrompt.ts    # System prompt (Croatian/English cooking assistant)
  App.tsx                # Navigation setup
  app.json               # Expo config
  eas.json               # EAS Build profiles

Security Notes

  • Claude API key and GAS URL are stored in Android Keystore via expo-secure-store (hardware-backed AES encryption)
  • Chat history is stored in AsyncStorage (plaintext, on-device only — not sensitive)
  • No secrets in source code or APK bundle
  • The GAS URL can only do what the script allows (read/write your specific Sheet + create Docs)
  • Each user deploys their own GAS instance — no shared credentials

Language

The app defaults to Croatian. You can switch to English in Settings. The system prompt instructs the AI to respond in the selected language regardless of what language you type in.


Troubleshooting

"Cannot connect" — check your internet connection. If the problem persists, verify the GAS URL is correct in Settings.

"Error connecting to AI" — check your Claude API key in Settings. You may have run out of credit.

AI responds in English — go to Settings → Language → switch to Croatian.

Something wrong in the pantry — you can edit the Google Sheet directly; changes will appear in the app after opening the Pantry tab.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors