Skip to content

Mobile (Native iOS/Android)

The customer mobile clients are two native apps: apps/ios-user (Swift + SwiftUI) and apps/android/app-user (Kotlin + Jetpack Compose) — same customer-facing scope, same backend. The agent dashboard is likewise native (apps/ios-agent + apps/android/app-agent) on this same stack.

Both live in the monorepo as plain directories — no Turborepo / bun-workspace participation, so bun run check does not cover them. They consume the existing apps/api host (tRPC + Better Auth + image proxy) with zero backend changes.

Per-app dev notes live in apps/ios-user/CLAUDE.md and apps/android/app-user/CLAUDE.md. Native glue (i18n catalogs, fan-out + parity scripts, Firebase builds) lives under native/, decoupled from web/backend code — see PRO-70 for the seam rules.

Concernapps/ios-userapps/android/app-user
LanguageSwift 5, async/awaitKotlin 2.1, JVM target 17
UISwiftUI, NavigationStackJetpack Compose + Material 3, Navigation Compose (plain string routes)
Min targetiOS 17SDK 26
PatternMVVM-lite — @Observable ViewModel per screenStateFlow + ViewModel per screen (coroutines)
DIManual via AppEnvironmentManual AppContainer singleton — no Hilt
NetworkingURLSessionOkHttp 4 — no Retrofit
SerializationCodable + SuperJSON envelopekotlinx.serialization + SuperJSON envelope
Auth storageKeychainEncryptedSharedPreferences
Project genXcodeGen — IosUser.xcodeproj is gitignored, project.yml is source of truthGradle 8.14 wrapper, single :app module
Google sign-inGoogleSignIn-iOSandroidx Credential Manager
ImagesKingfisherCoil 3

Native files follow platform convention — PascalCase matching the primary type (AuthClient.swift, TrpcClient.kt), which overrides the repo-wide kebab-case rule for these two apps only. Android res/ resources stay snake_case (hyphens are a build error there).

Each app is a single target split into three layers — App/ (entry point, root navigation, DI container), Core/ (the app’s own SDK-bound glue: Google Sign-In, StreamChat, Knock/push, Sentry, app chrome, app-specific endpoints), and Features/ (one folder per screen group). The infrastructure the user and agent apps share — tRPC transport, cookie auth, session/settings stores, i18n loader, formatters, generated models, shared endpoint clients — lives in one module per platform: the MeridianCore SwiftPM package (native/MeridianCore, re-exported into each app via App/MeridianCoreExports.swift) and the :core:network Gradle module (apps/android/core/network, packages com.realestatecore.core.*). Both are dependency-free; per-app values are injected (ADR-0031). Android mirrors this under com.realestatecore.user: root files (App, MainActivity, Navigation, AppContainer) + core/ + features/ packages.

  • Navigation — a five-tab shell: Search · Discovery (Home) · Favorites · Inbox · Menu. Search and Discovery are browsable signed-out; Favorites, Inbox, and Menu are auth-gated and render a SignInPrompt when signed out. iOS wraps each tab in its own NavigationStack inside a TabView; Android drives the whole shell from a single flat NavHost of string routes (the auth flow is a nested navigation("auth") graph), with the bottom bar shown only on the five tab roots. Sub-screens (property detail, settings, tours, compare…) present over the tab shell with a vertical cover transition, drilling deeper between sub-screens pushes horizontally, and tab switches have no directional slide — the same motion on both platforms (iOS .fullScreenCover + NavigationStack push + TabView; Android a global Navigation-Compose transition set on the NavHost, chosen by the source→target route pair; the agent shell carries the same grammar). Predictive back is enabled on Android (both apps; nav-compose 2.9 makes the pop transitions seekable). The §01 tab cross-fade is Android-only — iOS keeps the native instant TabView switch to preserve per-tab state, a documented divergence.
  • Feature modules — Auth (welcome → email → OTP → name), Home (featured + nearby carousels), Search (list + map toggle, filters sheet, location autocomplete), Properties (card, detail, gallery/lightbox, tour-request sheet), Favorites (grid), Tours (list + reschedule), Menu (profile, edit-profile, become-agent, settings).
  • State — one @Observable (iOS) / StateFlow (Android) ViewModel per screen, created fresh per screen, holding transient UI state + tRPC-fetched DTOs. App-scoped stores live in AppEnvironment / AppContainer: SessionStore, AuthStore / AuthState, FavoritesStore, SettingsStore, SearchFiltersStore, RecentSearchesStore, and a ToastCenter. DI is manual — no Combine/TCA on iOS, no Hilt on Android.
  • Deep links — a pure DeepLink parser maps the expo-user:// scheme to navigation: expo-user://properties/{listingId} → property detail, expo-user://tours → My Tours.

