# anrighe/smile architecture

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

- Interactive diagram: https://gitdiagram.com/anrighe/smile
- Repository: https://github.com/anrighe/smile

## Overview

SMILE is a shell command-not-found suggestion engine. The documented workflow starts when the shell cannot resolve a command, invokes SMILE with the misspelled name, scans configured PATH directories for executables, optionally filters candidates, calculates Damerau–Levenshtein distances, and prints the closest suggestions. Configuration and optional history storage are supporting capabilities. The initializer-to-program link is documented in the README; the initializer script itself was not sampled.

Main entry points: [`src/main.cpp`](https://github.com/anrighe/smile/blob/main/src/main.cpp) (Suggestion workflow), [`include/Settings.hpp`](https://github.com/anrighe/smile/blob/main/include/Settings.hpp) (Settings loader), [`initializer/command_not_found_handle.sh`](https://github.com/anrighe/smile/blob/main/initializer/command_not_found_handle.sh) (Not-found handler), [`include/DatabaseStatements.hpp`](https://github.com/anrighe/smile/blob/main/include/DatabaseStatements.hpp) (History SQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Shell entry"]
  node_not_found["Not-found handler"]
  node_cli["CLI entry<br/>[main.cpp]"]
end

subgraph group_matching["Command matching"]
  node_matcher["Suggestion workflow<br/>[main.cpp]"]
  node_binary_scan["Executable scanner<br/>[CommonUtils.hpp]"]
  node_heuristic["Candidate filter<br/>[main.cpp]"]
  node_distance["Edit distance"]
  node_suggestions["Suggestion output<br/>[main.cpp]"]
end

subgraph group_configuration["Configuration and history"]
  node_settings["Settings loader<br/>[Settings.hpp]"]
  node_sql_statements["History SQL"]
  node_history_db[("SQLite history")]
end

node_shell(("Bash shell"))

node_shell -->|"unresolved command"| node_not_found
node_not_found -->|"runs SMILE"| node_cli
node_cli -->|"loads settings"| node_settings
node_cli -->|"passes command"| node_matcher
node_matcher -->|"scans PATH"| node_binary_scan
node_matcher -->|"filters candidates"| node_heuristic
node_matcher -->|"calculates distances"| node_distance
node_matcher -->|"prints closest"| node_suggestions
node_settings -->|"creates schema query"| node_sql_statements
node_settings -->|"opens and creates"| node_history_db
node_sql_statements -->|"prepares SQL"| node_history_db

click node_not_found "https://github.com/anrighe/smile/blob/main/initializer/command_not_found_handle.sh"
click node_cli "https://github.com/anrighe/smile/blob/main/src/main.cpp"
click node_matcher "https://github.com/anrighe/smile/blob/main/src/main.cpp"
click node_binary_scan "https://github.com/anrighe/smile/blob/main/include/CommonUtils.hpp"
click node_heuristic "https://github.com/anrighe/smile/blob/main/src/main.cpp"
click node_distance "https://github.com/anrighe/smile/blob/main/include/WordDistanceHandler.hpp"
click node_suggestions "https://github.com/anrighe/smile/blob/main/src/main.cpp"
click node_settings "https://github.com/anrighe/smile/blob/main/include/Settings.hpp"
click node_sql_statements "https://github.com/anrighe/smile/blob/main/include/DatabaseStatements.hpp"

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_not_found,node_cli toneBlue
class node_matcher,node_binary_scan,node_heuristic,node_distance,node_suggestions toneAmber
class node_settings,node_sql_statements,node_history_db toneMint
class node_shell toneIndigo
```

## Components

### Shell entry

- [Not-found handler](https://github.com/anrighe/smile/blob/main/initializer/command_not_found_handle.sh): `initializer/command_not_found_handle.sh`
- [CLI entry](https://github.com/anrighe/smile/blob/main/src/main.cpp): `src/main.cpp`

### Command matching

- [Suggestion workflow](https://github.com/anrighe/smile/blob/main/src/main.cpp): `src/main.cpp`
- [Executable scanner](https://github.com/anrighe/smile/blob/main/include/CommonUtils.hpp): `include/CommonUtils.hpp`
- [Candidate filter](https://github.com/anrighe/smile/blob/main/src/main.cpp): `src/main.cpp`
- [Edit distance](https://github.com/anrighe/smile/blob/main/include/WordDistanceHandler.hpp): `include/WordDistanceHandler.hpp`
- [Suggestion output](https://github.com/anrighe/smile/blob/main/src/main.cpp): `src/main.cpp`

### Configuration and history

- [Settings loader](https://github.com/anrighe/smile/blob/main/include/Settings.hpp): `include/Settings.hpp`
- [History SQL](https://github.com/anrighe/smile/blob/main/include/DatabaseStatements.hpp): `include/DatabaseStatements.hpp`
- **SQLite history**

### Other components

- **Bash shell**

## Connections

- Bash shell → Not-found handler: unresolved command (evidence: `README.md`)
- Not-found handler → CLI entry: runs SMILE (evidence: `README.md`)
- CLI entry → Settings loader: loads settings (evidence: `src/main.cpp`)
- CLI entry → Suggestion workflow: passes command (evidence: `src/main.cpp`)
- Suggestion workflow → Executable scanner: scans PATH (evidence: `src/main.cpp`)
- Suggestion workflow → Candidate filter: filters candidates (evidence: `src/main.cpp`)
- Suggestion workflow → Edit distance: calculates distances (evidence: `src/main.cpp`)
- Suggestion workflow → Suggestion output: prints closest (evidence: `src/main.cpp`)
- Settings loader → History SQL: creates schema query (evidence: `include/Settings.hpp`)
- Settings loader → SQLite history: opens and creates (evidence: `include/Settings.hpp`)
- History SQL → SQLite history: prepares SQL (evidence: `include/DatabaseStatements.hpp`)
