# getphyllo/phyllo-connect-reactnative architecture

> Architecture diagram of the GitHub repository getphyllo/phyllo-connect-reactnative, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/getphyllo/phyllo-connect-reactnative
- Repository: https://github.com/getphyllo/phyllo-connect-reactnative

## Overview

##### Project type and purpose
- This is a React Native SDK module ("react-native-phyllo-connect") that provides a JavaScript interface and native bridges for Android and iOS to integrate the Phyllo Connect flow into a React Native app.
- Its purpose is to expose Phyllo’s account-connection UI and events to a React Native application via a JS API and underlying native modules.

##### File structure
- Top-level files and directories:
- src/ – TypeScript implementation of the JS API and event emitter
- ios/ – Xcode project and Objective-C/Swift bridging code for iOS
- android/ – Java/Kotlin React Native module wrapper for Android
- example/ – a sample React Native app that demonstrates SDK usage on both platforms
- config files (babel.config.js, tsconfig.json, podspec, build.gradle, package.json, etc.)
- Patterns and architectural choices:
- Bridge pattern – JS ↔ native boundary on each platform
- Event-emitter for callback subscriptions
- Separate platform folders (android/, ios/) implementing the same interface signature

##### README for additional insights
- The README documents initialization, event subscriptions, and how to open the connection screen.
- It references Phyllo’s backend API for user-token generation.
- It outlines the configuration object and lifecycle events (accountConnected, exit, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Host Application Layer
    subgraph "Host React Native App"
        App["example/src/App.js"]:::applayer
        APIHandler["example/src/APIHandler.js"]:::applayer
        Config["example/src/config.js"]:::applayer
    end

    %% JS/TypeScript SDK Layer
    subgraph "JS/TS SDK Layer"
        SDKIndex["src/index.tsx"]:::jslayer
        SDKCore["src/PhylloConnect.ts"]:::jslayer
        SDKEnv["src/PhylloEnvironment.ts"]:::jslayer
        SDKConst["src/constants.ts"]:::jslayer
    end

    %% Android Native Module Layer
    subgraph "Android Native Module"
        AndMod["PhylloConnectModule.kt"]:::androidlayer
        AndPkg["PhylloConnectPackage.kt"]:::androidlayer
        AndManifest["AndroidManifest.xml"]:::androidlayer
        AndGradle["build.gradle"]:::androidlayer
    end

    %% iOS Native Module Layer
    subgraph "iOS Native Module"
        iOSSwift["PhylloConnectModule.swift"]:::ioslayer
        iOSObjC["PhylloConnectModule.m"]:::ioslayer
        iOSBridge["Bridging-Header.h"]:::ioslayer
        Podspec["react-native-phyllo-connect.podspec"]:::ioslayer
    end

    %% Native SDK UI
    subgraph "Phyllo Connect Native UI"
        NativeUIAndroid["Android SDK"]:::androidlayer
        NativeUIiOS["iOS SDK"]:::ioslayer
    end

    %% External Backend
    PhylloBackend["Phyllo Backend REST API"]:::backendlayer

    %% Data and Control Flow
    App -->|"PhylloConnect.initialize(config)\non(), open()"| SDKCore
    SDKCore -->|"RN bridge call"| AndMod
    SDKCore -->|"RN bridge call"| iOSSwift

    AndMod -->|"invoke UI"| NativeUIAndroid
    iOSSwift -->|"invoke UI"| NativeUIiOS

    NativeUIAndroid -->|"REST calls"| PhylloBackend
    NativeUIiOS -->|"REST calls"| PhylloBackend

    PhylloBackend -->|"responses / events"| NativeUIAndroid
    PhylloBackend -->|"responses / events"| NativeUIiOS

    NativeUIAndroid -->|"event callback"| AndMod
    NativeUIiOS -->|"event callback"| iOSSwift

    AndMod -->|"EventEmitter"| SDKCore
    iOSSwift -->|"EventEmitter"| SDKCore

    SDKCore -->|"accountConnected, exit events"| App

    %% Click Events
    click App "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/example/src/App.js"
    click APIHandler "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/example/src/APIHandler.js"
    click Config "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/example/src/config.js"
    click SDKIndex "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/src/index.tsx"
    click SDKCore "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/src/PhylloConnect.ts"
    click SDKEnv "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/src/PhylloEnvironment.ts"
    click SDKConst "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/src/constants.ts"
    click AndMod "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/android/src/main/java/com/phylloconnect/PhylloConnectModule.kt"
    click AndPkg "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/android/src/main/java/com/phylloconnect/PhylloConnectPackage.kt"
    click AndManifest "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/android/src/main/AndroidManifest.xml"
    click AndGradle "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/android/build.gradle"
    click iOSSwift "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/ios/PhylloConnectModule.swift"
    click iOSObjC "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/ios/PhylloConnectModule.m"
    click iOSBridge "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/ios/PhylloConnectModule–Bridging-Header.h"
    click Podspec "https://github.com/getphyllo/phyllo-connect-reactnative/blob/release_v0.4.0/react-native-phyllo-connect.podspec"

    %% Styles
    classDef applayer fill:#f9f,stroke:#333,stroke-width:1px
    classDef jslayer fill:#bbf,stroke:#333,stroke-width:1px
    classDef androidlayer fill:#bfb,stroke:#333,stroke-width:1px
    classDef ioslayer fill:#fbc,stroke:#333,stroke-width:1px
    classDef backendlayer fill:#ffb,stroke:#333,stroke-width:1px
```
