How braze-inc/braze-react-native-sdk works
Main Components
• JavaScript (React Native) Layer:
– Components and modules in the “src” directory (e.g., src/braze.js, src/helpers.js, models, and UI components) form the core of the JavaScript SDK interface.
– The “index.js” and “index.d.ts” are entry points and expose the public API of the SDK.
• Native Bridge Modules:
– iOS Side: Look at “ios”, “BrazeProject/ios”, and the separate “iOS/BrazeReactBridge” directory. They contain Objective-C/Swift files, Podfiles, and project configurations indicating how the bridge is implemented to interact with the native Braze iOS SDK.
– Android Side: Explore “android” and “BrazeProject/android” directories, including both “newarch” and “oldarch” folders. These include Kotlin/Java source files that implement the React Native bridge for Android.
• Sample App / Integration Projects:
– The “BrazeProject” folder contains a sample application demonstrating integration of the React Native SDK with native modules (via manual linking and Cocoapods for iOS).
• Configuration and Build Tools:
– Files like package.json, tsconfig.json, babel.config.js, and build.gradle scripts indicate the tooling and build process.
– The use of ESLint, Prettier, and Jest (with __tests__ directories) shows the inclusion of coding standards and testing infrastructure.
• External SDK Dependencies:
– Documentation in the README points to integration with the native Braze SDKs for Android and iOS, indicating that the bridge ultimately connects to these native libraries for marketing automation functionalities.
Relationships and Interactions
• Data/Control Flow between Layers:
– In the iOS part, show communication from React Native to the iOS Bridging components (AppDelegate, BrazeReactDelegate, etc.) and further to the underlying Braze iOS SDK.
– Similarly, on Android, represent the call flow from React Native through ReactBridge implementations in both “newarch” and “oldarch” folders towards the Braze native SDK components.
• Integration in Sample App:
– In the BrazeProject sample directory, denote its role as a consumer of the SDK; it integrates the JavaScript SDK with native linking (for both manual and Pod-managed integration on iOS).
• Testing and Utility Components:
– Indicate that test files (found in __tests__ directories) are used to validate both the JavaScript layer and possibly interactions with the native code.
Architectural Patterns and Design Principles
• React Native Bridge Pattern:
– Clearly represent the separation between the JavaScript layer and Native Modules.
• Modular Design:
– Show how the SDK is modular (different directories for src, bridge implementations, and sample integration) to allow extensibility and easier maintenance.
• Configuration-centric Approach:
– Include visual elements for build scripts and configuration management (Gradle for Android, Podfile for iOS, npm scripts for the JS side).
Elements
• Clear Labels for Each Component:
– “JS SDK” (with subcomponents like “src/braze.js”, “models”, “UI components”)
– “React Native Bridge – iOS” (with subcomponents like “Podfile”, “AppDelegate”, “BrazeReactDelegate”)
– “React Native Bridge – Android” (with subcomponents from “newarch” and “oldarch” folders)
– “Sample App (BrazeProject)”
– “Build & Config Tools” (e.g., Gradle, npm, Babel)
– “Testing Infrastructure” (Jest based test suites)
▪ Native iOS modules (e.g., green)
▪ Native Android modules (e.g., orange)
• Integration With External Services (Optional):