Mobile App Overview
How the HomeLink Hub mobile app is structured, how roles map to navigators, and how it talks to the API and stores data on the device.
The mobile app is a single Expo / React Native binary that serves tenants, agents, landlords and lawyers. Screens are file-based routes (expo-router) under app/. The signed-in user's role decides which tab navigator they land in. This section documents every screen flow, grouped by experience.
Repository layout
| Folder | What it holds |
|---|---|
app/ | Screens. Each file is a route; folders in parentheses such as (auth) are route groups that add no URL segment. |
app/_layout.tsx | Root layout: providers, session restore, auth-expiry redirect, push registration, and the root Stack. |
services/ | API code per domain. Either axios thunks (services/auth/auth-thunk.ts) or RTK Query slices (for example services/property/property-thunk.ts). |
store/ | store.ts (Redux store), axios.ts (axios instance and interceptors), config.ts (RTK Query base query and token refresh). |
hooks/ | storage.ts (AsyncStorage wrapper), use-push-notifications.ts, use-chat.ts, socket update hooks, theme hooks. |
lib/ | Helpers: push-notifications.ts, color-scheme.tsx (theming), share.ts, responsive.ts. |
components/ | Shared UI: components/app/* (property cards, maps, date picker), components/tour/* (guided tour), components/ui/*. |
constants/api.ts | The API host and the apiUrl() helper. |
content/help-content.ts | Static Help Center categories, articles and FAQs. |
utils/home-route.ts | The role to home-route mapping. |
Role-based navigators
The root Stack in app/_layout.tsx registers these top-level routes:
| Route | Purpose | Who reaches it |
|---|---|---|
(onboarding) | Splash and Get Started | Everyone at launch |
(auth) | Sign up, sign in, email code, password reset | Signed-out users |
tenant | Tenant tab bar: Home, Chats, Wishlist, Inspections, Profile | TENANT, and any missing or unknown role |
(tabs) | Professional tab bar (agent, landlord, developer, and the lawyer variant) | AGENT, LANDLORD, DEVELOPER, LAWYER |
agent-onboarding | Mandatory agent setup | AGENT straight after sign-in |
search, filter, categories, category/[type], recommended | Discovery screens outside the tab bar | Mainly tenants |
property | Property detail, inspection, payment and escrow stack, plus the listing editor | All roles (different screens) |
support | Help Center and Contact Support | All roles |
requests/[id], payment-requests/[id] | Agent-side request detail | Professionals |
modal, +not-found | Template modal and the 404 screen | Anyone |
The mapping lives in utils/home-route.ts:
homeRouteForRole(role)returns/(tabs)forLANDLORD,AGENT,LAWYERandDEVELOPER, and/tenantforTENANTor anything else. The comparison is case-insensitive.postAuthRouteForRole(role)is used right after authentication. It returns/agent-onboardingforAGENT(unconditionally; that screen forwards agents who have finished setup) and otherwise the same result ashomeRouteForRole.app/(tabs)/_layout.tsxre-checks agent setup on every render and redirects an unfinished agent back to/agent-onboarding, so a deep link cannot skip it.
/tenant is a real path segment, not a route group. The code comment explains why: as a group it collided with (tabs) on nine routes, including / itself.
No guard on the tenant navigator
app/tenant/_layout.tsx does not check the role or whether anyone is signed in. Routing to /tenant is decided only at the splash, after sign-in, and on the not-found screen. API calls from tenant screens still fail with 401 when there is no session, which sends the user to sign in.
How the app talks to the API
All requests go to one host, under /api/v1. The host is a constant in constants/api.ts (the comment there notes the default is production, so treat any write from a development build as real). There are two HTTP clients:
| Client | File | Used by |
|---|---|---|
| axios instance | store/axios.ts | Auth thunks, push-token registration, some agent onboarding thunks |
RTK Query createBaseQuery(baseUrl) | store/config.ts | Every createApi slice: propertyApi, wishlistApi, paymentApi, userApi, settingsApi, chatApi, bookingApi, escrowApi, inspectionsApi, and others |
Both behave the same way around authentication:
- Before each request the access token is read from AsyncStorage and sent as
Authorization: Bearer .... - If a response is
401and itsmessagecontains the word "token", the client callsPOST /api/v1/auth/refresh-tokenwith the stored refresh token. The refresh is deduplicated, so several requests failing together share one refresh call. - On success the new access token is stored and the original request is retried once.
- On failure the stored session is removed and every listener registered with
subscribeToAuthExpiryruns. The root layout's listener dispatchesclearAuthand replaces the route with/(auth)/signin.
The axios client has a 60 second timeout. Thunks convert a timeout into "The server took too long to respond. It may still have worked -- check before trying again." and a request with no response into "Could not reach the server. Check your connection and try again." (utils/handle-error.ts).
Real-time updates use socket.io (services/chat/socket.service.ts). The socket connects to the API host root, not /api/v1, and authenticates with the access token. It carries chat messages plus the booking:updated and escrow:status_updated events that refresh payment screens.
Where data is kept
Redux store
store/store.ts combines four plain slices (auth, chat, listingUi, listingForm) with one cache per RTK Query API. The whole store, caches included, is reset when clearAuth, logout.fulfilled or logout.rejected is dispatched, so one account's data never leaks into the next sign-in.
auth holds user, loading, error and sessionRestored. sessionRestored flips to true once the stored session has been read at launch; anything that routes by sign-in state waits for it.
AsyncStorage
hooks/storage.ts wraps AsyncStorage with two prefixes. Values are JSON-encoded.
| Stored key | Written by | Contents |
|---|---|---|
session:ACCESS_TOKEN | Sign-in thunks, token refresh | Access token (JWT) |
local:REFRESH_TOKEN | Sign-in thunks | Refresh token |
local:USER | Sign-in thunks, profile edit | The user object returned at sign-in |
local:REMEMBER_ME | Email sign-in | Boolean from the "Remember me" checkbox |
local:PUSH_TOKEN | Push registration | The Expo push token last registered for this device |
local:TOURS_SEEN | Guided tour | Which tours this device has already shown |
local:THEME_PREFERENCE | Appearance screen | system, light or dark |
Tokens are not in secure storage
Despite the session prefix, both prefixes are plain AsyncStorage and survive an app restart. Nothing uses the device keychain or keystore.
Sign-out and session expiry remove session:ACCESS_TOKEN, local:REFRESH_TOKEN and local:USER. Theme and tour keys are device preferences and are kept.
Theming
hooks/use-theme-preference.tsx reads local:THEME_PREFERENCE before rendering anything, so a user who chose Dark never sees a light first frame. Screens are wrapped in withThemeRemount and remount when the scheme changes; layouts read colours reactively.
Guides in this section
| Guide | Covers |
|---|---|
| App launch and onboarding | Splash, Get Started, session restore, role redirect, deep links, push notifications, not-found |
| Sign up and sign in | Account creation, email code, email / Google / Apple sign-in, token storage, sign out |
| Password reset | Forgot password code flow |
| Tenant experience | Browsing, property detail, inspections, payments, escrow, chats, profile, support |
The agent, landlord and lawyer experiences have their own sections alongside this one.
HomeLink Hub