# voxelbusters/permissions-kit architecture

> Architecture diagram of the GitHub repository voxelbusters/permissions-kit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/voxelbusters/permissions-kit
- Repository: https://github.com/voxelbusters/permissions-kit

## Overview

##### Main Components
- Editor Components: These include all the build pipeline scripts, inspectors, and configuration tools found under Assets/Plugins/VoxelBusters/PermissionsKit/Editor. The Editor scripts are responsible for integrating with Unity’s build pipeline (e.g., modifying AndroidManifest.xml, Info.plist updates for iOS) and providing configuration UI.
- Runtime Components: Under Assets/Plugins/VoxelBusters/PermissionsKit/Runtime, you have separate subdirectories like Android, iOS, and Core. These hold the core API, platform-specific implementations (native bridges, interface definitions), and the business logic to manage permissions once the game is running.
- Core API & Public Interface: The primary API (e.g., PermissionsKit.cs, PermissionsKitManager.cs, and wrapper interfaces) allows application code to request, verify, and check permissions. This layer abstracts away all platform differences.
- Native Modules: Inside the Plugins directories (both Android and iOS folders), you see native libraries (like AAR files for Android and header/source files for iOS) that the runtime components call into for native operations.
- Dependency Management: The ExternalDependencyManager in Assets provides integration to ensure that required external dependencies and configurations are correctly set up in the Unity project.
- Example/Demo: The Examples folder contains Scenes and Scripts demonstrating how to use the Permissions Kit, which is useful when illustrating how different modules interact.
- Configuration & Setup: Components found under the Setup and Simulator directories set initial configurations and simulate permission requests during development.

##### Relationships and Interactions
- Developer Code (in the owning Unity project) will call the unified Permissions Kit API (the Core/Runtime layer) to make permission requests.
- The Permissions Kit API then delegates calls to platform-specific implementations:
- For Android, via the Runtime/Android module and related Editor build pipeline scripts that update the Android manifest.
- For iOS, via the Runtime/iOS module and corresponding Editor scripts that modify Info.plist.
- The Editor tools (inside the Editor folder) ensure that, during builds, the necessary native settings and dependencies are correctly inserted.
- The dependency manager acts as a bridge between the plugin and any external libraries necessary for proper functioning.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project is clearly divided between Editor-time configuration and Runtime functionality.
- Abstracted Platform Layer: A unified API abstracts the differences between Android and iOS permission systems.
- Modular Design: Components like build pipeline processors, native bridges, and settings managers are broken into separate modules, enabling easier maintenance and potential extension.
- Automated Configuration: Through Editor scripts and dependency managers, the plugin automates many setup tasks for developers.

##### Relevant Technologies and Frameworks
- Unity C# Scripting and Assembly Definition Files (.asmdef) for managing modules.
- Platform-specific build scripts for Android (Gradle, manifest generators) and iOS (Info.plist updaters via build pipeline scripts).
- Native libraries for Android (.aar files) and iOS (Objective-C/C++ header and implementation files).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Application["Application Code"]:::external
    Example["Example/Demo Scenes & Scripts"]:::example

    subgraph "Permissions Kit - Editor Components"
        Editor["Editor Tools (Build Pipeline, UI/Inspectors)"]:::editor
        DM["Dependency Manager Integration"]:::editor
        Editor --> DM
    end

    subgraph "Permissions Kit - Runtime Components"
        Core["Core API & Public Interface"]:::runtime
        AndNative["Android Native Module"]:::native
        iOSNative["iOS Native Module"]:::native
        Setup["Setup Module"]:::runtime
        Simulator["Simulator Module"]:::runtime
        Core --> AndNative
        Core --> iOSNative
        Core --> Setup
        Core --> Simulator
    end

    PlatformSettings["Platform Settings (AndroidManifest, Info.plist)"]:::config
    ExternalDep["External Dependencies"]:::dependency

    Application -->|"calls"| Core
    Example -->|"demonstrates"| Core
    Editor -->|"updates"| PlatformSettings
    DM -->|"manages"| ExternalDep

    %% Click Events
    click Editor "https://github.com/voxelbusters/permissions-kit/tree/main/Assets/Plugins/VoxelBusters/PermissionsKit/Editor"
    click Core "https://github.com/voxelbusters/permissions-kit/tree/main/Assets/Plugins/VoxelBusters/PermissionsKit/Runtime/Core"
    click AndNative "https://github.com/voxelbusters/permissions-kit/tree/main/Assets/Plugins/VoxelBusters/PermissionsKit/Plugins/Android"
    click iOSNative "https://github.com/voxelbusters/permissions-kit/tree/main/Assets/Plugins/VoxelBusters/PermissionsKit/Plugins/iOS"
    click DM "https://github.com/voxelbusters/permissions-kit/tree/main/Assets/ExternalDependencyManager"
    click Example "https://github.com/voxelbusters/permissions-kit/tree/main/Assets/Plugins/VoxelBusters/PermissionsKit/Examples"
    click Setup "https://github.com/voxelbusters/permissions-kit/tree/main/Assets/Plugins/VoxelBusters/PermissionsKit/Runtime/Core/Setup"
    click Simulator "https://github.com/voxelbusters/permissions-kit/tree/main/Assets/Plugins/VoxelBusters/PermissionsKit/Runtime/Simulator"

    %% Styles
    classDef external fill:#F9E79F,stroke:#E67E22,stroke-width:2px;
    classDef editor fill:#AED6F1,stroke:#85C1E9,stroke-width:2px;
    classDef runtime fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef native fill:#D2B4DE,stroke:#A569BD,stroke-width:2px;
    classDef dependency fill:#D5DBDB,stroke:#AAB7B8,stroke-width:2px;
    classDef config fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef example fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
```
