# takuyaw-w/vaultnote architecture

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

- Interactive diagram: https://gitdiagram.com/takuyaw-w/vaultnote
- Repository: https://github.com/takuyaw-w/vaultnote

## Overview

##### Main Components Identification
The system can be broken down into these key components:

a. Command Layer
- Entry point (vnote.ts)
- Command handlers (src/commands/*)
- Each command (init, add, view, list, delete) represents a distinct operation

b. Core Services Layer
- Encryption/Security Services (utils/encryptor.ts, utils/hasher.ts)
- Memo Management (utils/memo.ts)
- File System Operations (utils/path.ts)

c. Data Layer
- Local File Storage (for encrypted memos)
- Configuration Storage

**User Input (CLI) → Command Layer → Core Services → Data Layer**

##### Key Flows

Main operational flows:

a. Initialization Flow:
**init command → hasher (master password) → path utility → config storage**

b. Memo Operations Flow:
**command → authentication → encryption/decryption → memo utility → storage**

##### Important Elements

a. Security Components:
- Password hashing mechanism
- Encryption/decryption service
- Secure storage handling

b. Utilities:
- Date handling
- Path management
- Message formatting
- Configuration management

##### Specific Implementation Details

a. Security Flow:
- How the master password is used
- Encryption/decryption process
- Demonstrate secure storage implementation

b. Data Flow:
- Command input processing
- Data transformation stages
- Storage interaction points

##### Integration Points

Key integration areas:

- File system interactions (--allow-read, --allow-write permissions)
- Environment variable usage (--allow-env permission)
- Configuration management
- Memo storage management

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI
        CLI_Input[User Input]
        EntryPoint["Entry Point"]:::entry
    end

    subgraph CommandLayer
        Commands["Command Handler"]:::command
        Add["Add Command"]:::command
        Delete["Delete Command"]:::command
        Init["Init Command"]:::command
        List["List Command"]:::command
        View["View Command"]:::command
    end

    subgraph CoreServices
        subgraph SecurityServices
            Encryptor["Encryption Service"]:::security
            Hasher["Password Hasher"]:::security
            Encoder["Encoding Utilities"]:::security
        end

        subgraph MemoManagement
            MemoOps["Memo Operations"]:::core
            DateHandler["Date Handler"]:::core
            MsgFormat["Message Formatter"]:::core
        end

        subgraph FileSystem
            PathMgmt["Path Management"]:::core
            InitUtils["Initialization Utils"]:::core
        end
    end

    subgraph DataLayer
        Config[(Configuration)]:::storage
        MemoStorage[(Encrypted Memos)]:::storage
    end

    subgraph Types
        ConfigTypes["Config Types"]:::type
        MemoTypes["Secure Memo Types"]:::type
    end

    subgraph Constants
        AppConst["App Constants"]:::const
        Version["Version Info"]:::const
    end

    CLI_Input --> EntryPoint
    EntryPoint --> Commands
    Commands --> |Command Selection| Add
    Commands --> |Command Selection| Delete
    Commands --> |Command Selection| Init
    Commands --> |Command Selection| List
    Commands --> |Command Selection| View

    Add & Delete & Init & List & View --> Hasher
    Add & Delete & Init & List & View --> Encryptor
    Encryptor --> Encoder
    
    Add & Delete & List & View --> MemoOps
    MemoOps --> DateHandler
    MemoOps --> MsgFormat
    
    Init --> InitUtils
    InitUtils & MemoOps --> PathMgmt
    
    PathMgmt --> Config
    MemoOps --> MemoStorage
    
    ConfigTypes --> Config
    MemoTypes --> MemoStorage
    
    AppConst --> EntryPoint
    Version --> EntryPoint

    %% Click Events
    click EntryPoint "https://github.com/takuyaw-w/vaultnote/blob/main/vnote.ts"
    click Commands "https://github.com/takuyaw-w/vaultnote/tree/main/src/commands/"
    click Add "https://github.com/takuyaw-w/vaultnote/blob/main/src/commands/add.ts"
    click Delete "https://github.com/takuyaw-w/vaultnote/blob/main/src/commands/delete.ts"
    click Init "https://github.com/takuyaw-w/vaultnote/blob/main/src/commands/init.ts"
    click List "https://github.com/takuyaw-w/vaultnote/blob/main/src/commands/list.ts"
    click View "https://github.com/takuyaw-w/vaultnote/blob/main/src/commands/view.ts"
    click Encryptor "https://github.com/takuyaw-w/vaultnote/blob/main/src/utils/encryptor.ts"
    click Hasher "https://github.com/takuyaw-w/vaultnote/blob/main/src/utils/hasher.ts"
    click Encoder "https://github.com/takuyaw-w/vaultnote/blob/main/src/utils/encoder.ts"
    click MemoOps "https://github.com/takuyaw-w/vaultnote/blob/main/src/utils/memo.ts"
    click DateHandler "https://github.com/takuyaw-w/vaultnote/blob/main/src/utils/date.ts"
    click MsgFormat "https://github.com/takuyaw-w/vaultnote/blob/main/src/utils/message.ts"
    click PathMgmt "https://github.com/takuyaw-w/vaultnote/blob/main/src/utils/path.ts"
    click InitUtils "https://github.com/takuyaw-w/vaultnote/blob/main/src/utils/init.ts"
    click ConfigTypes "https://github.com/takuyaw-w/vaultnote/blob/main/src/types/config.ts"
    click MemoTypes "https://github.com/takuyaw-w/vaultnote/blob/main/src/types/secureMemo.ts"
    click AppConst "https://github.com/takuyaw-w/vaultnote/blob/main/src/const/app.ts"
    click Version "https://github.com/takuyaw-w/vaultnote/blob/main/src/version.ts"

    %% Styling
    classDef entry fill:#2196F3,stroke:#1565C0,color:white
    classDef command fill:#90CAF9,stroke:#64B5F6,color:black
    classDef security fill:#FDD835,stroke:#FBC02D,color:black
    classDef core fill:#81C784,stroke:#66BB6A,color:black
    classDef storage fill:#B0BEC5,stroke:#90A4AE,color:black
    classDef type fill:#CE93D8,stroke:#BA68C8,color:black
    classDef const fill:#FFB74D,stroke:#FFA726,color:black
```
