# yogeshpaliyal/keypass architecture

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

- Interactive diagram: https://gitdiagram.com/yogeshpaliyal/keypass
- Repository: https://github.com/yogeshpaliyal/keypass

## Overview

##### Overall Project Type & Purpose
- KeyPass is an Android-first password manager written in Kotlin. It emphasizes offline storage (with local Room database and encrypted backups), uses modern UI components via Material Design 3 and Jetpack Compose, and follows an MVI architecture for managing state.
- In addition to the Android “app” module, the project contains shared and common modules for utility services (e.g., encryption, backup, database handling, dependency injection with Hilt) and even a “desktop” module indicating that the codebase is structured for some multi-platform support.

##### Main Components
- Mobile Application (Android)
- Presentation Layer (UI): Found in app/src/main/java. This includes Authentication (AuthScreen & biometric dialog components), Dashboard (home, nav components), backup and import/export screens, and password generation screens.
- Business Logic & State Management: Organized under the “redux” and MVI architecture folders. These include actions, middlewares, and view models handling intents, state updates, and UI logic.
- Data Layer: The Room Database usage is evident in the “common” module (e.g., AppDatabase, DbDao) and the data classes (AccountModel, UserSettings) ensuring state persistence.
- Utilities and Security: Encryption and backup helper classes (in common/src/main/java/com/yogeshpaliyal/common/dbhelper/ and utils) responsible for backup encryption, secure storage, and handling sensitive data.
- Dependency Injection: Hilt modules in common/di providing application-wide dependencies.
- Platform-specific Code: “shared” module contains cross-platform or multi-target code with common and desktop-specific implementations.

- Desktop Module: Although the focus is on mobile, the “desktop” module (in the desktop folder) shows a JVM-based entry point (Main.kt) supporting a desktop version. Represent this as an alternative UI/entry point which reuses common business logic from the shared code base.

- CI/CD & Workflow Components:
- GitHub workflows, actions, and fastlane scripts manage automated builds, testing, and releases. Although these aren’t runtime components, they are important for understanding development, testing, and deployment processes.

##### Relationships & Interactions
- User Interaction → Presentation Layer → MVI ViewModels/Redux Layer.
- ViewModels communicate with Use Cases/Interactors (part of business logic) that in turn interact with the Data Layer (Room database operations) and Helper utilities (e.g., encryption, backup logic).
- The repository pattern should be depicted between the data layer (common module’s database and encrypt/decrypt utilities) and higher-level modules.
- Dependency Injection (via Hilt) topically “injecting” required dependencies into ViewModels, repositories, and services.
- Flows for backup operations (auto backup worker in the “common/worker” package) which trigger encryption services and then interact with file storage.
- Relationships for both mobile and desktop components sharing common/biz logic from the shared module.

##### Architectural Patterns & Principles
- MVI (Model-View-Intent) architecture is central. Indicate the unidirectional data flow: Intent (user actions) → Model (state updates) → View.
- Modular separation (app for UI, common for core business logic and data, shared for multi-platform support, and desktop as an alternative UI).
- Usage of dependency injection (using Hilt) which decouples component creation from business logic.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Mobile Application (Android)"
        A1["Authentication UI"]:::ui
        A2["Dashboard & Navigation UI"]:::ui
        A3["Backup & Import UI"]:::ui
        A4["Password Generation UI"]:::ui
    end

    S["Business Logic & State Management (MVI/Redux)"]:::business
    D["Data Layer (Room Database & Models)"]:::data
    U["Encryption & Backup Utilities"]:::data
    I["Dependency Injection (Hilt)"]:::di
    SC["Shared Cross-Platform Code"]:::shared
    DS["Desktop Module (JVM Desktop UI)"]:::ui
    CI["CI/CD & Build/Workflow"]:::ci

    %% User interactions from UI to Business Logic
    A1 -->|"intent"| S
    A2 -->|"intent"| S
    A3 -->|"intent"| S
    A4 -->|"intent"| S

    %% Business logic interactions with Data and Shared Modules
    S -->|"query"| D
    S -->|"backup"| U
    S -->|"uses"| SC

    %% Dependency Injection provides components to Business Logic and Data Layer
    I -->|"injects"| S
    I -->|"injects"| D

    %% Shared code supports Desktop UI
    SC -->|"supports"| DS

    %% CI/CD pipelines trigger builds and deployment for Mobile and Desktop modules
    CI -->|"triggers"| A1
    CI -->|"triggers"| DS

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef business fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef data fill:#ABEBC6,stroke:#1D8348,stroke-width:2px;
    classDef di fill:#F5CBA7,stroke:#A04000,stroke-width:2px;
    classDef shared fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef ci fill:#FAD7A0,stroke:#D35400,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/yogeshpaliyal/keypass/tree/master/app/src/main/java/com/yogeshpaliyal/keypass/ui/auth/"
    click A1 "https://github.com/yogeshpaliyal/keypass/tree/master/app/src/main/java/com/yogeshpaliyal/keypass/ui/auth/components/"
    click A2 "https://github.com/yogeshpaliyal/keypass/tree/master/app/src/main/java/com/yogeshpaliyal/keypass/ui/home/"
    click A2 "https://github.com/yogeshpaliyal/keypass/tree/master/app/src/main/java/com/yogeshpaliyal/keypass/ui/nav/"
    click A3 "https://github.com/yogeshpaliyal/keypass/tree/master/app/src/main/java/com/yogeshpaliyal/keypass/ui/backup/"
    click A3 "https://github.com/yogeshpaliyal/keypass/tree/master/app/src/main/java/com/yogeshpaliyal/keypass/ui/backupsImport/"
    click A4 "https://github.com/yogeshpaliyal/keypass/tree/master/app/src/main/java/com/yogeshpaliyal/keypass/ui/generate/"
    click S "https://github.com/yogeshpaliyal/keypass/tree/master/app/src/main/java/com/yogeshpaliyal/keypass/ui/redux/"
    click D "https://github.com/yogeshpaliyal/keypass/blob/master/common/src/main/java/com/yogeshpaliyal/common/AppDatabase.kt"
    click D "https://github.com/yogeshpaliyal/keypass/tree/master/common/src/main/java/com/yogeshpaliyal/common/db/"
    click U "https://github.com/yogeshpaliyal/keypass/tree/master/common/src/main/java/com/yogeshpaliyal/common/dbhelper/"
    click U "https://github.com/yogeshpaliyal/keypass/tree/master/common/src/main/java/com/yogeshpaliyal/common/utils/"
    click I "https://github.com/yogeshpaliyal/keypass/tree/master/common/src/main/java/com/yogeshpaliyal/common/di/"
    click I "https://github.com/yogeshpaliyal/keypass/blob/master/common/src/main/java/com/yogeshpaliyal/common/di/module/AppModule.kt"
    click SC "https://github.com/yogeshpaliyal/keypass/tree/master/shared/src/commonMain/kotlin/com/yogeshpaliyal/keypass/common/"
    click DS "https://github.com/yogeshpaliyal/keypass/blob/master/desktop/src/jvmMain/kotlin/Main.kt"
    click CI "https://github.com/yogeshpaliyal/keypass/tree/master/.github/workflows/"
    click CI "https://github.com/yogeshpaliyal/keypass/tree/master/fastlane/"
```
