# pet1h/memplace architecture

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

- Interactive diagram: https://gitdiagram.com/pet1h/memplace
- Repository: https://github.com/pet1h/memplace

## Overview

Mem is a terminal command saver and fuzzy searcher. The user invokes the CLI, whose entry point resolves the data-file path, loads saved commands, and dispatches either the save or search workflow. Saving collects a description and persists a record; searching ranks records by string distance, opens a keyboard-driven TUI, and prints the selected command. The README documents the cross-platform JSON data file and these capabilities. Edges reflect the shown calls; the file store is external to the source tree.

Main entry points: [`src/main.rs`](https://github.com/pet1h/memplace/blob/main/src/main.rs) (CLI dispatcher), [`src/commands/save.rs`](https://github.com/pet1h/memplace/blob/main/src/commands/save.rs) (Save command), [`src/commands/search.rs`](https://github.com/pet1h/memplace/blob/main/src/commands/search.rs) (Search command), [`src/tui.rs`](https://github.com/pet1h/memplace/blob/main/src/tui.rs) (Result selector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_main["CLI dispatcher<br/>[main.rs]"]
  node_config["Data path config<br/>[config.rs]"]
end

subgraph group_save["Save workflow"]
  node_save_command["Save command<br/>[save.rs]"]
  node_description["Description prompt<br/>[save.rs]"]
end

subgraph group_search["Search workflow"]
  node_search_command["Search command<br/>[search.rs]"]
  node_fuzzy_rank["Fuzzy ranking<br/>[storage.rs]"]
  node_search_tui["Result selector<br/>[tui.rs]"]
end

subgraph group_data["Data layer"]
  node_storage_io["JSON persistence<br/>[storage.rs]"]
  node_json_file[("JSON data file")]
end

node_user(("CLI user"))
node_terminal(("Terminal output"))

node_user -->|"invokes"| node_main
node_main -->|"gets data path"| node_config
node_main -->|"loads records"| node_storage_io
node_main -->|"dispatches save"| node_save_command
node_main -->|"dispatches search"| node_search_command
node_save_command -->|"prompts for"| node_description
node_save_command -->|"creates and writes"| node_storage_io
node_search_command -->|"ranks records"| node_fuzzy_rank
node_search_command -->|"opens selector"| node_search_tui
node_search_tui -->|"renders and reads keys"| node_terminal
node_search_tui -->|"prints selection"| node_terminal
node_storage_io -->|"reads and writes"| node_json_file

click node_main "https://github.com/pet1h/memplace/blob/main/src/main.rs"
click node_config "https://github.com/pet1h/memplace/blob/main/src/config.rs"
click node_save_command "https://github.com/pet1h/memplace/blob/main/src/commands/save.rs"
click node_description "https://github.com/pet1h/memplace/blob/main/src/commands/save.rs"
click node_search_command "https://github.com/pet1h/memplace/blob/main/src/commands/search.rs"
click node_fuzzy_rank "https://github.com/pet1h/memplace/blob/main/src/storage.rs"
click node_search_tui "https://github.com/pet1h/memplace/blob/main/src/tui.rs"
click node_storage_io "https://github.com/pet1h/memplace/blob/main/src/storage.rs"

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_main,node_config,node_user toneBlue
class node_save_command,node_description toneAmber
class node_search_command,node_fuzzy_rank,node_search_tui toneMint
class node_storage_io,node_json_file toneRose
class node_terminal toneIndigo
```

## Components

### CLI entry

- [CLI dispatcher](https://github.com/pet1h/memplace/blob/main/src/main.rs): `src/main.rs`
- [Data path config](https://github.com/pet1h/memplace/blob/main/src/config.rs): `src/config.rs`

### Save workflow

- [Save command](https://github.com/pet1h/memplace/blob/main/src/commands/save.rs): `src/commands/save.rs`
- [Description prompt](https://github.com/pet1h/memplace/blob/main/src/commands/save.rs): `src/commands/save.rs`

### Search workflow

- [Search command](https://github.com/pet1h/memplace/blob/main/src/commands/search.rs): `src/commands/search.rs`
- [Fuzzy ranking](https://github.com/pet1h/memplace/blob/main/src/storage.rs): `src/storage.rs`
- [Result selector](https://github.com/pet1h/memplace/blob/main/src/tui.rs): `src/tui.rs`

### Data layer

- [JSON persistence](https://github.com/pet1h/memplace/blob/main/src/storage.rs): `src/storage.rs`
- **JSON data file**

### Other components

- **CLI user**
- **Terminal output**

## Connections

- CLI user → CLI dispatcher: invokes (evidence: `README.md`)
- CLI dispatcher → Data path config: gets data path (evidence: `src/main.rs`)
- CLI dispatcher → JSON persistence: loads records (evidence: `src/main.rs`)
- CLI dispatcher → Save command: dispatches save (evidence: `src/main.rs`)
- CLI dispatcher → Search command: dispatches search (evidence: `src/main.rs`)
- Save command → Description prompt: prompts for (evidence: `src/commands/save.rs`)
- Save command → JSON persistence: creates and writes (evidence: `src/commands/save.rs`)
- Search command → Fuzzy ranking: ranks records (evidence: `src/commands/search.rs`)
- Search command → Result selector: opens selector (evidence: `src/commands/search.rs`)
- Result selector → Terminal output: renders and reads keys (evidence: `src/tui.rs`)
- Result selector → Terminal output: prints selection (evidence: `src/tui.rs`)
- JSON persistence → JSON data file: reads and writes (evidence: `src/storage.rs`)
