# commencis/secrets-vault-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/commencis/secrets-vault-plugin
- Repository: https://github.com/commencis/secrets-vault-plugin

## Overview

##### Main Components

a) Build-time Components:
- Gradle Plugin System (SecretsVaultPlugin)
- Secrets Processing Pipeline
- Code Generation System
- CMake Integration Layer

b) Runtime Components:
- Android App Integration
- Native (NDK) Layer
- Security Verification System

**[secrets.json] → [SecretsVaultPlugin] → [Processing Pipeline]**
- ↓
**[Code Generator] ← [Template Resources] → [Generated Assets]**
- ↓
- [Compiled Native Library]

**[Android App] → [Security Verification] → [Native Library]**
- ↓
- [Decoded Secrets]

##### Component Details

Build Time:
- SecretsVaultPlugin (Main plugin orchestrator)
- KeepSecretsTask (Task execution)
- Code Generation System (Kotlin and C++ generators)
- CMake Configuration
- Source Set Mapping System

Runtime:
- App Signature Verification
- Native Library Interface
- Secret Retrieval System
- Custom Encoding/Decoding Pipeline

##### Important Relationships to Highlight

- How the plugin processes secrets.json and generates both Kotlin and C++ code
- Relationship between different source sets and flavor-specific secrets
- Demonstrate the security flow with app signature verification
- Interaction between Kotlin/Java layer and native code

##### Additional Elements

- File types (.kt, .cpp, .json)
- Security checkpoints
- Build vs. runtime boundaries
- Configuration points

##### Architectural Patterns to Emphasize

- Builder pattern for secret processing
- Factory pattern for code generation
- Strategy pattern for custom encoding/decoding
- Bridge pattern between Kotlin and native code

##### Security Flow Highlights

- XOR obfuscation process
- App signature verification
- Custom encoding/decoding pipeline
- Native code protection

Remember to include annotations explaining key decision points and configuration options, particularly around the multi-dimensional flavor support and custom security implementations.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Build Time Components"
        SecretsJson[("secrets.json")]:::config
        Plugin["SecretsVaultPlugin"]:::plugin
        ProcessingPipeline["Secrets Processing Pipeline"]:::processor
        CodeGen["Code Generation System"]:::generator
        Templates["Template Resources"]:::resources
        CMake["CMake Integration Layer"]:::build
        GeneratedAssets["Generated Assets"]:::output
        NativeLib["Compiled Native Library"]:::output
        SourceSetMapping["Source Set Mapping"]:::config
    end

    subgraph "Runtime Components"
        AndroidApp["Android App"]:::app
        SecurityVerification["Security Verification System"]:::security
        NativeLayer["Native (NDK) Layer"]:::native
        DecodedSecrets["Decoded Secrets"]:::output
    end

    SecretsJson --> Plugin
    Plugin --> ProcessingPipeline
    ProcessingPipeline --> CodeGen
    Templates --> CodeGen
    SourceSetMapping --> ProcessingPipeline
    CodeGen --> GeneratedAssets
    GeneratedAssets --> CMake
    CMake --> NativeLib
    
    AndroidApp --> SecurityVerification
    SecurityVerification --> NativeLayer
    NativeLayer --> DecodedSecrets

    %% Click events for component mapping
    click Plugin "https://github.com/Commencis/secrets-vault-plugin/blob/main/secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/SecretsVaultPlugin.kt"
    click ProcessingPipeline "https://github.com/Commencis/secrets-vault-plugin/blob/main/secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/KeepSecretsTask.kt"
    click CodeGen "https://github.com/Commencis/secrets-vault-plugin/blob/main/secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/utils/CodeGenerator.kt"
    click CMake "https://github.com/Commencis/secrets-vault-plugin/blob/main/secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/extensions/CMakeExtension.kt"
    click NativeLayer "https://github.com/Commencis/secrets-vault-plugin/blob/main/secretsvaultplugin/src/main/resources/cpp/common/secrets_util.cpp"
    click SecurityVerification "https://github.com/Commencis/secrets-vault-plugin/blob/main/secretsvaultplugin/src/main/resources/cpp/common/sha256.cpp"
    click Templates "https://github.com/Commencis/secrets-vault-plugin/tree/main/secretsvaultplugin/src/main/resources/kotlin"
    click SourceSetMapping "https://github.com/Commencis/secrets-vault-plugin/blob/main/secretsvaultplugin/src/main/kotlin/com/commencis/secretsvaultplugin/SourceSetToSecretFileMapping.kt"

    %% Styling
    classDef config fill:#FFE873,stroke:#333,stroke-width:2px
    classDef plugin fill:#B5D3E7,stroke:#333,stroke-width:2px
    classDef processor fill:#9FD4C2,stroke:#333,stroke-width:2px
    classDef generator fill:#B5D3E7,stroke:#333,stroke-width:2px
    classDef resources fill:#FFB873,stroke:#333,stroke-width:2px
    classDef build fill:#D4B5E7,stroke:#333,stroke-width:2px
    classDef output fill:#98FB98,stroke:#333,stroke-width:2px
    classDef app fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef security fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef native fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Configuration"]:::config
        L2["Plugin Components"]:::plugin
        L3["Processing"]:::processor
        L4["Generation"]:::generator
        L5["Resources"]:::resources
        L6["Build"]:::build
        L7["Output"]:::output
        L8["Application"]:::app
        L9["Security"]:::security
        L10["Native"]:::native
    end
```
