# eddyverbruggen/cordova-plugin-googleplus architecture

> Architecture diagram of the GitHub repository eddyverbruggen/cordova-plugin-googleplus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eddyverbruggen/cordova-plugin-googleplus
- Repository: https://github.com/eddyverbruggen/cordova-plugin-googleplus

## Overview

1. This repository is a Cordova/PhoneGap plugin, not an app. Its job is to expose Google Sign-In to hybrid apps through a single JavaScript API while delegating platform-specific auth work to native code on iOS and Android.

2. The top-level integration point is `plugin.xml`. It defines the plugin metadata, which source files are installed per platform, and the variables the app must provide at install time, especially `REVERSED_CLIENT_ID` and `WEB_APPLICATION_CLIENT_ID`. That file is the central boundary between Cordova and the native implementations.

3. The JavaScript surface area lives in `www/GooglePlus.js`. This is the public plugin API consumed by Cordova apps via `window.plugins.googleplus`. It is the only code the host application calls directly; everything else is behind the Cordova bridge.

4. Native sign-in logic is split by platform under `src/ios/GooglePlus.m/.h` and `src/android/GooglePlus.java`. These are the real authentication adapters that talk to the Google SDKs, handle login/silent login/logout/disconnect, and translate SDK results into plain JS objects returned to the callback layer.

5. The data flow is consistent across platforms: app code calls the JS wrapper, Cordova forwards the request to the native side, the native SDK performs authentication, and the result is marshaled back as a JSON-like object containing profile fields plus optional `idToken`, `serverAuthCode`, and `accessToken`.

6. Browser support is implemented separately in `src/browser/GooglePlusProxy.js`. This is a Cordova proxy layer for the browser platform, meant to keep the plugin callable in non-native environments. It is part of the same API surface but does not use the iOS/Android SDKs.

7. There is also a simulation layer in `src/simulation/`, with `sim-host.js` and `sim-host-handlers.js`. This appears to provide a host-driven fake environment for testing or demoing plugin behavior without a real device auth flow, forming a separate non-production execution path.

8. Build-time behavior is customized with hooks. `hooks/browser/after_prepare.js` adjusts browser platform output after Cordova prepare, and `hooks/ios/prerequisites.js` plus `hooks/ios/package.json` support iOS dependency/setup handling. These hooks are important because they bridge the plugin into platform build systems rather than runtime auth.

9. The iOS side depends on CocoaPods, as called out in the README. That means the plugin is not fully self-contained on iOS: the Cordova plugin installs native code, but the final app build also needs Pods resolution for Google Sign-In libraries.

10. Android integration depends on Google Play Services and OAuth configuration rather than bundled credentials. The plugin code expects the app developer to provide the correct SHA-1 / client IDs, while the plugin itself focuses only on the sign-in flow and token retrieval.

11. The `demo/` directory contains reference host apps for different Cordova stacks: plain Cordova, Cordova with Firebase, and Ionic 2. These demos are not part of the plugin runtime, but they illustrate the expected call pattern and serve as integration examples.

12. Overall architecture: a thin cross-platform JS API at the top, Cordova bridge and platform proxies in the middle, native Google Sign-In implementations at the bottom, and a small amount of build-time glue around the edges to wire in platform dependencies and configuration.

Main entry points: [`plugin.xml`](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/plugin.xml) (plugin.xml), [`src/ios/GooglePlus.m`](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/ios/GooglePlus.m) (GooglePlus.m), [`www/GooglePlus.js`](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/www/GooglePlus.js) (GooglePlus.js), [`src/android/GooglePlus.java`](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/android/GooglePlus.java) (GooglePlus.java)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_plugin["Plugin core"]
  node_plugin_xml["plugin.xml<br/>cordova manifest<br/>[plugin.xml]"]
  node_www_googleplus_js["GooglePlus.js<br/>JS API<br/>[GooglePlus.js]"]
  node_plugin_bridge(("Cordova bridge<br/>runtime bridge"))
  node_readme["README.md<br/>docs<br/>[README.md]"]
end

subgraph group_group_native["Native auth"]
  node_ios_googleplus_h["GooglePlus.h<br/>iOS interface<br/>[GooglePlus.h]"]
  node_ios_googleplus_m["GooglePlus.m<br/>iOS auth<br/>[GooglePlus.m]"]
  node_android_googleplus_java["GooglePlus.java<br/>Android auth<br/>[GooglePlus.java]"]
end

