{"success":true,"name":"luipay-deploy","description":"Use for LuiPay: deploy, local stack, accounts, prod data.","category":"brimind","path":"brimind/luipay-deploy/SKILL.md","file":"SKILL.md","content":"---\nname: luipay-deploy\ndescription: \"Use for LuiPay: deploy, local stack, accounts, prod data.\"\n---\n\n# LuiPay operations (deploy, local stack, accounts, data)\n\n## Always-on rules\n\n- **The local stack is production.** `npm run dev` (in the repo root) points at the prod\n  MongoDB cluster (`AliMoney`), and FedaPay usually runs **LIVE**. Every console\n  action on localhost:3000 changes real users' wallets, so say this whenever the user tests or edits data.\n- **Passwords can't be read back** (they are stored salted and hashed). Never offer to \"find\" one. For an admin,\n  give the user the `scripts/upsert-admin.mjs` command to run **themselves**,\n  so the password never passes through chat. App users are reset from the console.\n- Results go in a colored table (🟢/🟡/🔴/⚪) with a few lines around it. On an ambiguous\n  ask (for example \"real account not test\"), ask a clarify question with concrete options.\n- The user writes in short fragments (\"it was sending\", \"not card, a normal tag\"). When a\n  reading is unsure, ask ONE clarify question with concrete options before writing code.\n  When something is impossible on a platform (for example, an iPhone being read by NFC), say so\n  in one line, then build the nearest working alternative. Don't argue about it.\n- When the user says a feature \"was working before\", start with `git log` on that feature's files\n  and diff the commit that touched them. Broad \"backup\"/cleanup commits have silently removed features.\n- Verify against data (an API login or wallet call, a DB query), not docs: HANDOFF.md\n  credentials (`ali@`/`awa@ admin1234`) are stale.\n\n- **Phones hit `core.luipay.app`, not localhost.** To find out why a payment from a phone\n  failed, read the prod container log on the verified deployment host (`docker logs --since 40m alimoney-api-1`),\n  not the local `npm run dev` output. Remember the flat 600 XOF transfer fee and that test accounts\n  can't pay real ones. Advise testers to use two **real** accounts that have a balance.\n\nLocal run, test accounts, \"real users + balances\" queries and the prod-equality\ncheck: see `references/local-dev-and-data.md`.\nMoney not arriving / NFC or QR payment failing (log reading, status→cause table,\niPhone NFC limits): see `references/payment-failure-diagnosis.md`.\n\n# Deployment\n\nLuiPay (money-transfer app for Niger, package `pro.brimind.luipay.niger`) runs\nfrom the `Alicent` monorepo (`[PATH]` locally)\nonto a [PRIVATE_HOST]. From [PRIVATE_HOST], start with `ssh -o BatchMode=yes -o ConnectTimeout=5 [PRIVATE_HOST] 'docker ps --format \"{{.Names}}\"'` and confirm the expected `alimoney-*` containers before operating. Use the SSH alias configured on the machine executing the command; verify the stack rather than assuming a [PRIVATE_HOST] alias points to LuiPay. Set `LUIPAY_HOST` to that verified alias before running the commands below.\n\n## Where things live\n\n| Host | Serves |\n|---|---|\n| `luipay.app` | `apps/site` — public site, invite links, download buttons |\n| `core.luipay.app` | `services/core` — ledger + admin API |\n| `dash.luipay.app` | `apps/web` — admin console |\n| `sms.luipay.app` | WhatsApp pairing page |\n\n- Compose stack on the [PRIVATE_HOST]: `[PATH]` (needs `sudo`; the plain user\n  has no access). `/docker/alimoney` also exists on the box but is a stale\n  empty decoy — ignore it, don't edit its `.env`.\n- All runtime config is in `[PATH]` (gitignored, [PRIVATE_HOST]-only — the\n  repo's local `.env` files are not what's live). Grep it with\n  `ssh \"$LUIPAY_HOST\" \"sudo grep -n '<VAR>' [PATH]\"` before assuming\n  a value is unset.\n- `docs/deploy.md` and each app's `README.md` in the repo document every env\n  var's meaning — read those to find the right variable name, then go set it\n  on the [PRIVATE_HOST], not in the repo.\n\n## Recovering WhatsApp login-code delivery\n\n1. `GET https://sms.luipay.app/status` and read the JSON `status` before touching production. `qr` means the sender is waiting for a device scan. A 401 from the bare `/qr` page means the pairing key is missing or invalid, not that the QR service is down; do not restart or reset the sender for that 401.\n2. On the verified production host, read the WhatsApp startup line with `docker logs alimoney-whatsapp-1 2>&1 | grep -F '[whatsapp] appairage :' | tail -n 1`. Search the retained log, not just recent lines: the URL is printed at startup. Keep the log output and key out of transcripts and files by capturing and filtering them inside `execute_code`. Replace the logged localhost origin with `https://sms.luipay.app`, preserving the entire `/qr?k=…` path and query verbatim.\n3. Fetch the resulting HTTPS URL privately and verify both HTTP 200 and the rendered QR image (`alt=\"QR code d'appairage\"`); an HTML page alone can be a waiting or already-paired screen. Share the verified link only with the authorized operator who requested it: the same key also guards repair and logout. Never persist the key in a skill or memory, paste it into external tools, or use reset/logout to test the link.\n4. Have the operator open the QR on another screen and scan on the sender phone via **WhatsApp → Linked Devices → Link a Device**. Report **QR verified; scan pending**, not **delivery restored**. After the scan, recheck `/status` for a connected sender. Confirm end-to-end delivery only with an authorized test login that actually receives a code.\n\n## Deploying a core (API) code change\n\n`[PATH]` on the [PRIVATE_HOST] is a git checkout (often behind local). If `git diff <[PRIVATE_HOST] HEAD> -- services/core`\nlocally shows only your change, push the files with `ssh \"$LUIPAY_HOST\" \"sudo cp F F.bak-x && sudo tee F\" < F`,\nthen `sudo docker compose up -d --build api` (compose service is `api`, container `alimoney-api-1`).\nTo check a new route exists, curl it without auth: 401 means it exists, 404 means it doesn't.\n\n## Building the app and putting it on a phone\n\n1. Toolchain: Flutter/Android SDK live only on the DevSSD sparsebundle (the `flutter` shell\n   function just prints a hint). Run `~/.devssd/mount.sh` first. It attaches the bundle from\n   `/Volumes/SSD ext` (SSD on the Mac) or from `/Volumes/[PRIVATE_HOST]-SSD_ext` (SSD on the [PRIVATE_HOST], over SMB).\n   Over SMB it uses a local `-shadow` file, because an attach without a shadow is read-only\n   and Flutter dies with \"Operation not supported\". Then run\n   `source ~/.devssd/env.sh && export PATH=\"$FLUTTER_ROOT/bin:$PATH\"`.\n2. Check before building: `flutter gen-l10n` (after any `.arb` edit; French `app_fr.arb` is the\n   template), `flutter analyze lib`, then the feature's tests. Each step takes minutes over SMB,\n   so run it in the background with notify.\n3. iPhone: `flutter build ios --release` (automatic signing, team 325YR3A65N), then\n   `xcrun devicectl device install app --device <id> build/ios/iphoneos/Runner.app` and\n   `xcrun devicectl device process launch --device <id> brimind.luipay.niger`.\n   `kAMDMobileImageMounterDeviceLocked` means the phone is locked. Ask the user to unlock it and\n   retry in a loop (every 5 s) until you see \"App installed\".\n   Verify capabilities in the built app, not the repo:\n   `codesign -d --entitlements :- Runner.app` and `plutil -p Runner.app/Info.plist`.\n4. A feature that needs both phones (NFC, QR handoff) needs the **Android build too**. An\n   old APK on the other phone makes the new iPhone build look broken.\n\n## Changing a config value (store links, support contacts, API URLs, etc.)\n\n1. Find the var name in `docs/deploy.md` / `apps/<app>/README.md` (e.g.\n   `PUBLIC_PLAY_STORE_URL`, `PUBLIC_APP_STORE_URL`, `PUBLIC_SUPPORT_WHATSAPP`).\n2. Append/edit it in `[PATH]` on the [PRIVATE_HOST]:\n   `ssh \"$LUIPAY_HOST\" \"echo 'VAR=value' | sudo tee -a [PATH]\"`.\n3. **Rebuild, don't just restart** — `apps/site` and `apps/web` bake every\n   `NEXT_PUBLIC_*` var in at build time via Dockerfile `ARG`/`ENV`, so a plain\n   `docker compose restart` keeps serving the old value:\n   `ssh \"$LUIPAY_HOST\" \"cd [PATH] && sudo docker compose up -d --build <service>\"`\n   (compose service names: `site`, `web`, `api`, `whatsapp`; `core.luipay.app` is served by `api`).\n4. Verify live, don't trust the build log alone:\n   `curl -s https://luipay.app/ | grep -o '<expected string>'`.\n\n## Store listing\n\nPlay Store published URL for LuiPay:\n`https://play.google.com/store/apps/details?id=pro.brimind.luipay.niger`\n(confirm a listing is actually live, not just the ID being valid, by curling\nit and grepping for `itemprop=\"name\"` — Play returns HTTP 200 even for an\nunpublished/removed app page shell).\n\nUntil a store listing is public, `apps/site`'s download button logic\nautomatically falls back from `PLAY_STORE_URL` → `ANDROID_PLAY_TEST_URL`\n(open testing link) → APK → \"bientôt\" — so publishing just means setting\n`PUBLIC_PLAY_STORE_URL` and rebuilding; no component code changes needed.\n","linked_files":["references/local-dev-and-data.md","references/payment-failure-diagnosis.md"],"origin":"brimind","owner_id":null,"source":"router"}