# ionic-team/capacitor architecture

> Architecture diagram of the GitHub repository ionic-team/capacitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ionic-team/capacitor
- Repository: https://github.com/ionic-team/capacitor

## Overview

##### Key Relationships

a. Data Flow
- Web App <-> Capacitor Bridge <-> Native Platform APIs

b. Plugin Architecture
- Custom Plugins -> Plugin Registry -> Core Bridge -> Native Implementation

c. Build/Deploy Flow
- CLI Commands -> Platform Projects -> Native Builds

##### Component Details

- JavaScript Runtime
- Plugin Registry
- Native API Bridge
- Web View Container

b. Platform Implementations (Surrounding Core)
- iOS (Swift/Objective-C Layer)
- Android (Java/Kotlin Layer)
- Web (Progressive Web App Layer)

c. Plugin System (Connected to Core)
- Core Plugins
- Custom Plugins
- Cordova Compatibility Layer

##### Integration Points

- Web App Integration
- Native Platform Integration
- Plugin Integration
- Build System Integration

##### Special Features

Specialized components for:
- Cordova Compatibility
- Progressive Web App Support
- Native SDK Access
- Cross-Platform APIs

##### Architectural Patterns

Highlight:
- Bridge Pattern (Web to Native)
- Plugin Pattern
- Command Pattern (CLI)

- The central role of the bridge in connecting web apps to native functionality
- The plugin-based architecture for extensibility
- The multi-platform nature of the framework
- The build and deployment workflow
- The relationship between web code and native implementations

- Data flow direction
- Dependencies
- Build/deployment flow
- Plugin registration and execution

- Special indicators

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core ["Core Bridge Layer"]
        NB["Native Bridge"]
        PS["Plugin System"]
        WR["Web Runtime"]
        NB <--> PS
        PS <--> WR
    end

    subgraph Platforms ["Platform Implementations"]
        direction TB
        iOS["iOS Implementation"]
        Android["Android Implementation"]
        Web["Web Implementation"]
    end

    subgraph CLI ["CLI Tools"]
        direction TB
        Build["Build System"]
        ProjMgmt["Project Management"]
        PlatMgmt["Platform Management"]
    end

    subgraph Plugins ["Plugin Architecture"]
        direction TB
        PluginReg["Plugin Registry"]
        CorePlugins["Core Plugins"]
        PluginBase["Plugin Base"]
    end

    subgraph Bridge ["Bridge Components"]
        direction TB
        iOSBridge["iOS Bridge"]
        AndroidBridge["Android Bridge"]
        WebBridge["Web Bridge"]
    end

    subgraph Templates ["Platform Templates"]
        direction TB
        iOSTemp["iOS Template"]
        AndroidTemp["Android Template"]
    end

    Core <--> Platforms
    Core <--> Plugins
    CLI --> Platforms
    Plugins <--> Bridge
    Bridge <--> Platforms
    Templates --> Platforms

    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef core fill:#b3e0ff,stroke:#333
    classDef platform fill:#98fb98,stroke:#333
    classDef cli fill:#dda0dd,stroke:#333
    classDef plugin fill:#ffa500,stroke:#333
    classDef bridge fill:#87ceeb,stroke:#333
    classDef template fill:#f0e68c,stroke:#333

    class NB,PS,WR core
    class iOS,Android,Web platform
    class Build,ProjMgmt,PlatMgmt cli
    class PluginReg,CorePlugins,PluginBase plugin
    class iOSBridge,AndroidBridge,WebBridge bridge
    class iOSTemp,AndroidTemp template

    click NB "https://github.com/ionic-team/capacitor/blob/main/core/native-bridge.ts"
    click PS "https://github.com/ionic-team/capacitor/blob/main/core/src/core-plugins.ts"
    click WR "https://github.com/ionic-team/capacitor/blob/main/core/src/runtime.ts"
    click iOS "https://github.com/ionic-team/capacitor/tree/main/ios/Capacitor/Capacitor/"
    click Android "https://github.com/ionic-team/capacitor/tree/main/android/capacitor/src/main/java/com/getcapacitor/"
    click Web "https://github.com/ionic-team/capacitor/blob/main/core/src/web-plugin.ts"
    click Build "https://github.com/ionic-team/capacitor/blob/main/cli/src/tasks/build.ts"
    click ProjMgmt "https://github.com/ionic-team/capacitor/blob/main/cli/src/tasks/init.ts"
    click PlatMgmt "https://github.com/ionic-team/capacitor/blob/main/cli/src/tasks/sync.ts"
    click PluginReg "https://github.com/ionic-team/capacitor/blob/main/android/capacitor/src/main/java/com/getcapacitor/PluginManager.java"
    click CorePlugins "https://github.com/ionic-team/capacitor/blob/main/core/src/core-plugins.ts"
    click PluginBase "https://github.com/ionic-team/capacitor/blob/main/core/src/definitions.ts"
    click iOSBridge "https://github.com/ionic-team/capacitor/blob/main/ios/Capacitor/Capacitor/CAPBridge.swift"
    click AndroidBridge "https://github.com/ionic-team/capacitor/blob/main/android/capacitor/src/main/java/com/getcapacitor/Bridge.java"
    click WebBridge "https://github.com/ionic-team/capacitor/blob/main/core/src/web-plugin.ts"
    click iOSTemp "https://github.com/ionic-team/capacitor/tree/main/ios-template/"
    click AndroidTemp "https://github.com/ionic-team/capacitor/tree/main/android-template/"
```