subgraph group_group_support["Support paths"]
  node_browser_proxy["GooglePlusProxy.js<br/>browser proxy<br/>[GooglePlusProxy.js]"]
  node_sim_host["sim-host.js<br/>simulation host<br/>[sim-host.js]"]
  node_sim_handlers["sim-host-handlers.js<br/>simulation handlers"]
  node_browser_hook["after_prepare.js<br/>build hook<br/>[after_prepare.js]"]
  node_ios_hook["prerequisites.js<br/>build hook<br/>[prerequisites.js]"]
  node_ios_hook_pkg["package.json<br/>hook config<br/>[package.json]"]
end

subgraph group_group_examples["Demos"]
  node_demo_cordova["Cordova demo<br/>example app<br/>[index.html]"]
  node_demo_firebase["Firebase demo<br/>example app<br/>[index.html]"]
  node_demo_ionic2["Ionic 2 demo<br/>example app<br/>[app.module.ts]"]
  node_demo_readme["demo README<br/>example docs<br/>[README.md]"]
end

node_plugin_xml -->|"installs"| node_www_googleplus_js
node_plugin_xml -->|"installs"| node_ios_googleplus_m
node_plugin_xml -->|"installs"| node_android_googleplus_java
node_plugin_xml -->|"maps"| node_browser_proxy
node_plugin_xml -->|"hooks"| node_browser_hook
node_plugin_xml -->|"hooks"| node_ios_hook
node_www_googleplus_js -->|"calls"| node_plugin_bridge
node_plugin_bridge -->|"dispatches"| node_ios_googleplus_h
node_plugin_bridge -->|"dispatches"| node_ios_googleplus_m
node_plugin_bridge -->|"dispatches"| node_android_googleplus_java
node_plugin_bridge -->|"dispatches"| node_browser_proxy
node_plugin_bridge -.->|"supports"| node_sim_host
node_ios_googleplus_m -->|"implements"| node_ios_googleplus_h
node_ios_googleplus_m -->|"returns"| node_plugin_bridge
node_android_googleplus_java -->|"returns"| node_plugin_bridge
node_browser_proxy -->|"adapts"| node_plugin_bridge
node_sim_host -->|"drives"| node_sim_handlers
node_sim_host -.->|"mimics"| node_plugin_bridge
node_ios_hook -->|"uses"| node_ios_hook_pkg
node_readme -->|"documents"| node_plugin_xml
node_readme -->|"documents"| node_ios_googleplus_m
node_readme -->|"documents"| node_android_googleplus_java
node_demo_readme -->|"references"| node_demo_cordova
node_demo_readme -->|"references"| node_demo_firebase
node_demo_readme -->|"references"| node_demo_ionic2
node_demo_cordova -->|"consumes"| node_www_googleplus_js
node_demo_firebase -->|"consumes"| node_www_googleplus_js
node_demo_ionic2 -->|"consumes"| node_www_googleplus_js

