How sharpedmimishee/gi works
1. Project shape
- This is a single Rust command-line binary named gi (“Get Integer”), focused on 2FA code generation and management.
- The repository is small and modular: src/main.rs is the entrypoint, and src/commands.rs plus src/commands/* contain the CLI subcommands.
2. Top-level execution flow
- The program starts in main, parses the user’s command, and dispatches into one of the command handlers.
- The available user-facing actions are run/get, list, add, delete, plus help-oriented handling.
3. Command routing layer
- src/commands.rs is the command orchestration layer.
- It likely centralizes shared command definitions, argument parsing, and dispatch to the concrete modules in src/commands/.
- The subcommand files indicate a clean separation between command parsing and command behavior.
4. Core command modules
- add.rs handles creating a new 2FA entry.
- delete.rs removes an entry.
- delline.rs suggests deletion may be implemented by line-based editing of a local storage file.
- list.rs enumerates stored accounts/secrets.
- get.rs retrieves or generates the current integer/token for a selected entry.
- help.rs provides usage output and command guidance.
5. Primary data flow
- User invokes a subcommand.
- The command layer locates the relevant stored 2FA record.
- For get/run, the secret is used to compute a one-time integer.
- For add/delete/list, the command layer reads and updates the local registry of entries.
6. State and persistence boundary
- The presence of delline.rs strongly suggests the app stores 2FA entries in a local file rather than in a database or remote service.
- The app’s persistence boundary is therefore local filesystem state, with command modules acting on that file directly or through a small helper layer.
7. Cryptography and token generation
- The README lists sha1, hmac, and byteorder as dependencies.
- That combination is consistent with standard OTP generation, likely HMAC-SHA1-based code computation with binary/byte-order handling.
- In architecture terms, this is the core “token engine” used by get/run, separate from the CLI plumbing.
8. Dependency boundaries
- The app has no visible backend service, network client, or UI framework.
- External crates are used only for cryptographic/token logic and low-level byte handling, not for infrastructure integration.
9. Operational model
- This is an offline local utility: users build it with Cargo and run commands directly in the terminal.
- There is no evidence of background daemon behavior, scheduler, or server process.
10. Likely diagram boundaries
- One boundary is the CLI interface: terminal input/output and help text.
- A second boundary is command processing: routing and validation.
- A third boundary is data/crypto: local storage of secrets plus OTP generation from HMAC-SHA1.
11. What to emphasize in an architecture diagram
- Draw the binary as one process with a command dispatcher in the center.
- Show four functional areas around it: add/update, list, delete, and token generation.
- Show a local file/store as the persistence target, and a crypto component feeding the token-generation path.
12. Overall architectural summary
- gi is a compact Rust CLI for managing local 2FA entries and generating integer OTP codes.
- Its architecture is primarily command-driven, with a small shared command layer and a cryptographic token-generation core, backed by local file-based state.
Main entry points: commands.rs Commands · delete.rs Delete · get.rs Get · list.rs List
Components 13
CLI surface
Terminal entrypoint and user-facing commands
- gi · Starts the CLI and hands off to command routing
src/main.rs - Help · Prints usage and command guidance
src/commands/help.rs - List · Shows stored 2FA entries
src/commands/list.rs - Add · Creates a new 2FA entry
src/commands/add.rs - Delete · Deletes an existing entry
src/commands/delete.rs - Get · Retrieves or generates the current integer token
src/commands/get.rs
Command core
Routing, subcommands, and token generation
- Commands · Shared command parsing and subcommand dispatch
src/commands.rs - Del line · Line-based deletion helper for storage updates
src/commands/delline.rs - OTP engine · Computes one-time integers from stored secrets
- HMAC-SHA1 · Core hash/MAC used by token generation
- Byte order · Handles binary layout for OTP inputs and counters
Local state
Filesystem-backed entry storage
- Registry · Filesystem-backed 2FA entry records
- Secret data · Stored account identifier and secret material
Connections 16
- gi → Commands: dispatches · Program startup routes into shared command handling
- Commands → Help: help · Resolves help-oriented requests
- Commands → List: list · Routes listing requests
- Commands → Add: add · Routes creation requests
- Commands → Delete: delete · Routes removal requests
- Commands → Get: get/run · Routes token-generation requests
- Add → Registry: append · Adds a new entry to local storage
- List → Registry: read · Reads stored entries for display
- Delete → Del line: uses · Delegates line-based storage removal
- Del line → Registry: edit · Updates the registry file in place
- Delete → Registry: remove · Deletes an entry from local storage
- Get → Registry: lookup · Finds the selected record before generating a token
- Get → Secret data: uses · Consumes stored secret material
- Secret data → OTP engine: feeds · Secret data is transformed into an OTP value
- OTP engine → HMAC-SHA1: depends on · Token generation is based on HMAC-SHA1
- OTP engine → Byte order: depends on · Binary encoding is handled during token computation