# adaptyteam/adaptyui-react-native architecture

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

- Interactive diagram: https://gitdiagram.com/adaptyteam/adaptyui-react-native
- Repository: https://github.com/adaptyteam/adaptyui-react-native

## Overview

##### Project type and purpose
- This is an open-source React Native UI library (“@adapty/react-native-ui”) that extends the Adapty SDK by providing a native, no-code paywall view component for iOS and Android.
- It is not a full-stack app; it’s a client-side library that installs into a RN project, bridges JS ↔ native, and fetches/render paywalls via the Adapty SDK.

##### File structure
- Top-level: configuration files (.eslintrc, babel.config.js, tsconfig.json), CI workflows (.github), scripts/pack.sh.
- “src/” contains the JS/TS bridge:
- bridge.ts – entry point to the native module
- index.tsx – exports public API (createPaywallView)
- view-controller.ts & view-emitter.ts – manage view lifecycle and events
- types/ – TypeScript definitions for bridge and public types
- “android/”: standard RN native-module Android code under src/main/java/com/adapty/react/ui
- “ios/”: native UI module implementation in Swift/Obj-C plus Xcode project
- package.json and podspec define how the library integrates into RN projects.

##### README for additional insights
- Explains usage: fetch paywall via Adapty SDK JS module, then call createPaywallView → returns a platform-native view object.
- The view object exposes present/dismiss and event handlers, which under the hood invoke native code and communicate back to JS.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% JS Layer
    subgraph "JavaScript Layer"
        direction TB
        JSAPI["React Native JS API"]:::jsLayer
        BRIDGE["Bridge Module"]:::jsLayer
        VC["View Controller"]:::jsLayer
        VE["View Emitter"]:::jsLayer
        TYPES["TypeScript Definitions"]:::jsLayer
        TBRIDGE["Bridge Type Definitions"]:::jsLayer
    end

    %% Native Modules
    subgraph "Native Modules"
        direction TB
        subgraph "Android Native UI Module"
            direction TB
            AND_DIR["Android UI Module Directory"]:::native
            RNAContext["RNAContext.kt"]:::native
            RNAUIModule["RNAUIModule.kt"]:::native
            RNAUIPackage["RNAUIPackage.kt"]:::native
            Constants["Constants.kt"]:::native
            ParamMap["ParamMap.kt"]:::native
            BridgeError["BridgeError.kt"]:::native
        end
        subgraph "iOS Native UI Module"
            direction TB
            IOS_DIR["iOS UI Module Directory"]:::native
            AdaptyUI["AdaptyUI+View.swift"]:::native
            RNAConstants["RNAConstants.swift"]:::native
            RNACallHandlerSwift["RNAUICallHandler.swift"]:::native
            RNACallHandlerObjC["RNAUICallHandler.m"]:::native
            RNAUIError["RNAUIError.swift"]:::native
            RNAdaptyResult["RNAdapty+Result.swift"]:::native
            BridgingHeader["ReactNativeUi-Bridging-Header.h"]:::native
        end
    end

    %% External SDK and Backend
    subgraph "External Dependencies"
        direction TB
        ADAPTY_SDK["AdaptySDK (iOS/Android)"]:::sdk
        BACKEND["Adapty Backend (REST API)"]:::external
    end

    %% Connections JS to Native
    JSAPI -->|"createPaywallView() call"| BRIDGE
    BRIDGE -->|"invoke native module"| AND_DIR
    BRIDGE -->|"invoke native module"| IOS_DIR

    %% Android internals
    AND_DIR --> RNAContext
    AND_DIR --> RNAUIModule
    AND_DIR --> RNAUIPackage
    AND_DIR --> Constants
    AND_DIR --> ParamMap
    AND_DIR --> BridgeError

    %% iOS internals
    IOS_DIR --> AdaptyUI
    IOS_DIR --> RNAConstants
    IOS_DIR --> RNACallHandlerSwift
    IOS_DIR --> RNACallHandlerObjC
    IOS_DIR --> RNAUIError
    IOS_DIR --> RNAdaptyResult
    IOS_DIR --> BridgingHeader

    %% Native to SDK and backend
    RNAUIModule -->|"fetch/render paywall"| ADAPTY_SDK
    AdaptyUI -->|"fetch/render paywall"| ADAPTY_SDK
    ADAPTY_SDK -->|"HTTPS request"| BACKEND
    BACKEND -->|"response data"| ADAPTY_SDK

    %% Events back to JS
    RNAUIModule -->|"event callbacks"| VE
    AdaptyUI -->|"event callbacks"| VE
    VE -->|"emit events"| BRIDGE
    BRIDGE -->|"dispatch to JS"| JSAPI

    %% Click events
    click JSAPI "https://github.com/adaptyteam/adaptyui-react-native/blob/main/src/index.tsx"
    click BRIDGE "https://github.com/adaptyteam/adaptyui-react-native/blob/main/src/bridge.ts"
    click VC "https://github.com/adaptyteam/adaptyui-react-native/blob/main/src/view-controller.ts"
    click VE "https://github.com/adaptyteam/adaptyui-react-native/blob/main/src/view-emitter.ts"
    click TYPES "https://github.com/adaptyteam/adaptyui-react-native/blob/main/src/types.ts"
    click TBRIDGE "https://github.com/adaptyteam/adaptyui-react-native/blob/main/src/types/bridge.ts"
    click AND_DIR "https://github.com/adaptyteam/adaptyui-react-native/tree/main/android/src/main/java/com/adapty/react/ui/"
    click RNAContext "https://github.com/adaptyteam/adaptyui-react-native/blob/main/android/src/main/java/com/adapty/react/ui/RNAContext.kt"
    click RNAUIModule "https://github.com/adaptyteam/adaptyui-react-native/blob/main/android/src/main/java/com/adapty/react/ui/RNAUIModule.kt"
    click RNAUIPackage "https://github.com/adaptyteam/adaptyui-react-native/blob/main/android/src/main/java/com/adapty/react/ui/RNAUIPackage.kt"
    click Constants "https://github.com/adaptyteam/adaptyui-react-native/blob/main/android/src/main/java/com/adapty/react/ui/Constants.kt"
    click ParamMap "https://github.com/adaptyteam/adaptyui-react-native/blob/main/android/src/main/java/com/adapty/react/ui/ParamMap.kt"
    click BridgeError "https://github.com/adaptyteam/adaptyui-react-native/blob/main/android/src/main/java/com/adapty/react/ui/BridgeError.kt"
    click IOS_DIR "https://github.com/adaptyteam/adaptyui-react-native/tree/main/ios/"
    click AdaptyUI "https://github.com/adaptyteam/adaptyui-react-native/blob/main/ios/AdaptyUI+View.swift"
    click RNAConstants "https://github.com/adaptyteam/adaptyui-react-native/blob/main/ios/RNAConstants.swift"
    click RNACallHandlerSwift "https://github.com/adaptyteam/adaptyui-react-native/blob/main/ios/RNAUICallHandler.swift"
    click RNACallHandlerObjC "https://github.com/adaptyteam/adaptyui-react-native/blob/main/ios/RNAUICallHandler.m"
    click RNAUIError "https://github.com/adaptyteam/adaptyui-react-native/blob/main/ios/RNAUIError.swift"
    click RNAdaptyResult "https://github.com/adaptyteam/adaptyui-react-native/blob/main/ios/RNAdapty+Result.swift"
    click BridgingHeader "https://github.com/adaptyteam/adaptyui-react-native/blob/main/ios/ReactNativeUi-Bridging-Header.h"

    %% Styling
    classDef jsLayer fill:#D0E8FF,stroke:#4A90E2,color:#000
    classDef native fill:#DFF2BF,stroke:#7FBF00,color:#000
    classDef sdk fill:#E8F7D0,stroke:#8DC73F,color:#000
    classDef external fill:#FFE4B5,stroke:#F5A623,color:#000
```
