# beemdevelopment/aegis architecture

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

- Interactive diagram: https://gitdiagram.com/beemdevelopment/aegis
- Repository: https://github.com/beemdevelopment/aegis

## Overview

Based on our analysis of the file tree and README, Aegis Authenticator is an Android application whose primary purpose is to serve as a secure, open source two‐factor authentication app. It focuses on security through encryption of a “vault” (using AES-256-GCM with scrypt derived keys and Android Keystore for biometrics) and also incorporates features for backup, importing/exporting credentials, and a rich user interface.

##### Main Components
- User Interface (UI) Layer:
- Represented by Activities, Fragments, Dialogs, and Views (e.g., AegisActivity.java, various components under ui/ and ui/dialogs, ui/fragments, and ui/components).
- This layer handles user interactions, screens (like authentication, entry list, settings, and import/export flows), and theme management.
- Business Logic and Controllers:
- Classes and modules (in the “aegis” package) that mediate between UI and lower-level functions.
- This includes tasks (in ui/tasks such as Argon2Task, Import/Export tasks), and classes that implement core functionalities like backup versioning, preferences handling, and entry ordering.
- Security & Cryptography Modules:
- Located under packages such as crypto, otp, and crypto sub-packages.
- Includes components for encryption (AES-256-GCM), key derivation (using scrypt), and OTP calculations (HOTP, TOTP).
- Also includes integration with Android Keystore for biometric/unlock support.
- Data Persistence Layer:
- The vault and database components (e.g., AppDatabase, Vault, VaultRepository) are critical for securely storing the 2FA entries.
- Includes backup and export/import functionalities as well as the vault’s JSON schema definitions.
- Import/Export and Integration Modules:
- Importer classes under “importers” adapt to multiple external formats (like Google Authenticator, Authy, and others) so that users can bring in their credentials.
- External Dependencies and Vendor Libraries:
- Testing & Quality Assurance:
- Separated test directories (androidTest and test) illustrate integration/unit tests that ensure reliability of cryptographic, database, and UI aspects.

##### Relationships and Interactions
- Interactions from importers/exporters with the secure data layer.

##### Architectural Patterns and Design Principles
- Although not based on explicit MVC/MVVM frameworks, the structure shows a clear separation between presentation (Activities, Fragments) and core logic (crypto, database, importers) — similar to the separation of concerns principle.
- The encryption vault and backup mechanisms reflect a strong emphasis on secure design and data integrity.
- The file structure also hints at modularity (i.e., each package handles distinct responsibilities) which is a useful guideline for your component breakdown.

##### Technologies, Frameworks, and Libraries
- Android framework components (Activities, Services, Receivers).
- Encryption libraries with AES-256-GCM and scrypt implementations.
- Android Keystore integration for biometric support.
- Gradle build system and testing frameworks.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% User Interface Layer
    subgraph "User Interface Layer"
        U1["AegisActivity"]:::ui
        U2["IntroActivity"]:::ui
        U3["Fragments/Preferences"]:::ui
        U4["Dialogs"]:::ui
        U5["Custom Components & Views"]:::ui
    end

    %% Business Logic and Controllers
    subgraph "Business Logic & Controllers"
        BL1["Core Controllers"]:::business
        BL2["Task Executors"]:::business
    end

    %% Security & Cryptography Modules
    subgraph "Security & Cryptography"
        S1["Crypto Core"]:::security
        S2["OTP Handling"]:::security
        S3["Additional Crypto Algorithms"]:::security
        S4["PINs & Biometrics"]:::security
    end

    %% Data Persistence Layer
    subgraph "Data Persistence Layer"
        D1["Database"]:::persistence
        D2["Vault"]:::persistence
    end

    %% Import/Export and Integration Modules
    subgraph "Import/Export & Integration"
        IE1["Importers"]:::import
    end

    %% External Dependencies and Vendor Libraries
    subgraph "External Dependencies"
        EX1["Library Configs"]:::external
        EX2["External UI Libraries"]:::external
    end

    %% Testing & Quality Assurance
    subgraph "Testing & Quality Assurance"
        T1["Instrumentation Tests"]:::testing
        T2["Unit Tests"]:::testing
    end

    %% Connections between layers
    U1 -->|"invokes"| BL1
    U2 -->|"invokes"| BL1
    U3 -->|"triggers"| BL2
    U4 -->|"triggers"| BL2
    U5 -->|"triggers"| BL2

    BL1 -->|"encrypts"| S1
    BL1 -->|"utilizes"| S2
    BL2 -->|"reads/writes"| D2
    BL1 -->|"reads/writes"| D1

    IE1 -->|"imports/exports"| D2

    U5 ---|"utilizes"| EX2

    %% Click Events for UI Layer
    click U1 "https://github.com/beemdevelopment/aegis/blob/master/app/src/main/java/com/beemdevelopment/aegis/ui/AegisActivity.java"
    click U2 "https://github.com/beemdevelopment/aegis/blob/master/app/src/main/java/com/beemdevelopment/aegis/ui/IntroActivity.java"
    click U3 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/ui/fragments/preferences"
    click U4 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/ui/dialogs"
    click U5 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/ui/components"

    %% Click Events for Business Logic and Controllers
    click BL1 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis"
    click BL2 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/ui/tasks"

    %% Click Events for Security & Cryptography Modules
    click S1 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/crypto"
    click S2 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/crypto/otp"
    click S3 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/crypto/bc"
    click S4 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/crypto/pins"

    %% Click Events for Data Persistence Layer
    click D1 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/database"
    click D2 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/vault"

    %% Click Event for Import/Export and Integration Modules
    click IE1 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/importers"

    %% Click Events for External Dependencies
    click EX1 "https://github.com/beemdevelopment/aegis/tree/master/app/config/libraries"
    click EX2 "https://github.com/beemdevelopment/aegis/tree/master/app/src/main/java/com/beemdevelopment/aegis/ui/glide"

    %% Click Events for Testing & Quality Assurance
    click T1 "https://github.com/beemdevelopment/aegis/tree/master/app/src/androidTest/java/com/beemdevelopment/aegis"
    click T2 "https://github.com/beemdevelopment/aegis/tree/master/app/src/test/java/com/beemdevelopment/aegis"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef business fill:#98FB98,stroke:#006400,stroke-width:2px;
    classDef security fill:#FFC0CB,stroke:#B22222,stroke-width:2px;
    classDef persistence fill:#D3D3D3,stroke:#696969,stroke-width:2px;
    classDef import fill:#D8BFD8,stroke:#9400D3,stroke-width:2px;
    classDef external fill:#FFFACD,stroke:#DAA520,stroke-width:2px;
    classDef testing fill:#F5DEB3,stroke:#8B4513,stroke-width:2px;
```