There is no @trpc/react-query and no compile-time types from @repo/api. Each platform ships one hand-written thin client (TrpcClient.swift in MeridianCore / TrpcClient.kt in :core:network, ~150–200 lines) speaking the wire protocol directly:

  • Queries — GET /api/trpc/{router.procedure}?input=<urlencoded {"json": <input>}>
  • Mutations — POST /api/trpc/{router.procedure}, body {"json": <input>}
  • Response — {"result": {"data": {"json": <output>}}}; error — {"error": {"json": {...}}}
  • No batching — one request per call; native concurrency (async/await, coroutines) handles parallelism.
  • Transport-failure-only retry — retries the network-failure class, never server 4xx/5xx (which carry data).

Cookie-based Better Auth. The app owns the Cookie: header end-to-end (platform cookie jars disabled) and captures rotations from any Set-Cookie response into the Keychain (SessionStore.swift) / EncryptedSharedPreferences (CookieInterceptor.kt).

  • Email OTP is live: send-verification-otp → sign-in/email-otp → (new accounts) collect a name via users.updateProfile.
  • Google sign-in uses the native SDK idToken flow — the app obtains an idToken locally (Credential Manager on Android, GoogleSignIn-iOS on iOS) and posts it to POST /api/auth/sign-in/social ({provider: "google", idToken: ...}). No browser/proxy. This needs iOS + Android OAuth clients in Google Cloud (same project as the web client; serverClientId = the existing web client id).
  • A 401 on any request triggers a global sign-out: clear the stored cookie and flip auth state back to the welcome screen.

Billing — payment on the web, never in-app purchase

Section titled “Billing — payment on the web, never in-app purchase”

The native apps read the plan through entitlements.get / entitlements.getUsage / billing.getSubscription and, in the agent apps, buy or change it through billing.catalog / previewChange / checkout / portalSession / changePlan / cancelPendingChange (PRO-89). A purchase is a URL: billing.checkout and billing.portalSession answer with a Stripe Checkout / Customer Portal link the app opens in SFSafariViewController / Chrome Custom Tabs — never a WebView, never StoreKit / Play Billing. Stripe returns the browser to the public web page /billing/return?app=agent|user&checkout=success|cancelled|portal, which bounces to expo-agent://billing?checkout=… / expo-user://plan?checkout=…; the app toasts, refetches, and polls billing.getSubscription a bounded number of times until the webhook has landed, with a refetch on foreground as the fallback. The calculator sends stepper totals; every read returns extras above the base inclusion — convert in one place. The Stripe half of these calls is the same @repo/api/services/billing-flows.ts the web form actions use, and web and native share the billing-* rate-limit counters.

Store policy (PRO-110). The App Store (Guideline 3.1.1(a)) and Google Play (Payments policy) forbid in-app buttons or links to a non-store purchase on the Mexico storefronts, and neither store’s link-out programs cover Mexico. So billing.getSubscription carries nativePurchaseMode, set on the API host by NATIVE_PURCHASE_MODE, and every purchase or portal CTA follows it:

ModeAgent appsUser apps
web (default; also a missing or unknown value)The calculator’s pay CTA reads “Continue on the web” and every “Manage billing” reads “Manage on the web”; both open /dashboard/billing in the in-app browser. The calculator stays a quote tool.”Manage on the web” opens /portal/plan/subscription.
checkoutThe Stripe Checkout / Customer Portal link-out described above.Same as web.
hiddenNo purchase or portal link anywhere; an informational line says buying isn’t available in the app.The button is hidden; the hint text stays.

“Keep current capacity” (cancelPendingChange, no charge) works in every mode. The mode is presentation only: checkout / portalSession stay callable, so older builds keep working. In web mode the purchase completes on the web and returns to /dashboard/billing, not the app: the screens refetch when the in-app browser closes and on foreground. A signed-out in-app browser lands on the web home page (no returnTo), hence the “sign in with the same email” hint.

