Instructions to run SafeWay from scratch (backend + frontend) on Android emulator or physical device.
- Node.js and npm (for frontend)
- Python 3.11+ (for backend)
- Android: Android Studio (emulator) or a physical device with USB debugging
- Supabase project (for auth and DB)
- Google Cloud project with:
- Maps SDK for Android enabled
- Geocoding API enabled (for backend)
- API keys created (one for Android app, one optional for server)
From the repo root (where requirements.txt lives):
pip install -r requirements.txtOptional: use a virtual environment:
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
pip install -r requirements.txtIn backend/:
cp .env.example .envEdit backend/.env and set:
| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string (e.g. from Supabase: postgresql://postgres:PASSWORD@PROJECT.supabase.co:5432/postgres) |
SUPABASE_URL |
https://PROJECT.supabase.co |
SUPABASE_PUBLISHABLE_KEY |
Supabase anon/public key |
GOOGLE_MAPS_API_KEY |
Server-side Google API key (Geocoding, etc.) |
cd frontend
npm installIn frontend/:
cp .env.example .envEdit frontend/.env and set:
| Variable | Description |
|---|---|
EXPO_PUBLIC_SUPABASE_URL |
Same as backend SUPABASE_URL |
EXPO_PUBLIC_SUPABASE_ANON_KEY |
Same as backend SUPABASE_PUBLISHABLE_KEY |
EXPO_PUBLIC_API_BASE_URL |
Backend URL the app will call (see table below) |
EXPO_PUBLIC_GOOGLE_MAPS_API_KEY |
Google Maps API key for the Android app (required for maps) |
Important: Expo only loads variables prefixed with EXPO_PUBLIC_. The Maps key must be EXPO_PUBLIC_GOOGLE_MAPS_API_KEY so it is available in app.config.ts and the map works.
| Setup | EXPO_PUBLIC_API_BASE_URL |
|---|---|
| Android Emulator | http://10.0.2.2:8000 |
| Physical device (same Wi‑Fi as PC) | http://YOUR_PC_IP:8000 (e.g. http://192.168.1.105:8000 — get IP from ipconfig) |
| Physical device (USB + adb reverse) | http://localhost:8000 (after running adb reverse tcp:8000 tcp:8000) |
In Supabase Dashboard → Authentication → Providers → Google:
- Enable Google and set OAuth client ID/secret.
- Add redirect URL:
safeway://auth/callback - For local Expo, add the redirect URI from
Linking.createURL('auth/callback')if needed.
You need two processes: backend and frontend.
cd backend
uvicorn main:app --reload --host 0.0.0.0 --port 8000Leave this running. The API will be at http://localhost:8000 (and on your LAN at http://0.0.0.0:8000 when using a physical device).
In a second terminal:
cd frontend
npx expo start- Android emulator: Press
ain the Expo terminal (or ensure the emulator is running and Expo will offer to open on it). - Physical device: Scan the QR code with Expo Go, or press
aif the device is connected via USB and detected. - Web: Press
w(if supported).
If the phone is connected by cable and you want the app to use the backend without Wi‑Fi:
- Connect the phone via USB and enable USB debugging.
- Run once per session:
adb reverse tcp:8000 tcp:8000
- In
frontend/.envsetEXPO_PUBLIC_API_BASE_URL=http://localhost:8000. - Restart Expo and open the app on the device.
If you see a “no API key” or “api=your api key” error:
- In
frontend/.envuseEXPO_PUBLIC_GOOGLE_MAPS_API_KEY(notGOOGLE_MAPS_API_KEY) and set it to your real key. - Restart Expo (
npx expo start). - Rebuild the Android app so the key is baked in:
Or:
cd frontend npx expo run:androidnpx expo prebuild --cleanthennpx expo run:android.
| Step | Where | Action |
|---|---|---|
| 1 | Repo root | pip install -r requirements.txt |
| 2 | backend/ |
Copy .env.example → .env, fill Supabase + Google key |
| 3 | frontend/ |
npm install |
| 4 | frontend/ |
Copy .env.example → .env, set all EXPO_PUBLIC_* and API base URL |
| 5 | Terminal 1 | cd backend → uvicorn main:app --reload --host 0.0.0.0 --port 8000 |
| 6 | Terminal 2 | cd frontend → npx expo start → press a for Android |
Both backend and frontend must be running at the same time.