Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / globalesim / AGENTS.md

AGENTS.md3.7 KiBRenderedCodeRaw
1# AGENTS.md — globalesim/ (':globalesim')
2
3> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `globalesim/` + allowed shared modules. Do not root-scan.
4
5_Install: ./install globalesim (dev by default)._
6<!-- last-reviewed: 2026-10-24 -->
7- Gradle: :globalesim / dir: globalesim/
8- Package roots present: ui, data, domain, platform
9- Entry files: MainActivity.kt, Route.kt, Navigation.kt
10- Deps: :library:network, :library:log, :library:ui (via conventions), androidx.datastore.preferences, stripe-android
11- Metadata: metadata_data/globalesim.md (present)
12- Rust: no / screenshotTest: yes
13
14## Overview
15**Purpose:** Travel data eSIM storefront. One global eSIM per anonymous account — top up USD credit, data deducts at the local per-country rate. Credit never expires.
16**Key features:**
17- Pay-first: no eSIM until the first top-up ($5 min, card or crypto); the server keeps a $3 setup fee and funds the rest
18- Anonymous account (client-minted UUIDv4, no PII). The account id is the only credential and is shown as the "SIM ID": Copy SIM ID on the old phone, Claim on a phone without an eSIM
19- Rate catalog (server-scaled to the wallet's face value), Stripe card and NOWPayments crypto (+5%) top-ups, $5–$20 per payment
20- One-tap install via the standard `https://esimsetup.android.com/esim_qrcode_provisioning?carddata=LPA:1$<smdp>$<code>` link (unpinned ACTION_VIEW, raw carddata)
21**Architecture / data-flow:** `ui/` screens → `platform/EsimViewModel` (single `EsimUiState`) → `data/api/EsimApi` (own `/esim/v1/*` on api.maproj.org, FIRST_PARTY) with pure `domain/QuoteMath` and `data/AnonymousIdStore` (DataStore UUID). The reseller vendor is server-only (`location_share_server/src/handlers/esim*.rs`) and never named here.
22**Entry points + reading order:** `Route.Tabs` (Purchase + Pricing tabs, no other routes) → `MainActivity.kt` → `Navigation.kt` → `platform/EsimViewModel.kt` → `data/api/EsimApi.kt`.
23**Gotchas:**
24- After any payment the ViewModel polls `/status` until the wallet rises (server-owned pending checkout + `pending_credit_cents` keep it going); pull-to-refresh on Purchase reloads status
25- One open crypto checkout per account, owned by the server and restored from `/status`
26- PaymentSheet presents each client secret once (saved across recreation); cleared on done/cancel
27- ViewModel messages are shown once by the tab host in `Navigation.kt`, not by the screens
28- Never log the account id / SIM ID; the clipboard copy is flagged sensitive
29- Install shows no QR/code — same-phone QR is unscannable; direct LPA handoff only
30- `rememberPaymentSheet` is deprecated in stripe-android 23.x (same as fooddelivery); leave until repo migrates
31
32## Key files
33### Root — entry + navigation
34- com/vayunmathur/globalesim/MainActivity.kt
35- com/vayunmathur/globalesim/Navigation.kt
36- com/vayunmathur/globalesim/Route.kt
37### data/ — api + anonymous id
38- com/vayunmathur/globalesim/data/api/EsimApi.kt — BASE_URL + url(path) + NetworkClient calls
39- com/vayunmathur/globalesim/data/api/EsimDtos.kt — generic DTOs only, no vendor strings
40- com/vayunmathur/globalesim/data/AnonymousIdStore.kt
41### domain/ — pure logic (no Android)
42- com/vayunmathur/globalesim/domain/QuoteMath.kt — payment bounds, cents formatting/parsing
43- com/vayunmathur/globalesim/domain/CheckoutUrls.kt
44- com/vayunmathur/globalesim/domain/EsimActivationCode.kt
45### platform/ — ViewModel
46- com/vayunmathur/globalesim/platform/EsimViewModel.kt
47### ui/ — one public @Composable per file
48- com/vayunmathur/globalesim/ui/HomeScreen.kt — Purchase tab (balance, top-up, install, Copy SIM ID / Claim)
49- com/vayunmathur/globalesim/ui/PricingScreen.kt — Pricing tab
50
51## Verify (this module only)
52```
53./gradlew :globalesim:compileDevKotlin
54./gradlew :globalesim:lint
55./gradlew :globalesim:testDevUnitTest
56```