KeyTUI
A specialized terminal-based token vault and manager designed for rapid credential access, featuring Vim-style navigation, cross-platform clipboard integration, and a persistent SQLite backend.
Overview
Architecting KeyTUI—a high-performance Terminal User Interface (TUI) for developers managing an expanding inventory of API tokens, service keys, and environment-specific credentials. The project focuses on eliminating the friction of traditional CLI-based management by providing a persistent, keyboard-driven environment that enables instant visual filtering and one-touch yanking to the system clipboard.
Problem
The original CLI iteration of this tool suffered from 'Input Exhaustion.' To retrieve a single credential, I had to execute specific commands (e.g., 'keytui token') which only supported singular platform contexts. The process required manual mouse highlighting and copying from the terminal buffer, creating a significant break in development flow. As service complexity grew, the reactive nature of a standard CLI became a bottleneck; I needed a stateful workspace that displayed all tokens simultaneously and allowed for instant navigation without repetitive command execution.
Constraints
- Must minimize 'Time-to-Token'—the duration between needing a key and yanking it
- Requires zero-dependency local storage for maximum portability and data privacy
- Must provide a consistent UX across various terminal emulators via raw mode
- Requires high-speed, intuitive navigation for users accustomed to modal editing (Vim)
Approach
I rebuilt the system from the ground up using Rust and the Ratatui framework to transition from a transient CLI to a persistent state machine. I implemented a centralized SQLite database to manage relational data, such as service labels and expiration dates. The architecture utilizes a strict separation between the 'Input State' (for credential entry) and the 'Normal Mode' (for navigation), ensuring the terminal remains a high-velocity workspace rather than a command-entry chore.
Key Decisions
Vim-Centric Navigation Model
For a developer-focused tool, the keyboard is the primary interface. By implementing 'h/j/k/l' for focus shifting and list navigation, I eliminated the need for mouse interaction or arrow keys, enabling muscle-memory-based token retrieval.
- Standard Arrow-Key Navigation (Less ergonomic for heavy terminal users)
- Search-only Interface (Too slow for visual browsing of available services)
Relational Persistence via SQLite
Using `rusqlite` allowed for advanced features like dynamic service filtering and expiration tracking through standard SQL queries. It ensures data remains structured and queryable as the database grows, unlike flat-file alternatives.
- Flat JSON/YAML files (Prone to corruption and lacks efficient filtering)
- In-memory storage (Lacks persistence across terminal sessions)
Tech Stack
- Rust
- Ratatui (UI Rendering)
- Crossterm (Terminal Manipulation)
- SQLite (via rusqlite)
- Arboard (Cross-platform Clipboard)
Result & Impact
- Reduced by ~70% vs original CLIKeystrokes to Copy
- Unlimited (SQLite vs Single-token context)Data Scalability
- Sub-10ms (Local State Machine)Navigation Latency
The transition to a TUI transformed KeyTUI from a utility I had to 'run' into an environment I 'use.' The ability to see the entire catalog of services and yank a token with a single 'y' press has significantly reduced the mental overhead during high-pressure deployment and API testing phases.
Learnings
- Terminal UIs require rigorous state management, particularly when handling modal transitions between 'Normal', 'Adding', and 'Command' states.
- Clipboard integration is highly platform-sensitive; leveraging a robust crate like `arboard` is essential for consistent behavior across Linux, macOS, and Windows.
- UI layout in a terminal is heavily constrained by character cells; scannability must be the primary design driver.
Additional Context
The most significant architectural shift was the implementation of a Stateful UI. Unlike the previous CLI which exited after every command, the TUI version of KeyTUI maintains a persistent connection to the keytui.db. This allows for features like the Service Sidebar, which dynamically groups tokens based on the service column, allowing the user to filter hundreds of keys in milliseconds.
The Input Pipeline presented a unique challenge. Handling text input in terminal raw mode requires capturing every individual keypress and updating the InputState struct in real-time. I implemented a ‘Tab-to-Cycle’ focus system within the Add Token modal to make data entry feel as fluid and familiar as a standard web form, despite being locked to a character-grid environment.
Currently, the project focuses on Visual Feedback. When a user yanks a token, the status bar provides immediate confirmation (e.g., “Yanked Stripe-API!”). This closes the feedback loop, ensuring the user knows the clipboard is ready without having to manually test it. Future iterations will focus on Encrypted Storage (AES-256) to ensure that while tokens are easy for the user to access, they remain secure at rest within the SQLite file.
[ codeberg ] [ github ] [ gitlab ] - latest updates on codeberg