# tingreavinash/keepassdx architecture

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

- Interactive diagram: https://gitdiagram.com/tingreavinash/keepassdx
- Repository: https://github.com/tingreavinash/keepassdx

## Overview

##### Project type and purpose
- KeePassDX is a multi-module Android application (Kotlin/Java/JNI/C) implementing a secure password manager that reads/writes KeePass (.kdb/.kdbx) files, offers UI for entries/groups, and integrates with Android Autofill, Biometric, Notifications, and custom keyboard services.

##### Top-level modules and their roles
- **app**: The main Android application module. Contains UI (Activities/Fragments/Views), presentation (ViewModels), persistence (Room database schemas/entities/DAOs), repositories/use-cases (database/file I/O, encryption orchestration), Android services (AutofillService, NotificationService, BackupAgent, MagikeyboardService), utilities, and settings.
- **crypto**: A library module exposing cipher and key-derivation functions via JNI bridges to native C implementations of AES, ChaCha20, Argon2, HMAC, etc.
- **fastlane**: Build/release automation (CI/CD) scripts and metadata for Play Store / F-Droid.

##### Architectural patterns and key layers
- **MVVM**: UI (Activities/Fragments/Custom Views) ←→ ViewModels ←→ LiveData.
- **Repository** pattern: ViewModels delegate to repository classes that coordinate data sources (Room DB, file I/O, crypto).
- **Room**: Local SQLite via AppDatabase, DAOs, versioned schemas.
- **Service components**:
- **AutofillService** for form-filling using Android Autofill API
- **BiometricManager**/Prompt for fingerprint/face unlock
- **NotificationService** for background task notifications
- **BackupAgent** for settings backup/restore
- **MagikeyboardService** for custom field-filling keyboard
- **JNI/native**: crypto module loaded at runtime for heavy cryptographic operations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        Activities["Activities"]:::ui
        Fragments["Fragments"]:::ui
        CustomViews["Custom Views"]:::ui
    end

    %% Presentation Logic
    subgraph "Presentation Logic"
        ViewModels["ViewModels"]:::logic
    end

    %% Domain/Repository Layer
    subgraph "Domain / Repository Layer"
        DBActions["Database Actions (Repositories)"]:::repo
        CryptoFacades["Crypto Facades"]:::repo
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        AppDatabase["AppDatabase (Room)"]:::data
        FileIO["File I/O Tasks"]:::data
    end

    %% Crypto Module
    subgraph "Crypto Module"
        JNIBridge["CipherFactory / HashManager / NativeLib"]:::native
        NativeCLibs["Native C Libraries"]:::native
    end

    %% Android System Services
    subgraph "Android System Services"
        KeeAutofillService["KeeAutofillService"]:::service
        NotificationService["NotificationService"]:::service
        AdditionalNotif["Additional Notification Services"]:::service
        BackupAgent["SettingsBackupAgent"]:::service
        MagikeyboardService["MagikeyboardService"]:::service
        AdvancedUnlockManager["AdvancedUnlockManager"]:::service
    end

    %% Resource Modules
    subgraph "Resource Modules"
        IconClassic["Icon Pack Classic"]:::external
        IconMaterial["Icon Pack Material"]:::external
    end

    %% Build / CI
    subgraph "Build / CI"
        Gradle["Gradle"]:::infra
        Fastlane["Fastlane"]:::infra
    end

    %% Relationships
    Activities -->|uses| ViewModels
    Fragments -->|uses| ViewModels
    CustomViews -->|binds to| ViewModels

    ViewModels -->|calls| DBActions
    ViewModels -->|calls| CryptoFacades

    DBActions -->|reads/writes| AppDatabase
    DBActions -->|reads/writes| FileIO
    CryptoFacades -->|invokes JNI| JNIBridge

    JNIBridge -->|native calls| NativeCLibs

    Activities -->|autofill| KeeAutofillService
    Activities -->|notify| NotificationService
    Activities -->|notify| AdditionalNotif
    Activities -->|backup| BackupAgent
    Activities -->|keyboard| MagikeyboardService
    Activities -->|biometric| AdvancedUnlockManager

    Activities -->|loads icons| IconClassic
    Activities -->|loads icons| IconMaterial
    Fragments -->|loads icons| IconClassic
    Fragments -->|loads icons| IconMaterial

    Gradle -->|builds| Activities
    Fastlane -->|deploys| Activities
    Fastlane -->|deploys| CryptoFacades

    %% Click Events
    click Activities "https://github.com/tingreavinash/keepassdx/tree/master/app/src/main/java/com/kunzisoft/keepass/activities"
    click Fragments "https://github.com/tingreavinash/keepassdx/tree/master/app/src/main/java/com/kunzisoft/keepass/activities/fragments"
    click CustomViews "https://github.com/tingreavinash/keepassdx/tree/master/app/src/main/java/com/kunzisoft/keepass/view"
    click ViewModels "https://github.com/tingreavinash/keepassdx/tree/master/app/src/main/java/com/kunzisoft/keepass/viewmodels"
    click DBActions "https://github.com/tingreavinash/keepassdx/tree/master/app/src/main/java/com/kunzisoft/keepass/database/action"
    click CryptoFacades "https://github.com/tingreavinash/keepassdx/tree/master/app/src/main/java/com/kunzisoft/keepass/database/crypto"
    click AppDatabase "https://github.com/tingreavinash/keepassdx/blob/master/app/src/main/java/com/kunzisoft/keepass/app/database/AppDatabase.kt"
    click FileIO "https://github.com/tingreavinash/keepassdx/tree/master/app/src/main/java/com/kunzisoft/keepass/database/file"
    click JNIBridge "https://github.com/tingreavinash/keepassdx/blob/master/crypto/src/main/java/com/kunzisoft/encrypt/CipherFactory.kt"
    click JNIBridge "https://github.com/tingreavinash/keepassdx/blob/master/crypto/src/main/java/com/kunzisoft/encrypt/HashManager.kt"
    click JNIBridge "https://github.com/tingreavinash/keepassdx/blob/master/crypto/src/main/java/com/kunzisoft/encrypt/NativeLib.kt"
    click NativeCLibs "https://github.com/tingreavinash/keepassdx/tree/master/crypto/src/main/jni"
    click KeeAutofillService "https://github.com/tingreavinash/keepassdx/blob/master/app/src/main/java/com/kunzisoft/keepass/autofill/KeeAutofillService.kt"
    click NotificationService "https://github.com/tingreavinash/keepassdx/blob/master/app/src/main/java/com/kunzisoft/keepass/services/NotificationService.kt"
    click AdditionalNotif "https://github.com/tingreavinash/keepassdx/blob/master/app/src/main/java/com/kunzisoft/keepass/services/*NotificationService.kt"
    click BackupAgent "https://github.com/tingreavinash/keepassdx/blob/master/app/src/main/java/com/kunzisoft/keepass/backup/SettingsBackupAgent.kt"
    click MagikeyboardService "https://github.com/tingreavinash/keepassdx/blob/master/app/src/main/java/com/kunzisoft/keepass/magikeyboard/MagikeyboardService.kt"
    click AdvancedUnlockManager "https://github.com/tingreavinash/keepassdx/blob/master/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockManager.kt"
    click IconClassic "https://github.com/tingreavinash/keepassdx/tree/master/icon-pack-classic/src/main/res"
    click IconMaterial "https://github.com/tingreavinash/keepassdx/tree/master/icon-pack-material/src/main/res"
    click Fastlane "https://github.com/tingreavinash/keepassdx/tree/master/fastlane"
    click Gradle "https://github.com/tingreavinash/keepassdx/tree/master/gradle/wrapper"

    %% Styles
    classDef ui fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef logic fill:#FCF3CF,stroke:#7D6608,color:#7D6608
    classDef repo fill:#D5F5E3,stroke:#196F3D,color:#145A32
    classDef data fill:#FADBD8,stroke:#943126,color:#641E16
    classDef native fill:#E8DAEF,stroke:#512E5F,color:#4A235A
    classDef service fill:#FDEDEC,stroke:#A93226,color:#641E16
    classDef external fill:#EBF5FB,stroke:#1A5276,color:#154360
    classDef infra fill:#F4ECF7,stroke:#6C3483,color:#4A235A
```
