# Baskit Customer App

Flutter customer app for comparing grocery prices across **Pick n Pay**, **Checkers Sixty60**, and **Woolworths**. Phase 1 browsing MVP is live; Phase 2 UI (auth, Smart Split, checkout stub, Group Buy, profile) runs on local state until the CI4 API ships.

## Prerequisites
- [Flutter](https://docs.flutter.dev/get-started/install) 3.38+
- WAMP (or any PHP 8 + Apache) serving this repo at `http://localhost/baskit_app/`
- Network access to Dokploy MySQL (see `docs/dokploy-mysql-remote.md`)

## API setup

**Production (Dokploy):** `https://baskitapi.appnotify.co.za` — deployed from `api/docker-compose.yml` in the `baskit-worker` project.

**Local (WAMP):**
```bash
cp api/.env.php.example api/.env.php
# Edit api/.env.php — set db_pass and api_key
```

Smoke test:
```
https://baskitapi.appnotify.co.za/index.php?r=stats&key=baskit-prod-key-appnotify-2026
# Local: http://localhost/baskit_app/api/index.php?r=stats
```
Header: `X-Api-Key: <api_key>` (or `?key=` query for quick checks).

Routes: `aisles` · `products` · `product` · `deals` · `stats`

### Customer returns (Baskit Ops)
Post-delivery returns go to Ops (`BASKIT_OPS_API`), not the catalogue API:

- App: delivered order → **Return** → select item → photo + reason → submit
- Ops console: **Returns** nav → list / detail → approve or reject
- API: `POST /api/v1/returns` (multipart: `order_code`, `item_name`, `reason`, `photo`, optional `customer_email`) and `GET /api/v1/returns?order_code=…`

## Run the Flutter app
```bash
flutter pub get

# Chrome / desktop (defaults to production API)
flutter run -d chrome

# Physical phone on mobile data — no adb reverse needed
flutter run -d <device-id>

# Local WAMP API override
flutter run --dart-define=BASKIT_API=http://localhost/baskit_app/api \
            --dart-define=BASKIT_API_KEY=baskit-dev-key-change-me

# Android emulator — map host machine as 10.0.2.2
flutter run --dart-define=BASKIT_API=http://10.0.2.2/baskit_app/api \
            --dart-define=BASKIT_API_KEY=baskit-dev-key-change-me
```

## Project layout
```
api/                 Thin read-only PHP catalogue API
lib/
  theme/             Design tokens
  core/              ApiClient
  models/            Aisle, Product, …
  state/             BasketModel
  features/          onboarding, auth, home, shop, product, basket, smart-split,
                     checkout, group-buy, orders (returns), profile, shell
  widgets/           Shared UI
assets/              Category art + lockup from docs/ui
docs/                Specs, tasks, DB notes
```

## Design source
UI handoff lives in `docs/ui/`. Brand colours: olive `#2a2e13`, cream `#f5f2e3`, wheat `#ece4b5`, green `#5e891e`.

## Security
- Never commit `api/.env.php`.
- Prefer locking down Dokploy MySQL (firewall / SSH tunnel) before production traffic.
