React Native Template
Purpose and Scope
Purpose: LatamPassMobile is a mobile application developed in React Native with the goal of providing users of the LATAM Pass loyalty program with a comprehensive platform to manage their account, access relevant program information, perform transactions, and take advantage of exclusive benefits.
Scope: The application includes features such as:
- LATAM Pass user account management.
- Points and miles balance inquiry.
- Flight search and redemption.
- Access to program offers and promotions.
- Information about earning points with partner airlines and merchants.
- Display of educational content about the LATAM Pass program.
- Integration with Co-branding services (e.g., Itaú).
- Personalized notifications and alerts.
- Interaction with analytics and monitoring services (Firebase, Dynatrace).
- Secure authentication through Auth0.
- Multi-language support (Spanish, Portuguese, English).
Architecture
The application follows a React Native-based architecture, leveraging native components for iOS and Android. It is structured into main functional modules (Core, Design System, Flight Search, Member Information, etc.) that interact with each other.
- Core: Cross-cutting features such as authentication, navigation, internationalization, environment configuration, and base services.
- Design System: Reusable UI components and visual themes.
- Business Modules: Specific logic for flight search, member information, educational content, marketing, etc.
- External Integrations: Connection with services such as Auth0 (authentication), Firebase (analytics, remote config, crashlytics), Dynatrace (performance monitoring), Salesforce Marketing Cloud (notifications), Medallia (feedback).
Stack and tab navigation provided by @react-navigation is used.
LatamPassMobile App
|-- React Native Core
| |-- JavaScript/TypeScript Logic
| |-- Native Modules (iOS/Android)
|
|-- Main Modules (@latam-pass-mobile/*)
| |-- Core (auth, navigation, i18n, storage, etc.)
| |-- Design System (UI components)
| |-- Member Information
| |-- Flight Search
| |-- Marketing
| |-- Cobranded
| |-- Educational Content
|
|-- Third-Party Integrations
| |-- Auth0 (Authentication)
| |-- Firebase (Analytics, Crashlytics, Remote Config)
| |-- Dynatrace (APM)
| |-- Salesforce Marketing Cloud (Push Notifications)
| |-- Medallia (Feedback)
|
|-- Native Platforms
|-- iOS (Objective-C/Swift, CocoaPods)
|-- Android (Java/Kotlin, Gradle)
It is recommended to generate a more detailed architecture diagram and store it in a repository or diagramming tool.
Technologies and Dependencies
Main:
- Language: TypeScript, JavaScript
- Framework: React Native 0.71.11
- Package Manager: Yarn
- Navigation:
@react-navigation/native,@react-navigation/bottom-tabs,@react-navigation/material-top-tabs,@react-navigation/native-stack - State (implicit, may use Context API or Redux not directly specified): React Context API (evident in
src/contexts) - Styles:
styled-components,@latam-pass-mobile/design-system - UI Components:
@latam-pass-mobile/design-system,react-native-svg,react-native-linear-gradient,react-native-fast-image,react-native-gesture-handler,react-native-reanimated - Forms:
react-hook-form,@hookform/resolvers,yup(for validation) - API Communication:
axios - Internationalization (i18n):
i18next,react-i18next - Build Tools (iOS): CocoaPods
- Build Tools (Android): Gradle
- CI/CD: Jenkins, Fastlane
Key Dependencies (from package.json and configuration files):
- Authentication:
react-native-auth0 - Secure Storage:
react-native-sensitive-info,react-native-keychain - Local Storage:
@react-native-async-storage/async-storage - Remote Configuration/Environment Variables:
react-native-config,@react-native-firebase/remote-config - Analytics and Monitoring:
@dynatrace/react-native-plugin@react-native-firebase/app@react-native-firebase/analytics@react-native-firebase/crashlyticsreactotron-react-native(for debugging)
- Notifications:
react-native-notificationsreact-native-marketingcloudsdk(Salesforce Marketing Cloud)
- Native Permissions:
react-native-permissions - Device Information:
react-native-device-info - WebView/InAppBrowser:
react-native-webview,react-native-inappbrowser-reborn - Testing:
jest,@testing-library/react-native,@testing-library/jest-native - Linting/Formatting: ESLint (
@react-native-community/eslint-config), Prettier - Git Hooks: Husky, commitlint
- Patch Management:
patch-package - Feedback:
medallia-digital-rn - Fonts: Custom assets in
@latam-pass-mobile/design-system/assets/fonts
Local Setup
Prerequisites
- Node.js (version specified in
.node-version, currently 18) - Yarn (package manager)
- Watchman (recommended for React Native)
- Xcode and CocoaPods (for iOS development)
- Android Studio, Android SDK and NDK (version
23.1.7779620specified inandroid/build.gradle) (for Android development) - JDK (usually included with Android Studio or managed independently)
- React Native CLI (
npx react-native)
Setup Steps
-
Clone the repository: Follow these steps
-
Configure Artifactory: Make sure you have a
.yarnrcand/or.npmrcfile in the project root configured to point to LATAM's Artifactory repositories..yarnrccontent (or similar.npmrc):registry=https://artifactoryrepo1.appslatam.com/artifactory/api/npm/npmjs-org/@latam-pass-mobile:registry=https://artifactoryrepo1.appslatam.com/artifactory/api/npm/corp-libs-npm-release-local/always-auth=true//artifactoryrepo1.appslatam.com/artifactory/api/npm/corp-libs-npm-release-local/:_authToken=${AUTH_NPM_TOKEN}//artifactoryrepo1.appslatam.com/artifactory/api/npm/npmjs-org/:_authToken=${AUTH_NPM_TOKEN}Obtain your
AUTH_NPM_TOKENfrom JFrog Artifactory (Identity Token) and configure it as an environment variable:export AUTH_NPM_TOKEN=YOUR_IDENTITY_TOKEN_HERE(Add this to your
.bashrc,.zshrc, or similar). -
Install Dependencies:
yarn install -
Configure Firebase Files: Obtain the Firebase configuration files from the Firebase project console:
- For iOS:
GoogleService-Info.plist. Place it inios/GoogleService-Info.plist. - For Android:
google-services.json. Place it inandroid/app/google-services.json. (These files are in.gitignoreand must be obtained separately).
- For iOS:
-
Platform-Specific Configuration:
- iOS:
It may be necessary to runcd iospod installcd ..
npx react-native setup-ios-permissions. - Android:
Make sure you have
local.propertiesconfigured inandroid/with the path to your Android SDK if it is not in the default location (Android Studio usually handles this).
- iOS:
-
Create Environment Files: Copy the
.env.examplefiles (if they exist) to.env.dev,.env.intg,.env.prodas needed and configure the specific environment variables. Example:.env.devfor development. -
Run the Application:
- Start Metro Bundler:
yarn start
- Run on Android (development environment):
yarn run:android:dev
- Run on iOS (development environment):
(See other scripts inyarn run:ios:dev
package.jsonfor different environments:intg,prod).
- Start Metro Bundler:
-
Clear Caches and Reinstall (if there are issues):
yarn dep-installThis custom script clears
node_modules, reinstalls dependencies, and clears Gradle and Pods caches. -
Debugging:
- Reactotron: Make sure you have Reactotron Desktop installed.
- For Android, run:
adb reverse tcp:9090 tcp:9090
- For iOS, it usually works without additional steps if Reactotron is configured.
Deployment
The application uses Jenkins and Fastlane for deployments.
Jenkins:
The Jenkinsfile defines the pipeline:
pipelineLatam("gke-krane-react")
This suggests a standardized corporate pipeline for React applications (possibly React Native).
Fastlane (iOS):
Located in ios/fastlane/.
- Configuration:
Appfile,Matchfile,Fastfile,models/Config.rb. - Handles code signing (
match), building (gym), and uploading to TestFlight. - Common commands (run from
ios/):bundle exec fastlane ios release_devbundle exec fastlane ios release_intbundle exec fastlane ios release_prdbundle exec fastlane ios fetch_certificatesbundle exec fastlane ios renew_certificates
Fastlane (Android):
Located in android/fastlane/.
- Configuration:
Appfile,Fastfile. - Handles APK/AAB building (
gradle) and distribution to Firebase App Distribution. - Common commands (run from
android/):bundle exec fastlane android build_dev(generates APK for Dev)bundle exec fastlane android release_dev(distributes to Firebase App Distribution for Dev)- (Similar commands for
intgandprod).
Deployment Environment Variables:
Fastlane and build scripts depend on environment variables for keystores, Firebase IDs, App Store Connect credentials,
etc. (e.g., ANDROID_DEV_KEY_STORE, APP_STORE_CONNECT_KEY_ID). These must be configured in the CI/CD environment.
API Endpoints
The mobile application consumes backend APIs for its various features (LATAM Pass account management, flight search,
etc.). It does not expose APIs directly.
Specific endpoints are defined in the corresponding backend services. Base URL configuration for these backend services
is
managed through environment variables (see react-native-config and .env files).
Backend service configuration example (.env):
MEMBERINFORMATION_MOBILE_BFF=https://api.example.com/member
CHANNELS_MOBILE_BFF=https://api.example.com/channels
AUTH0_DOMAIN=your-auth0-domain.auth0.com
AUTH0_CLIENTID=yourAuth0ClientId
# ...other variables...
Specific Components
Authentication (Auth0)
- Library:
react-native-auth0 - Configuration: Credentials (Domain, ClientID) are managed through
react-native-config(variablesAUTH0_DOMAIN,AUTH0_CLIENTID). - Implementation: See
src/hooks/useAuthLogin.tsxfor login logic andsrc/App.tsxfor theAuthProvider. - Callbacks: Configured in the Auth0 dashboard and in the app's native configuration (iOS
Info.plist, AndroidAndroidManifest.xml/build.gradle).
Firebase
- SDKs:
@react-native-firebase/app,analytics,crashlytics,remote-config. - Native Configuration Files:
- iOS:
ios/GoogleService-Info.plist - Android:
android/app/google-services.json
- iOS:
- Additional
firebase.jsonConfiguration:{"react-native": {"google_analytics_automatic_screen_reporting_enabled": false}} - Implementation: Initialization in
AppDelegate.mm(iOS) andMainApplication.java(Android). Usage through the@latam-pass-mobile/coremodules.
Dynatrace
- Plugin:
@dynatrace/react-native-plugin - Main Configuration (
dynatrace.config.js): DefinesapplicationId,beaconUrl, and behavior for Android and iOS.// dynatrace.config.jsmodule.exports = {// ...android: {config: `dynatrace {configurations {defaultConfig {autoStart {applicationId 'a8b9d0f0-bd5a-4dcc-8378-bcd97b23b25a'beaconUrl 'https://bf94499thn.bf.dynatrace.com/mbeacon'}// ...}}}`,},ios: {config: `<key>DTXApplicationID</key><string>a8b9d0f0-bd5a-4dcc-8378-bcd97b23b25a</string><key>DTXBeaconURL</key><string>https://bf94499thn.bf.dynatrace.com/mbeacon</string>// ...`,},}; - Integration:
metro.config.js:reporter: require('@dynatrace/react-native-plugin/lib/dynatrace-reporter')babel.config.js: Adds the Dynatrace JSX plugin.index.js: InitializesDynatrace.applyUserPrivacyOptions.customTransformer.js: Usesdynatrace-transformer.
- User Identification:
Dynatrace.identifyUser(userInfo.FFNumber);insrc/utils/analytics.ts.
Push Notifications (Salesforce Marketing Cloud)
- Libraries:
react-native-marketingcloudsdk,react-native-notifications. - Native Configuration:
- iOS (
AppDelegate.mm): Initialization ofSFMCSdkwith Salesforce credentials (MID, Server, Token, AppID) obtained fromRNCConfig. - Android (
MainApplication.java): SimilarSFMCSdkconfiguration.
- iOS (
- Custom Native Module (
NotificationModule):- iOS:
ios/NotificationModule.h,ios/NotificationModule.m - Android:
android/app/src/main/java/com/latam/pass/NotificationModule.java - Exposes methods to interact with the Marketing Cloud SDK (read messages, count unread, etc.).
- iOS:
- JS Wrapper Service (
src/services/NotificationService.ts): Provides a JS interface for the native module.
Native Permissions
- Library:
react-native-permissions. - iOS Configuration (
package.jsonandInfo.plist):Ensure that usage descriptions (e.g.,// package.json -> reactNativePermissionsIOS"reactNativePermissionsIOS": ["FaceID","Notifications"]NSFaceIDUsageDescription) are inInfo.plist. - Android Configuration (
AndroidManifest.xml): Declare permissions such asandroid.permission.POST_NOTIFICATIONS. - Implementation: Used in
src/contexts/Notification/index.tsxandsrc/screens/HomeScreen/HomeScreen.tsxto request and verify permissions.
Reactotron (Debugging)
- Libraries:
reactotron-react-native,reactotron-core-client. - Configuration:
src/config/reactotron.ts. Conditionally imported inindex.jsfor development builds. - Usage: Connect with the Reactotron desktop application.
Medallia (Feedback)
- Library:
medallia-digital-rn. - Initialization: In
src/App.tsxusing environment tokens.let token = Platform.OS === "ios" ? environment.MEDALLIA_IOS_TOKEN : environment.MEDALLIA_ANDROID_TOKEN;MedalliaDigital.initialize(token); - Usage: Display feedback forms (e.g.,
src/screens/MenuScreen/index.tsx).
Testing
- Framework: Jest (configured in
jest.config.js). - Utilities:
@testing-library/react-native,@testing-library/jest-native. - Command to run tests:
This includes coverage report generation.yarn test
- Coverage Configuration (
jest.config.js):coverageThreshold: {global: {lines: 80,},},collectCoverageFrom: ['./src/**','!./src/**/*.styles.ts',// ... exclusions ...], - Mocks: Found in the
__mocks__/folder for native or external libraries.
Security Considerations
- Credential Management:
AUTH_NPM_TOKENfor Artifactory must be an environment variable and not hardcoded.- API keys and secrets for services such as Auth0, Firebase, Dynatrace, Salesforce Marketing Cloud, and Medallia are
managed through
react-native-configand.envfiles that should not be versioned (except examples). - Firebase configuration files (
GoogleService-Info.plist,google-services.json) are in.gitignoreand must be managed securely.
- Secure Storage:
react-native-sensitive-infoandreact-native-keychainare used to store sensitive data on the device securely.- Session tokens (Auth0) are stored securely.
- Local Authentication:
- Biometric authentication (FaceID/Fingerprint) is implemented to protect access to the application after the initial login.
- Communication:
- Ensure that all communications with backend APIs are performed over HTTPS.
- Permissions:
- Only the minimum permissions necessary for the app to function are requested.
- Error Handling and Logs:
- Crashlytics is used for error reporting.
- Avoid logging sensitive information in production. Dynatrace and Firebase Analytics should be configured to respect user privacy.
- Security Updates: Keep dependencies updated to mitigate known vulnerabilities.