Color tokens are generated and committed, never hardcoded. The source of truth is design-tokens/tokens.cjs — the Meridian Native App Map §03 role table (light + dark), including the mode-invariant primarySolid (primary buttons stay white-on-indigo in dark mode); the generated files are native/MeridianUI/Sources/MeridianUI/Tokens.swift (shared by both iOS apps) and apps/android/core/design-system/src/main/kotlin/com/realestatecore/core/design/Tokens.kt (shared by both Android apps); the same run also writes the web’s tokens.generated.css. Read colors via @Environment(\.tokens) (iOS) or LocalTokens.current (Android) — never hardcode hex. Typography is the shared Meridian ramp — Space Grotesk for display roles (prices, KPIs, screen titles; never body text) and Hanken Grotesk for everything else — bundled per app with a matching scale (24 title · 14 body · 13.5 subtitle · 12 caption · 11 micro-caps, floor 11) that follows Dynamic Type (iOS relativeTo:) / the Android font scale (sp). Shape / spacing / elevation / motion constants live in the shared packages’ Metrics (Metrics.swift / Metrics.kt): feature code reads Metrics.gutter, Metrics.cardRadius / inputRadius / thumbRadius / badgeRadius and the elevation tiers (.meridianShadow(.chip | .pill | .toast | .raised | .overlay) on iOS, Metrics.ElevationChip / Pill / Raised / Overlay on Android) rather than literal numbers.

Both apps ship a hand-built, lockstep primitive library (matching API + visuals on each platform) so feature code never re-rolls UI: PrimaryButton / SecondaryButton (52 height, 600 label; 12pt radius on iOS, a full pill on Android — the §03 platform split), ListRow, SwitchRow, CheckboxRow, SegmentedControl (single + multi select), SelectablePill / DismissibleChip, Avatar (muted-gradient initials), StatusBadge (6pt radius, 700 weight), Toast (via ToastCenter — a top capsule on iOS, the M3 snackbar on Android), EmptyState, Skeleton, text Inputs (muted-fill borderless on iOS, M3 outlined + floating label on Android), PickerSheet, plus the Meridian chrome primitives — TabRootHeader, IconActionButton (Android) / GlassIconButton + ChromeButton (iOS), OfflineBanner, Haptics, Metrics — and the §03-10 property-card variants (vertical / row / tile, with the selectable compare mark: circle on iOS, rounded square on Android). The rule is no hand-rolled buttons, and colors come from the generated palette via @Environment(\.tokens) / LocalTokens.current, never hardcoded hex. The mobile-ui-audit skill flags violations (its Rule 14 lists the shared components).

Catalogs are synced copies of the shared source native/i18n/user/{en,es}.json (agent apps use native/i18n/agent/) — flat keys, {{var}} interpolation, _one / _other plural suffixes, es fallback (mapped to es-MX for number/date formatting). To add a key: edit both locales in the shared native/i18n/ source, then re-run the sync (there is no compile step):

Terminal window
bun native/tooling/src/sync-native-i18n.ts
AppCatalog location
iOSIosUser/Resources/messages-{en,es}.json
Androidapp/src/main/assets/messages/{en,es}.json

Same rule as the rest of the repo — read packages/database/src/enums.ts (values) and packages/database/src/generated/db.ts (column types) before hardcoding any status string. Tour.status = REQUESTED, not PENDING. There are no compile-time enum types here, so a wrong literal fails silently at runtime.

Crash + error reporting, one Sentry project per deployable (org na-v1f): ios-user and android-user are their own projects. iOS uses sentry-cocoa (SwiftPM); Android uses sentry-android (no Gradle plugin yet — release symbol upload is deferred). Both init manually at process start — Monitoring.start() from IosUserApp.init() / App.onCreate() — with sendDefaultPii off, tracesSampleRate 0.1, and a beforeSend that redacts cookie / set-cookie / authorization request headers. Android disables the SDK’s io.sentry.auto-init ContentProvider (a manifest meta-data) so the DSN and options live in code. The DSN is a public ingest key, committed — Monitoring.start() no-ops on a non-https placeholder, so the app runs fine before the project exists. A #if DEBUG / BuildConfig.DEBUG-gated “Send test event” row on the Home screen proves the pipeline.

