Architecture Layers
The codebase is organized into four primary layers:Layer Responsibilities
| Layer | Location | Purpose | Dependencies |
|---|---|---|---|
| Domain | domain/ | Pure business logic, models, helpers | None (pure functions) |
| Application | application/state/ | State management, orchestration | Domain, Infrastructure |
| Infrastructure | infrastructure/ | External I/O, persistence, services | Domain |
| UI | components/, App.tsx | Presentation, user interaction | Application, Domain |
agents.md:6-19:
Dependency Rule: Dependencies flow inward. Domain has no external dependencies. Application depends on Domain and Infrastructure. UI depends on Application and Domain.
Domain Layer
Location:domain/
Purpose
Pure business logic and domain models. No side effects, no external dependencies.Key Files
domain/models.ts (714 lines)
Core domain models:
Host- SSH/Telnet/Serial connection configurationSSHKey- SSH key managementIdentity- Reusable authentication credentialsSnippet- Command snippets and scriptsWorkspace- Terminal split/pane layoutTerminalSession- Active terminal stateSftpConnection- SFTP session statePortForwardingRule- SSH tunnel configurationKnownHost- SSH host key verificationConnectionLog- Connection history and replay
domain/host.ts
Host-specific helpers:
- Distro detection and normalization
- Host sanitization and validation
domain/workspace.ts
Workspace tree operations:
- Split pane management (horizontal/vertical)
- Pane insertion and removal
- Size calculations
- Tree traversal
credentials.ts- Credential validationquickConnect.ts- SSH URI parsingsshAuth.ts- Auth method selectionsshConfigSerializer.ts- SSH config exportsync.ts- Data sync operationsvaultImport.ts- Import from other SSH clients
Application Layer
Location:application/state/
Purpose
React hooks that manage state and orchestrate domain logic with infrastructure services.State Management Pattern
Each hook owns its state and persistence:Key Hooks
useVaultState
Manages hosts, keys, snippets, groups:
- CRUD operations for hosts/keys/snippets
- Custom groups and tagging
- Import/export vault data
- Persistence to localStorage
useSessionState
Manages terminal sessions and workspaces:
- Session lifecycle (create/destroy)
- Workspace split/focus management
- Drag-and-drop session management
- Session restoration
useSettingsState
Manages application settings:
- Theme (UI and terminal)
- Accent color and mode
- Font family and size
- Terminal preferences
- Keyboard shortcuts
- Sync configuration
application/state/sftp/)
useSftpConnections- Connection pool managementuseSftpDirectoryListing- Directory browsinguseSftpTransfers- Upload/download operationsuseSftpFileWatch- Auto-sync file changesuseSftpExternalOperations- External editor integration
useApplicationBackend- IPC bridge to Electron main processuseClipboardBackend- System clipboard integrationuseKeychainBackend- System keychain integrationuseKnownHostsBackend- SSH host key managementuseCloudSync- GitHub Gist/S3/OneDrive sync
Infrastructure Layer
Location:infrastructure/
Purpose
External integrations, I/O, configuration, and persistence.Structure
Configuration Files
infrastructure/config/storageKeys.ts
Centralized storage key definitions (70 keys):
agents.md:31-33:
infrastructure/config/terminalThemes.ts
Built-in xterm.js color schemes (39,558 lines total):
- Dracula, Monokai, Solarized Dark/Light
- One Dark, Nord, Gruvbox
- 50+ community themes
UI Layer
Location:components/, App.tsx
Purpose
Presentation logic and user interaction. Components are “dumb” - they receive data and callbacks from hooks.Main Application
App.tsx (52,396 bytes)
Main application component:
- Wires together all state hooks
- Manages top-level routing (Vault/Terminal/Settings)
- Handles global keyboard shortcuts
- Manages modals and dialogs
Component Organization
Component Guidelines
Fromagents.md:38-39:
Keep components dumb: If a prop list grows large, derive a smaller view model in the hook. Avoid business logic in components.
Electron Main Process
Location:electron/
Main Entry Point
electron/main.cjs
Electron main process:
- Window creation and management
- IPC bridge initialization
- Protocol registration (
app://) - GPU acceleration settings
electron/main.cjs:1-14:
Bridge Architecture
Location:electron/bridges/
Bridges provide IPC communication between renderer (React) and main process:
| Bridge | Purpose | Key Features |
|---|---|---|
| sshBridge.cjs | SSH connections | Connection pool, keepalive, host key verification |
| sftpBridge.cjs | SFTP operations | Directory listing, file operations, permissions |
| terminalBridge.cjs | PTY sessions | Local shell, Telnet, Mosh, Serial |
| transferBridge.cjs | File transfers | Upload/download with progress, resume |
| portForwardingBridge.cjs | SSH tunnels | Local/remote/dynamic port forwarding |
| localFsBridge.cjs | Local filesystem | Browse local files for SFTP |
| windowManager.cjs | Window management | Multi-window support, window state |
| credentialBridge.cjs | System keychain | macOS Keychain, Windows Credential Manager |
| tempDirBridge.cjs | Temp file management | SFTP external editor temp files |
| sessionLogsBridge.cjs | Session logging | Auto-save terminal output |
| cloudSyncBridge.cjs | Cloud sync | GitHub Gist, S3, OneDrive |
Helper Modules
electron/bridges/sshAuthHelper.cjs
Shared SSH authentication logic:
- Default key discovery (
~/.ssh/id_*) - Encrypted key detection
- SSH agent integration
- Multi-key fallback
electron/bridges/sshAuthHelper.cjs:12-13:
electron/bridges/keyboardInteractiveHandler.cjs
Handles keyboard-interactive SSH authentication prompts.
electron/bridges/passphraseHandler.cjs
Manages encrypted SSH key passphrase prompts.
electron/bridges/proxyUtils.cjs
HTTP and SOCKS5 proxy support for SSH connections.
Data Flow
Example: Opening an SSH Connection
- UI: User clicks host in
VaultView.tsx - Application:
useSessionStatehook creates session - Application: Hook calls
window.electronAPI.ssh.connect(config) - Bridge:
sshBridge.cjsreceives IPC call - Bridge: Uses
sshAuthHelper.cjsto build auth config - Bridge: Establishes SSH connection via
ssh2library - Bridge: Emits connection status events back to renderer
- Application: Hook updates session state
- UI:
Terminal.tsxreceives session and renders xterm.js
Example: SFTP File Upload
- UI: User drags file into
SftpView.tsx - Application:
useSftpTransfershook creates transfer task - Application: Hook calls
window.electronAPI.transfer.upload(task) - Bridge:
transferBridge.cjsreceives IPC call - Bridge: Reads local file via
localFsBridge.cjs - Bridge: Uploads via
sftpBridge.cjswith progress events - Application: Hook receives progress updates, updates UI
- Bridge: Emits completion event
- Application: Hook marks transfer complete
- UI: SFTP directory refreshes to show new file
Temporary File Management
Fromagents.md:34:
This ensures:
- Proper cleanup on app exit
- User visibility in Settings > System
- Isolation from other applications
Coding Conventions
Fromagents.md:41-45:
Layer Separation
Layer Separation
- Keep logic pure in domain (no side effects)
- Side effects belong to application/infrastructure layers
- UI components should not call infrastructure directly
State Management
State Management
- Prefer composition over deep prop drilling
- Lift shared state into hooks
- Use Context sparingly (hooks are preferred)
External I/O
External I/O
- Avoid direct network/fetch in components
- Add a service/adapter in infrastructure first
- Use IPC bridges for Electron main process communication
Code Style
Code Style
- TypeScript for type safety
- Maintain ASCII-only unless required by file content
- Follow existing patterns in the codebase
Design Patterns
Aside Panel System
Fromagents.md:49-175:
VaultView subpages share a unified aside panel design system via components/ui/aside-panel.tsx:
- Position:
absolute right-0 top-0 bottom-0(parent must berelative) - Width:
w-[380px](configurable) - Background:
bg-background(solid) - Border:
border-l border-border/60 - Content: Auto-scrolling with
space-y-4gap
Project Statistics
- TypeScript files: 256 files
- Main app bundle:
App.tsx(52KB) - Domain models:
domain/models.ts(714 lines, 27KB) - Terminal themes:
infrastructure/config/terminalThemes.ts(39KB) - Electron bridges: 24 bridge modules in
electron/bridges/
Tech Stack
FromREADME.md:280-293:
| Category | Technology |
|---|---|
| Framework | Electron 40 |
| Frontend | React 19, TypeScript |
| Build Tool | Vite 7 |
| Terminal | xterm.js 5 |
| Styling | Tailwind CSS 4 |
| SSH/SFTP | ssh2, ssh2-sftp-client |
| PTY | node-pty |
| Icons | Lucide React |
| Serial | serialport |
| Editor | Monaco Editor (VS Code) |
Further Reading
Building
Build instructions and development setup
Contributing
Contribution guidelines and code style
