# caidensilverstein-svg/token-depot architecture

> Architecture diagram of the GitHub repository caidensilverstein-svg/token-depot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/caidensilverstein-svg/token-depot
- Repository: https://github.com/caidensilverstein-svg/token-depot

## Overview

TokenDepot is a macOS menubar app for encrypted floating sticky notes. Users set a master and panic password, optionally configure recovery, unlock, then create and edit notes that are encrypted for persistence; locking clears the session. The graph includes authentication, recovery, note presentation, encrypted storage, and security primitives. Edges are limited to relationships shown in excerpts, the source index, or README; some UI and supporting-module behavior is unsampled, so uncertain links are omitted.

Main entry points: [`TokenDepot/Auth/AuthManager.swift`](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/AuthManager.swift) (Authentication), [`TokenDepot/Storage/NoteStore.swift`](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Storage/NoteStore.swift) (Note Persistence), [`TokenDepot/App/AppDelegate.swift`](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/App/AppDelegate.swift) (App Lifecycle), [`TokenDepot/Auth/RecoveryManager.swift`](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/RecoveryManager.swift) (Recovery Verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and Notes"]
  node_appdelegate["App Lifecycle<br/>[AppDelegate.swift]"]
  node_menubar["Menubar Controls"]
  node_setupview["Setup Flow<br/>[SetupView.swift]"]
  node_unlockview["Unlock Flow<br/>[UnlockView.swift]"]
  node_notewindow["Note Window"]
  node_noteview["Note View Model"]
end

subgraph group_auth["Authentication and Recovery"]
  node_authmanager["Authentication<br/>[AuthManager.swift]"]
  node_ratelimiter["Rate Limiting<br/>[RateLimiter.swift]"]
  node_recoveryview["Recovery Flow<br/>[RecoveryView.swift]"]
  node_recoverymanager["Recovery Verification"]
  node_keychainmanager["Keychain Access"]
end

subgraph group_storage["Encrypted Storage"]
  node_notestore[("Note Persistence<br/>[NoteStore.swift]")]
  node_notefile["Note File Model<br/>[NoteFile.swift]"]
  node_securewipe["Secure Wipe<br/>[SecureWipe.swift]"]
end

subgraph group_security["Security Primitives"]
  node_cryptoengine["Authenticated Encryption<br/>[CryptoEngine.swift]"]
  node_keyderivation["Key Derivation"]
  node_securememory["Secure Memory<br/>[SecureMemory.swift]"]
end

node_user(("User"))
node_macos["macOS Services"]

node_user -->|"starts app"| node_appdelegate
node_appdelegate -->|"shows setup"| node_setupview
node_appdelegate -->|"shows unlock"| node_unlockview
node_appdelegate -->|"starts controls"| node_menubar
node_appdelegate -->|"checks auth"| node_authmanager
node_appdelegate -->|"loads notes"| node_notestore
node_setupview -->|"sets passwords"| node_authmanager
node_setupview -->|"creates token"| node_recoverymanager
node_unlockview -->|"authenticates"| node_authmanager
node_authmanager -->|"limits attempts"| node_ratelimiter
node_authmanager -->|"derives keys"| node_keyderivation
node_authmanager -->|"reads credentials"| node_keychainmanager
node_authmanager -->|"panic wipes"| node_notestore
node_recoveryview -->|"verifies recovery"| node_recoverymanager
node_recoveryview -->|"derives replacement key"| node_keyderivation
node_recoverymanager -->|"stores token hash"| node_keychainmanager
node_recoverymanager -->|"hashes token"| node_keyderivation
node_menubar -->|"gets session key"| node_authmanager
node_menubar -->|"saves new note"| node_notestore
node_menubar -->|"opens note"| node_notewindow
node_notewindow -->|"deletes note"| node_notestore
node_noteview -->|"uses session"| node_authmanager
node_noteview -->|"uses notes"| node_notestore
node_notestore -->|"encrypts payload"| node_cryptoengine
node_notestore -->|"derives note keys"| node_keyderivation
node_notestore -->|"wipes files"| node_securewipe
node_keychainmanager -->|"accesses Keychain"| node_macos
node_cryptoengine -->|"uses CryptoKit"| node_macos
node_notestore -->|"stores note files"| node_macos
node_recoverymanager -->|"requests Touch ID"| node_macos

click node_appdelegate "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/App/AppDelegate.swift"
click node_menubar "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/MenuBarController.swift"
click node_setupview "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/SetupView.swift"
click node_unlockview "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/UnlockView.swift"
click node_notewindow "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/StickyNoteWindow.swift"
click node_noteview "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/StickyNoteView.swift"
click node_authmanager "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/AuthManager.swift"
click node_ratelimiter "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/RateLimiter.swift"
click node_recoveryview "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/RecoveryView.swift"
click node_recoverymanager "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/RecoveryManager.swift"
click node_keychainmanager "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/KeychainManager.swift"
click node_notestore "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Storage/NoteStore.swift"
click node_notefile "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Storage/NoteFile.swift"
click node_securewipe "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Storage/SecureWipe.swift"
click node_cryptoengine "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Crypto/CryptoEngine.swift"
click node_keyderivation "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Crypto/KeyDerivation.swift"
click node_securememory "https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Crypto/SecureMemory.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_appdelegate,node_menubar,node_setupview,node_unlockview,node_notewindow,node_noteview,node_user toneBlue
class node_authmanager,node_ratelimiter,node_recoveryview,node_recoverymanager,node_keychainmanager toneAmber
class node_notestore,node_notefile,node_securewipe toneMint
class node_cryptoengine,node_keyderivation,node_securememory toneRose
class node_macos toneIndigo
```

## Components

### App and Notes

- [App Lifecycle](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/App/AppDelegate.swift): `TokenDepot/App/AppDelegate.swift`
- [Menubar Controls](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/MenuBarController.swift): `TokenDepot/UI/MenuBarController.swift`
- [Setup Flow](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/SetupView.swift): `TokenDepot/UI/SetupView.swift`
- [Unlock Flow](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/UnlockView.swift): `TokenDepot/UI/UnlockView.swift`
- [Note Window](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/StickyNoteWindow.swift): `TokenDepot/UI/StickyNoteWindow.swift`
- [Note View Model](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/StickyNoteView.swift): `TokenDepot/UI/StickyNoteView.swift`

### Authentication and Recovery

- [Authentication](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/AuthManager.swift): `TokenDepot/Auth/AuthManager.swift`
- [Rate Limiting](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/RateLimiter.swift): `TokenDepot/Auth/RateLimiter.swift`
- [Recovery Flow](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/UI/RecoveryView.swift): `TokenDepot/UI/RecoveryView.swift`
- [Recovery Verification](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/RecoveryManager.swift): `TokenDepot/Auth/RecoveryManager.swift`
- [Keychain Access](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Auth/KeychainManager.swift): `TokenDepot/Auth/KeychainManager.swift`

### Encrypted Storage

- [Note Persistence](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Storage/NoteStore.swift): `TokenDepot/Storage/NoteStore.swift`
- [Note File Model](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Storage/NoteFile.swift): `TokenDepot/Storage/NoteFile.swift`
- [Secure Wipe](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Storage/SecureWipe.swift): `TokenDepot/Storage/SecureWipe.swift`

### Security Primitives

- [Authenticated Encryption](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Crypto/CryptoEngine.swift): `TokenDepot/Crypto/CryptoEngine.swift`
- [Key Derivation](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Crypto/KeyDerivation.swift): `TokenDepot/Crypto/KeyDerivation.swift`
- [Secure Memory](https://github.com/caidensilverstein-svg/token-depot/blob/main/TokenDepot/Crypto/SecureMemory.swift): `TokenDepot/Crypto/SecureMemory.swift`

### Other components

- **User**
- **macOS Services**

## Connections

- User → App Lifecycle: starts app (evidence: `README.md`)
- App Lifecycle → Setup Flow: shows setup (evidence: `TokenDepot/App/AppDelegate.swift`)
- App Lifecycle → Unlock Flow: shows unlock (evidence: `TokenDepot/App/AppDelegate.swift`)
- App Lifecycle → Menubar Controls: starts controls (evidence: `TokenDepot/App/AppDelegate.swift`)
- App Lifecycle → Authentication: checks auth (evidence: `TokenDepot/App/AppDelegate.swift`)
- App Lifecycle → Note Persistence: loads notes (evidence: `TokenDepot/App/AppDelegate.swift`)
- Setup Flow → Authentication: sets passwords (evidence: `TokenDepot/UI/SetupView.swift`)
- Setup Flow → Recovery Verification: creates token (evidence: `TokenDepot/UI/SetupView.swift`)
- Unlock Flow → Authentication: authenticates (evidence: `TokenDepot/UI/UnlockView.swift`)
- Authentication → Rate Limiting: limits attempts (evidence: `TokenDepot/Auth/AuthManager.swift`)
- Authentication → Key Derivation: derives keys (evidence: `TokenDepot/Auth/AuthManager.swift`)
- Authentication → Keychain Access: reads credentials (evidence: `TokenDepot/Auth/AuthManager.swift`)
- Authentication → Note Persistence: panic wipes (evidence: `TokenDepot/Auth/AuthManager.swift`)
- Recovery Flow → Recovery Verification: verifies recovery (evidence: `TokenDepot/UI/RecoveryView.swift`)
- Recovery Flow → Key Derivation: derives replacement key (evidence: `TokenDepot/UI/RecoveryView.swift`)
- Recovery Verification → Keychain Access: stores token hash (evidence: `TokenDepot/Auth/RecoveryManager.swift`)
- Recovery Verification → Key Derivation: hashes token (evidence: `TokenDepot/Auth/RecoveryManager.swift`)
- Menubar Controls → Authentication: gets session key (evidence: `TokenDepot/UI/MenuBarController.swift`)
- Menubar Controls → Note Persistence: saves new note (evidence: `TokenDepot/UI/MenuBarController.swift`)
- Menubar Controls → Note Window: opens note (evidence: `TokenDepot/UI/MenuBarController.swift`)
- Note Window → Note Persistence: deletes note (evidence: `TokenDepot/UI/StickyNoteWindow.swift`)
- Note View Model → Authentication: uses session (evidence: `TokenDepot/UI/StickyNoteView.swift`)
- Note View Model → Note Persistence: uses notes (evidence: `TokenDepot/UI/StickyNoteView.swift`)
- Note Persistence → Authenticated Encryption: encrypts payload (evidence: `TokenDepot/Storage/NoteStore.swift`)
- Note Persistence → Key Derivation: derives note keys (evidence: `TokenDepot/Storage/NoteStore.swift`)
- Note Persistence → Secure Wipe: wipes files (evidence: `TokenDepot/Storage/NoteStore.swift`)
- Keychain Access → macOS Services: accesses Keychain (evidence: `TokenDepot/Auth/KeychainManager.swift`)
- Authenticated Encryption → macOS Services: uses CryptoKit (evidence: `TokenDepot/Crypto/CryptoEngine.swift`)
- Note Persistence → macOS Services: stores note files (evidence: `README.md`)
- Recovery Verification → macOS Services: requests Touch ID (evidence: `TokenDepot/Auth/RecoveryManager.swift`)
