# krishna4a6av/showcmm architecture

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

- Interactive diagram: https://gitdiagram.com/krishna4a6av/showcmm
- Repository: https://github.com/krishna4a6av/showcmm

## Overview

showcmm is a CLI for importing shell history into local command-frequency statistics, browsing those statistics, and optionally sending a summary for AI analysis. The main workflow runs through `main.py`: users update, view, delete, or request analysis; history import parses configured shell files before storing commands, while views and AI summaries read the stored data. The README documents several shell parsers and AI modes; source excerpts show their shared implementation paths, but not every runtime detail.

Main entry points: [`main.py`](https://github.com/krishna4a6av/showcmm/blob/main/main.py) (Command router), [`functions/history.py`](https://github.com/krishna4a6av/showcmm/blob/main/functions/history.py) (History importer), [`functions/ai.py`](https://github.com/krishna4a6av/showcmm/blob/main/functions/ai.py) (AI analysis), [`functions/show_commands.py`](https://github.com/krishna4a6av/showcmm/blob/main/functions/show_commands.py) (Command queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_main["Command router<br/>[main.py]"]
  node_display["Table display<br/>[display.py]"]
end

subgraph group_import["History import"]
  node_history["History importer<br/>[history.py]"]
  node_shellconfig["Shell config<br/>[read_toml.py]"]
  node_parser["History parsers<br/>[parser.py]"]
end

subgraph group_analysis["Analysis"]
  node_commands["Command queries<br/>[show_commands.py]"]
  node_jsondata["AI data summary<br/>[json_data.py]"]
  node_ai["AI analysis<br/>[ai.py]"]
  node_prompts["AI modes<br/>[config.py]"]
end

subgraph group_data["Local data"]
  node_delete["History deletion<br/>[delete.py]"]
  node_database[("SQLite statistics<br/>[database.py]")]
end

node_user(("CLI user"))
node_shellfiles["Shell history files"]
node_provider(("AI provider"))

node_user -->|"runs commands"| node_main
node_main -->|"starts import"| node_history
node_main -->|"requests view"| node_commands
node_main -->|"displays results"| node_display
node_main -->|"requests deletion"| node_delete
node_main -->|"requests analysis"| node_ai
node_history -->|"loads settings"| node_shellconfig
node_shellfiles -->|"provides history"| node_history
node_history -->|"parses lines"| node_parser
node_history -->|"inserts commands"| node_database
node_commands -->|"queries statistics"| node_database
node_commands -->|"normalizes commands"| node_parser
node_commands -->|"returns results"| node_main
node_jsondata -->|"reads statistics"| node_database
node_jsondata -->|"normalizes commands"| node_parser
node_ai -->|"builds input"| node_jsondata
node_ai -->|"selects prompt"| node_prompts
node_ai -.->|"sends analysis"| node_provider
node_provider -.->|"returns response"| node_ai
node_delete -->|"removes database"| node_database

click node_main "https://github.com/krishna4a6av/showcmm/blob/main/main.py"
click node_display "https://github.com/krishna4a6av/showcmm/blob/main/utils/display.py"
click node_history "https://github.com/krishna4a6av/showcmm/blob/main/functions/history.py"
click node_shellconfig "https://github.com/krishna4a6av/showcmm/blob/main/utils/read_toml.py"
click node_parser "https://github.com/krishna4a6av/showcmm/blob/main/utils/parser.py"
click node_commands "https://github.com/krishna4a6av/showcmm/blob/main/functions/show_commands.py"
click node_jsondata "https://github.com/krishna4a6av/showcmm/blob/main/utils/json_data.py"
click node_ai "https://github.com/krishna4a6av/showcmm/blob/main/functions/ai.py"
click node_prompts "https://github.com/krishna4a6av/showcmm/blob/main/config.py"
click node_delete "https://github.com/krishna4a6av/showcmm/blob/main/functions/delete.py"
click node_database "https://github.com/krishna4a6av/showcmm/blob/main/db/database.py"

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_display,node_user toneBlue
class node_history,node_shellconfig,node_parser toneAmber
class node_commands,node_jsondata,node_ai,node_prompts toneMint
class node_delete,node_database toneRose
class node_shellfiles,node_provider toneIndigo
```

## Components

### CLI

- [Command router](https://github.com/krishna4a6av/showcmm/blob/main/main.py): `main.py`
- [Table display](https://github.com/krishna4a6av/showcmm/blob/main/utils/display.py): `utils/display.py`

### History import

- [History importer](https://github.com/krishna4a6av/showcmm/blob/main/functions/history.py): `functions/history.py`
- [Shell config](https://github.com/krishna4a6av/showcmm/blob/main/utils/read_toml.py): `utils/read_toml.py`
- [History parsers](https://github.com/krishna4a6av/showcmm/blob/main/utils/parser.py): `utils/parser.py`

### Analysis

- [Command queries](https://github.com/krishna4a6av/showcmm/blob/main/functions/show_commands.py): `functions/show_commands.py`
- [AI data summary](https://github.com/krishna4a6av/showcmm/blob/main/utils/json_data.py): `utils/json_data.py`
- [AI analysis](https://github.com/krishna4a6av/showcmm/blob/main/functions/ai.py): `functions/ai.py`
- [AI modes](https://github.com/krishna4a6av/showcmm/blob/main/config.py): `config.py`

### Local data

- [History deletion](https://github.com/krishna4a6av/showcmm/blob/main/functions/delete.py): `functions/delete.py`
- [SQLite statistics](https://github.com/krishna4a6av/showcmm/blob/main/db/database.py): `db/database.py`

### Other components

- **CLI user**
- **Shell history files**
- **AI provider**

## Connections

- CLI user → Command router: runs commands
- Command router → History importer: starts import
- Command router → Command queries: requests view
- Command router → Table display: displays results
- Command router → History deletion: requests deletion
- Command router → AI analysis: requests analysis
- History importer → Shell config: loads settings
- Shell history files → History importer: provides history
- History importer → History parsers: parses lines
- History importer → SQLite statistics: inserts commands
- Command queries → SQLite statistics: queries statistics
- Command queries → History parsers: normalizes commands
- Command queries → Command router: returns results
- AI data summary → SQLite statistics: reads statistics
- AI data summary → History parsers: normalizes commands
- AI analysis → AI data summary: builds input
- AI analysis → AI modes: selects prompt
- AI analysis → AI provider: sends analysis
- AI provider → AI analysis: returns response
- History deletion → SQLite statistics: removes database
