# websitebeaver/react-native-document-scanner-plugin architecture

> Architecture diagram of the GitHub repository websitebeaver/react-native-document-scanner-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/websitebeaver/react-native-document-scanner-plugin
- Repository: https://github.com/websitebeaver/react-native-document-scanner-plugin

## Overview

This React Native plugin opens a native document scanner and returns captured page images as file paths or, where supported, base64 data, with success or cancellation status. The main workflow is JavaScript API call → native module → platform scanner → image results. Android also supports a page limit; the Expo config plugin adds the iOS camera usage description. The sampled sources show Android and iOS handling, but do not expose the full iOS scanner implementation or generated native-module wiring.

Main entry points: [`android/src/main/java/com/documentscanner/DocumentScannerModule.kt`](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/android/src/main/java/com/documentscanner/DocumentScannerModule.kt) (Scan handler), [`ios/DocumentScanner.swift`](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/ios/DocumentScanner.swift) (Scan handler), [`src/NativeDocumentScanner.ts`](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/src/NativeDocumentScanner.ts) (Native module spec), [`src/index.tsx`](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/src/index.tsx) (Scanner API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_js_api["JavaScript API"]
  node_public_api["Scanner API<br/>[index.tsx]"]
  node_native_spec["Native module spec"]
end

subgraph group_android["Android Scanner"]
  node_android_package["Module registration"]
  node_android_module["Scan handler"]
  node_android_scanner["ML Kit scanner"]
  node_android_results["Page results"]
end

subgraph group_ios["iOS Scanner"]
  node_ios_module["Scan handler"]
  node_ios_scanner["Document scanner"]
  node_ios_results["Scan response"]
end

subgraph group_config["App Configuration"]
  node_expo_config["Expo config plugin"]
end

node_app_user(("React Native app"))
node_ios_app_config["iOS app config"]

node_app_user -->|"calls"| node_public_api
node_public_api -->|"delegates to"| node_native_spec
node_native_spec -.->|"dispatches to"| node_android_module
node_android_package -->|"creates"| node_android_module
node_android_module -->|"launches"| node_android_scanner
node_android_scanner -->|"returns pages"| node_android_module
node_android_module -->|"resolves"| node_android_results
node_native_spec -.->|"dispatches to"| node_ios_module
node_ios_module -->|"starts scan"| node_ios_scanner
node_ios_scanner -->|"returns images"| node_ios_module
node_ios_module -->|"resolves response"| node_ios_results
node_app_user -.->|"configures"| node_expo_config
node_expo_config -->|"sets camera usage"| node_ios_app_config

click node_public_api "https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/src/index.tsx"
click node_native_spec "https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/src/NativeDocumentScanner.ts"
click node_android_package "https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/android/src/main/java/com/documentscanner/DocumentScannerPackage.kt"
click node_android_module "https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/android/src/main/java/com/documentscanner/DocumentScannerModule.kt"
click node_android_results "https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/android/src/main/java/com/documentscanner/DocumentScannerModule.kt"
click node_ios_module "https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/ios/DocumentScanner.swift"
click node_ios_scanner "https://github.com/websitebeaver/react-native-document-scanner-plugin/tree/master/ios/DocScanner"
click node_ios_results "https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/ios/DocumentScanner.swift"
click node_expo_config "https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/expo-plugin/src/withDocumentScanner.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api,node_native_spec toneBlue
class node_android_package,node_android_module,node_android_scanner,node_android_results toneAmber
class node_ios_module,node_ios_scanner,node_ios_results toneMint
class node_expo_config toneRose
class node_app_user,node_ios_app_config toneIndigo
```

## Components

### JavaScript API

- [Scanner API](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/src/index.tsx): `src/index.tsx`
- [Native module spec](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/src/NativeDocumentScanner.ts): `src/NativeDocumentScanner.ts`

### Android Scanner

- [Module registration](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/android/src/main/java/com/documentscanner/DocumentScannerPackage.kt): `android/src/main/java/com/documentscanner/DocumentScannerPackage.kt`
- [Scan handler](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/android/src/main/java/com/documentscanner/DocumentScannerModule.kt): `android/src/main/java/com/documentscanner/DocumentScannerModule.kt`
- **ML Kit scanner**
- [Page results](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/android/src/main/java/com/documentscanner/DocumentScannerModule.kt): `android/src/main/java/com/documentscanner/DocumentScannerModule.kt`

### iOS Scanner

- [Scan handler](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/ios/DocumentScanner.swift): `ios/DocumentScanner.swift`
- [Document scanner](https://github.com/websitebeaver/react-native-document-scanner-plugin/tree/master/ios/DocScanner): `ios/DocScanner`
- [Scan response](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/ios/DocumentScanner.swift): `ios/DocumentScanner.swift`

### App Configuration

- [Expo config plugin](https://github.com/websitebeaver/react-native-document-scanner-plugin/blob/master/expo-plugin/src/withDocumentScanner.ts): `expo-plugin/src/withDocumentScanner.ts`

### Other components

- **React Native app**
- **iOS app config**

## Connections

- React Native app → Scanner API: calls (evidence: `README.md`)
- Scanner API → Native module spec: delegates to (evidence: `src/index.tsx`)
- Native module spec → Scan handler: dispatches to
- Module registration → Scan handler: creates (evidence: `android/src/main/java/com/documentscanner/DocumentScannerPackage.kt`)
- Scan handler → ML Kit scanner: launches (evidence: `android/src/main/java/com/documentscanner/DocumentScannerModule.kt`)
- ML Kit scanner → Scan handler: returns pages (evidence: `android/src/main/java/com/documentscanner/DocumentScannerModule.kt`)
- Scan handler → Page results: resolves (evidence: `android/src/main/java/com/documentscanner/DocumentScannerModule.kt`)
- Native module spec → Scan handler: dispatches to
- Scan handler → Document scanner: starts scan (evidence: `ios/DocumentScanner.swift`)
- Document scanner → Scan handler: returns images (evidence: `ios/DocumentScanner.swift`)
- Scan handler → Scan response: resolves response (evidence: `ios/DocumentScanner.swift`)
- React Native app → Expo config plugin: configures
- Expo config plugin → iOS app config: sets camera usage (evidence: `expo-plugin/src/withDocumentScanner.ts`)