The apps don’t hand-write response DTOs — the model layer is generated from the Zod “wire” schemas in @repo/contract (packages/contract) via scripts/codegen-models.ts (bespoke Swift + Kotlin emitters). The schemas describe result.data.json post-superjson — ISO-string dates, z.int() counts, money as numbers — and the output lands committed once per platform in the shared Core modules (native/MeridianCore/Sources/MeridianCore/Models/Generated/, apps/android/core/network/.../core/api/models/), so both apps of a platform compile the same DTOs. Enums, computed properties, Date accessors and Encodable request bodies stay hand-written in *+App.swift / extension files; regeneration is idempotent. Full pipeline: packages/contract/FEATURE.md.

Two guards keep the models honest:

  • CI tests job (in ci.yml) regenerates the models and runs git diff --exit-code — a schema change without a committed regen, or a hand-edited generated file, fails the PR — then fixtures:validate, which parses every committed fixture through its schema, and sync-contract-fixtures.ts --check, which fails if a native copy drifted from packages/contract/fixtures/.
  • Decode tests — scripts/contract-fixtures/generate-fixtures.ts captures real API envelopes as committed golden <proc>.json files in the canonical packages/contract/fixtures/{user,agent}/, which bun native/tooling/src/sync-contract-fixtures.ts copies into each app’s test tree (never edit a copy); ContractFixtureTests.swift / ContractFixtureTest.kt decode them through the real client unwrap path, catching decoder regressions. The capture tool is manual (refresh a fixture when the wire genuinely changes, then run fixtures:validate); its old .shape.json signature diff is retired, since the API now enforces the @repo/contract schemas on every response. Protected procedures (e.g. users.getMe) need a session cookie (FIXTURE_SESSION_COOKIE) to capture.
Terminal window
cd apps/ios-user
xcodegen generate # regenerate IosUser.xcodeproj from project.yml
xcodebuild -project IosUser.xcodeproj -scheme IosUser \
-destination 'platform=iOS Simulator,name=iPhone 17 Pro' build
xcodebuild -project IosUser.xcodeproj -scheme IosUser \
-destination 'platform=iOS Simulator,name=iPhone 17 Pro' test
Terminal window
cd apps/android # the wrapper lives at the umbrella root
./gradlew :app-user:assembleDebug # debug APK → app-user/build/outputs/apk/debug/
./gradlew :app-user:testDebugUnitTest # unit tests (envelope, cookie merge, i18n)
./gradlew :app-user:lint
adb install app-user/build/outputs/apk/debug/app-user-debug.apk
# the agent app is the same build — swap :app-user for :app-agent

Both debug and release builds target the deployed API https://api.dev.useast.kottia.com by default. To test a local apps/api, flip the debug base URL to http://localhost:4000 (iOS simulator — NSAllowsLocalNetworking is already set) or http://10.0.2.2:4000 (Android emulator → host, plus a cleartext network-security-config).

To install on a physical device — currently debug-signed local builds; no TestFlight/Play yet — see Deployment → run on a physical device.

Phase 1 is code-complete on both platforms — the full customer journey ships natively:

  • Browsable tabs + Home — four-tab shell with featured + nearby carousels.
  • Search — list mode (filters sheet incl. the 57-key feature accordion, location autocomplete, sort, infinite scroll) and map mode (native clustering, pre-rasterized price-pill markers, viewport-driven fetch, list↔map toggle).
  • Property detail — gallery + lightbox, price history, neighborhood stats, agent card, and the tour-request sheet.
  • Favorites — grid with the optimistic favorite heart on every card.
  • Tours — My Tours list with reschedule negotiation + cancel.
  • Profile & settings — profile view/edit, multipart avatar upload + remove, become-agent, and live theme + language switching (no restart).
  • Deep links — expo-user:// for property detail + tours, plus code-side distribution prep (iOS app icon/launch screen, Android conditional release signing).

This builds on the Phase 0 foundations (scaffolding, tRPC client, cookie auth, generated tokens, runtime i18n, Sentry crash reporting, and the @repo/contract generated model layer).

Planned — Phase 2 fast-follows: chat (Stream SDKs), push notifications (APNs/FCM + Knock), addresses, saved searches, compare, recently-viewed, commute. Phase 3 is the store cutover (in-place update to the existing com.realestatecore.user listings). See Planning → Status.