# aironou/master-password architecture

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

- Interactive diagram: https://gitdiagram.com/aironou/master-password
- Repository: https://github.com/aironou/master-password

## Overview

##### Main Components

a. Core Algorithm Layer:
- Located in platform-independent/c/core
- Represents the central password generation algorithm
- Algorithm versions (v0-v3)

b. Platform-Specific Implementations:
- iOS/macOS (platform-darwin)
- Android (platform-android)
- Java GUI (platform-independent/java/gui)
- Web Interface (platform-independent/web)
- CLI Interface (platform-independent/c/cli)

c. Data Management Layer:
- Model components (platform-independent/java/model)
- Data persistence
- User preferences storage

##### Architecture Representation

**┌─────────────────────── User Interfaces ───────────────────────┐**
- ┌─────┐   ┌──────┐   ┌───────┐   ┌─────┐   ┌────────────┐  │
- iOS │   │macOS │   │Android│   │ Web │   │Java Desktop│  │
- ┬──┘   └───┬──┘   └───┬───┘   └──┬──┘   └─────┬──────┘  │
- ┼────────────┼────────┼──────────┼───────────┼───────────┘

**┌─────┼────────────┼────────┼──────────┼───────────┼───────────┐**
- Platform-Specific Implementations        │           │
- ┼────────┼──────────┼───────────┘           │

- Native Bridges and JNI Interfaces                 │
- ┬───────────────────────────────┘

**┌─────────────────────────────┼───────────────────────────────┐**
- Core Password Generation Algorithm                 │
- ┌─────────────┐  ┌────────────────┐  ┌──────────────┐     │
- Algorithm V0-3│  │Crypto Services │  │Type Templates│     │
- ┘  └────────────────┘  └──────────────┘     │
- ┘

##### Key Elements to Highlight

- Blue: User Interface components
- Green: Core algorithm components
- Yellow: Platform-specific implementations
- Gray: Supporting services

b. Connection Types:

##### Additional Details

Annotations for:
- Security boundaries
- Data persistence locations
- Cross-platform communication channels
- Algorithm version compatibility

##### Implementation Notes

- Relationship between the C core (platform-independent/c/core) and platform-specific implementations
- Shared model layer (platform-independent/java/model)
- Test coverage and validation paths
- Build and deployment pipelines

##### Architectural Patterns to Emphasize

- Core algorithm isolation
- Platform abstraction layers
- Cross-platform compatibility
- Security boundaries
- Data persistence strategies

Remember to include a note about the project's transition to Spectre, indicating this as a historical reference architecture that's being modernized in the new implementation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#a8d1f0,stroke:#000
    classDef core fill:#90EE90,stroke:#000
    classDef platform fill:#FFE5B4,stroke:#000
    classDef data fill:#D3D3D3,stroke:#000
    classDef test fill:#FFB6C1,stroke:#000

    %% User Interface Layer
    subgraph UI["User Interfaces"]
        iOS["iOS App"]:::ui
        macOS["macOS App"]:::ui
        Android["Android App"]:::ui
        Web["Web Interface"]:::ui
        JavaDesktop["Java Desktop"]:::ui
    end

    %% Platform Layer
    subgraph Platform["Platform-Specific Implementations"]
        DarwinImpl["Darwin Implementation"]:::platform
        AndroidImpl["Android Implementation"]:::platform
        JavaImpl["Java Implementation"]:::platform
        WebImpl["Web Implementation"]:::platform
        CLIImpl["CLI Implementation"]:::platform
    end

    %% Core Algorithm Layer
    subgraph Core["Core Password Generation"]
        AlgoV0["Algorithm V0"]:::core
        AlgoV1["Algorithm V1"]:::core
        AlgoV2["Algorithm V2"]:::core
        AlgoV3["Algorithm V3"]:::core
        CryptoServices["Crypto Services"]:::core
    end

    %% Data Management Layer
    subgraph Data["Data Management"]
        Model["Model Components"]:::data
        Persistence["Data Persistence"]:::data
        Preferences["User Preferences"]:::data
    end

    %% Testing Layer
    subgraph Testing["Testing Infrastructure"]
        CoreTests["Core Tests"]:::test
        JavaTests["Java Tests"]:::test
        DarwinTests["Darwin Tests"]:::test
    end

    %% Relationships
    iOS --> DarwinImpl
    macOS --> DarwinImpl
    Android --> AndroidImpl
    Web --> WebImpl
    JavaDesktop --> JavaImpl

    DarwinImpl --> Core
    AndroidImpl --> Core
    JavaImpl --> Core
    WebImpl --> Core
    CLIImpl --> Core

    DarwinImpl --> Data
    AndroidImpl --> Data
    JavaImpl --> Data
    WebImpl --> Data

    CoreTests --> Core
    JavaTests --> JavaImpl
    DarwinTests --> DarwinImpl

    %% Click Events
    click iOS "https://github.com/aironou/master-password/tree/master/platform-darwin/Source/iOS/"
    click macOS "https://github.com/aironou/master-password/tree/master/platform-darwin/Source/Mac/"
    click Android "https://github.com/aironou/master-password/tree/master/platform-android/src/main/"
    click Web "https://github.com/aironou/master-password/tree/master/platform-independent/web/"
    click JavaDesktop "https://github.com/aironou/master-password/tree/master/platform-independent/java/gui/"
    click CLIImpl "https://github.com/aironou/master-password/tree/master/platform-independent/c/cli/"
    click AlgoV0 "https://github.com/aironou/master-password/blob/master/platform-independent/c/core/src/mpw-algorithm_v0.c"
    click AlgoV1 "https://github.com/aironou/master-password/blob/master/platform-independent/c/core/src/mpw-algorithm_v1.c"
    click AlgoV2 "https://github.com/aironou/master-password/blob/master/platform-independent/c/core/src/mpw-algorithm_v2.c"
    click AlgoV3 "https://github.com/aironou/master-password/blob/master/platform-independent/c/core/src/mpw-algorithm_v3.c"
    click Model "https://github.com/aironou/master-password/tree/master/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/"
    click Persistence "https://github.com/aironou/master-password/tree/master/platform-darwin/Source/MasterPassword.xcdatamodeld/"
    click CoreTests "https://github.com/aironou/master-password/blob/master/platform-independent/c/cli/src/mpw-tests.c"
    click JavaTests "https://github.com/aironou/master-password/tree/master/platform-independent/java/tests/"
    click DarwinTests "https://github.com/aironou/master-password/tree/master/platform-darwin/Tests/"

    %% Legend
    subgraph Legend
        UI_Legend["User Interface"]:::ui
        Platform_Legend["Platform Layer"]:::platform
        Core_Legend["Core Algorithm"]:::core
        Data_Legend["Data Management"]:::data
        Test_Legend["Testing"]:::test
    end
```