click node_plugin_xml "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/plugin.xml"
click node_www_googleplus_js "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/www/GooglePlus.js"
click node_ios_googleplus_h "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/ios/GooglePlus.h"
click node_ios_googleplus_m "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/ios/GooglePlus.m"
click node_android_googleplus_java "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/android/GooglePlus.java"
click node_browser_proxy "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/browser/GooglePlusProxy.js"
click node_sim_host "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/simulation/sim-host.js"
click node_sim_handlers "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/simulation/sim-host-handlers.js"
click node_browser_hook "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/hooks/browser/after_prepare.js"
click node_ios_hook "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/hooks/ios/prerequisites.js"
click node_ios_hook_pkg "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/hooks/ios/package.json"
click node_demo_cordova "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/demo/cordova/index.html"
click node_demo_firebase "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/demo/cordova-firebase/index.html"
click node_demo_ionic2 "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/demo/ionic2/app/app.module.ts"
click node_demo_readme "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/demo/README.md"
click node_readme "https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/README.md"

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_plugin_xml,node_www_googleplus_js,node_plugin_bridge,node_readme toneBlue
class node_ios_googleplus_h,node_ios_googleplus_m,node_android_googleplus_java toneAmber
class node_browser_proxy,node_sim_host,node_sim_handlers,node_browser_hook,node_ios_hook,node_ios_hook_pkg toneMint
class node_demo_cordova,node_demo_firebase,node_demo_ionic2,node_demo_readme toneRose
```

## Components

### Plugin core

Cordova plugin boundary and public API surface.

- [plugin.xml](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/plugin.xml): cordova manifest · Plugin metadata, platform file mapping, and install variables. · `plugin.xml`
- [GooglePlus.js](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/www/GooglePlus.js): JS API · Public Cordova-facing API used by host apps. · `www/GooglePlus.js`
- **Cordova bridge**: runtime bridge · Dispatches JS calls into platform-specific implementations.
- [README.md](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/README.md): docs · Plugin usage, setup requirements, and platform notes. · `README.md`

### Native auth

Platform-specific Google Sign-In implementations.

- [GooglePlus.h](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/ios/GooglePlus.h): iOS interface · Native plugin interface and method declarations. · `src/ios/GooglePlus.h`
- [GooglePlus.m](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/ios/GooglePlus.m): iOS auth · iOS Google Sign-In adapter and result marshaling. · `src/ios/GooglePlus.m`
- [GooglePlus.java](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/android/GooglePlus.java): Android auth · Android Google Sign-In adapter and callback handling. · `src/android/GooglePlus.java`

### Support paths

Browser, simulation, and build-time integration paths.

- [GooglePlusProxy.js](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/browser/GooglePlusProxy.js): browser proxy · Browser-platform Cordova proxy for the same API surface. · `src/browser/GooglePlusProxy.js`
- [sim-host.js](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/simulation/sim-host.js): simulation host · Host-driven simulated plugin environment. · `src/simulation/sim-host.js`
- [sim-host-handlers.js](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/src/simulation/sim-host-handlers.js): simulation handlers · Fake auth responses and simulation behavior. · `src/simulation/sim-host-handlers.js`
- [after_prepare.js](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/hooks/browser/after_prepare.js): build hook · Browser platform post-prepare customization. · `hooks/browser/after_prepare.js`
- [prerequisites.js](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/hooks/ios/prerequisites.js): build hook · iOS setup and dependency preparation logic. · `hooks/ios/prerequisites.js`
- [package.json](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/hooks/ios/package.json): hook config · iOS hook package metadata and dependency wiring. · `hooks/ios/package.json`

### Demos

Reference host apps showing plugin usage.

- [Cordova demo](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/demo/cordova/index.html): example app · Plain Cordova integration example. · `demo/cordova/index.html`
- [Firebase demo](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/demo/cordova-firebase/index.html): example app · Cordova example combined with Firebase. · `demo/cordova-firebase/index.html`
- [Ionic 2 demo](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/demo/ionic2/app/app.module.ts): example app · Ionic-based integration example. · `demo/ionic2/app/app.module.ts`
- [demo README](https://github.com/eddyverbruggen/cordova-plugin-googleplus/blob/master/demo/README.md): example docs · Overview of the available demo host apps. · `demo/README.md`

## Connections

- plugin.xml → GooglePlus.js: installs · Declares the JavaScript entry point.
- plugin.xml → GooglePlus.m: installs · Registers the iOS native implementation.
- plugin.xml → GooglePlus.java: installs · Registers the Android native implementation.
- plugin.xml → GooglePlusProxy.js: maps · Provides the browser platform proxy.
- plugin.xml → after_prepare.js: hooks · Runs browser post-prepare customization.
- plugin.xml → prerequisites.js: hooks · Runs iOS setup/dependency preparation.
- GooglePlus.js → Cordova bridge: calls · Host apps invoke the JS API, which forwards through Cordova.
- Cordova bridge → GooglePlus.h: dispatches · Routes calls into the iOS plugin interface.
- Cordova bridge → GooglePlus.m: dispatches · Routes calls into the iOS authentication adapter.
- Cordova bridge → GooglePlus.java: dispatches · Routes calls into the Android authentication adapter.
- Cordova bridge → GooglePlusProxy.js: dispatches · Routes calls to the browser implementation when applicable.
- Cordova bridge → sim-host.js: supports · Can be exercised through the simulation path.
- GooglePlus.m → GooglePlus.h: implements · Objective-C implementation matches the native interface.
- GooglePlus.m → Cordova bridge: returns · Marshals auth results back through Cordova callbacks.
- GooglePlus.java → Cordova bridge: returns · Marshals auth results back through Cordova callbacks.
- GooglePlusProxy.js → Cordova bridge: adapts · Implements the same API surface for browsers.
- sim-host.js → sim-host-handlers.js: drives · Simulation host delegates fake auth behavior to handlers.
- sim-host.js → Cordova bridge: mimics · Exercises the same logical API flow without real devices.
- prerequisites.js → package.json: uses · Hook setup is packaged with iOS hook metadata.
- README.md → plugin.xml: documents · Explains install variables and plugin boundary.
- README.md → GooglePlus.m: documents · Describes iOS setup and CocoaPods dependency.
- README.md → GooglePlus.java: documents · Describes Android Google Play Services configuration.
- demo README → Cordova demo: references · Lists the Cordova demo app.
- demo README → Firebase demo: references · Lists the Firebase-integrated demo app.
- demo README → Ionic 2 demo: references · Lists the Ionic 2 demo app.
- Cordova demo → GooglePlus.js: consumes · Shows the plugin API from a host app.
- Firebase demo → GooglePlus.js: consumes · Shows the plugin API from a host app.
- Ionic 2 demo → GooglePlus.js: consumes · Shows the plugin API from a host app.
